How do I set angle of object in direction of motion

Get help using Construct 2

Post » Sun Dec 21, 2014 12:47 pm

During Drag and Drop, I want the object to set its angle in direction of the drag and drop motion. How do I do it?
Something big is coming...
To the Windows Store, App Store, Play Store and 14 other app marketplaces near you! :)
B
15
S
2
Posts: 62
Reputation: 856

Post » Sun Dec 21, 2014 4:04 pm

Give your object two local variables to store the object's previous position, say 'oldX' and 'oldY'. Now, every tick, set the objects angle to angle(Sprite.oldX, Sprite.oldY, Sprite.X, sprite.Y), then set 'oldX' and 'oldY' to the object's current X and Y positions. At the beginning of every frame, 'oldX' and 'oldY' will hold the object's previous position, so you use that to find the angle of motion.

Let me know if you have any questions.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,106

Post » Mon Dec 22, 2014 4:42 am

Thank you very much :) . Instead of using every tick though , using every 0.1s decreases violent shaking of the sprite.
Something big is coming...
To the Windows Store, App Store, Play Store and 14 other app marketplaces near you! :)
B
15
S
2
Posts: 62
Reputation: 856


Return to How do I....?

Who is online

Users browsing this forum: JarkeyBacon and 8 guests