Body:applyForce - angle

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Gru
Prole
Posts: 3
Joined: Thu Jun 10, 2010 11:29 am
Location: Russia
Contact:

Body:applyForce - angle

Post by Gru »

I do not speak English, so I'll post the .love and image
Image
Attachments
game.love
controls: a, d
(4.35 KiB) Downloaded 173 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Body:applyForce - angle

Post by Robin »

Please don't use fullscreen. It's very annoying and it didn't return to the normal resolution afterwards.

If I understand you correctly, the solution you seek requires trigonometry. Without looking at your code, something like:

Code: Select all

angle = body:getAngle()
body:applyForce(strength * cos(angle), strength * sin(angle))
As I said, I didn't look at your code and this is untested.
Help us help you: attach a .love.
User avatar
Gru
Prole
Posts: 3
Joined: Thu Jun 10, 2010 11:29 am
Location: Russia
Contact:

Re: Body:applyForce - angle

Post by Gru »

Thanks! you really helped me :awesome:
--sorry for the fullscreen
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests