How to rotate a wheel with touching (spinning it)
aalzanki
Member Posts: 283
How to rotate a wheel with touching (spinning it)
I want to rotate the wheel by spinning it to the right or to the left, and i don't want the wheel to move I only want it to spin.
Thank You.
I want to rotate the wheel by spinning it to the right or to the left, and i don't want the wheel to move I only want it to spin.
Thank You.
Comments
Thank you
when touch is pressed
constrain self.rotation to VectorToAngle (game.touch1.X, game.touch1.Y)
if this doesn't work try:
Create two integer game attributes spinX and spinY
Create an invisible actor with rule:
when touch is pressed
constrain self.positionY to touchY
constrain self.positionX to touchX
constrain game.spinY to self.positionY
constrain game.spinX to self.positionX
In the spinning objecting:
When touch is pressed and inside
constrain self.rotation to VectorToAngle(self.positionX-game.spinX, self.position.Y-game.spinY)
Hopefully one of these will work or will at least get you going in the right direction!
Would it be possible to have 2 fingers touching the objects and rotate accordingly as where they move.... if you played enigmo that same movement
i think it is also used for photos when you have them in a kind of desktop arrangement,,,saw that with the sixth sense project.
it worked
Something like:
vectorToAngle((TouchX2-TouchX1), (TouchY2-TouchY1))
I think that would work.
You could even maybe constrain the X and Y position based on the midpoint of the two touches. Although, upon initial touch, you may have to establish a baseline rotation and/or X/Y position to work from.
EDIT: Actually, upon further reading of this thread, it looks like Scitunes may be doing a bit of all this so play with his example. If you don't constrain, then you will have to wrap your updates in a fairly frequently occuring timer and that could still produce a choppy effect. For the flick-of-the-wheel as the original poster asked, TSB's non-constrained would be best since it is a quick, one-time (so to speak) movement.
I used Scintunes second example, but i want if the wheel rotates quickly move the other actor quickly and if it moves at a low speed move it at a low speed and if you stop rotating stop the other actor how ?
regards,
Time between each touchpoint to determine speed (i.e. less time=faster slide=more speed)?
Generic single touch to stop (or very little movement between touch and release...use magnitude()).
Angular drag to eventually slow things down for a more realistic feel.
I have a wheel and a flag so i want when the wheel rotate the flag move upward.
Regards,