Rotating a image
I have a wheel which needs to be rotated when ball hits it. Wheel should only rotate around its centre and should not move to and fro.
How to make it rotate, i tried checking and unchecking but fixed rotation option but no use.
Also how can i use precise collision.Currenly my ball collides on the rectangle image.I want to just collide with the rms of wheels
How to make it rotate, i tried checking and unchecking but fixed rotation option but no use.
Also how can i use precise collision.Currenly my ball collides on the rectangle image.I want to just collide with the rms of wheels
Best Answer
-
MotherHoose Posts: 2,456
gameAttribute: boolean … name: wheelRotate
if you want to keep actors' behaviors locked:
…add two more: wheelX and wheelY … index type
on wheelActor:
Rule: when
Event: overlaps or collides with ball
--Rule: when
--Attribute: game.wheelRotate is true
---Rotate behavior
Otherwise: changeAttribute: self.rotation To: 0
on ballActor
Rule: when
Event: overlaps or collides with wheel
--Rule: when
--Attribute: self.Position.X ≤ magnitude( game.wheelX - self.Position.X , game.wheelY - self.Position.Y )
--changeAttribute: game.wheelRotate To: true
Otherwise: changeAttribute: game.wheelRotate To: false
both have Collision Shape: Circle
==
yuck! sometimes the explanation is more complicated than actually doing!
demo: http://www.mediafire.com/?5rf2ubb9fhooeb2MH
Answers
To have it to rotate during collisions let the fixed rotation option unchecked. If you want the wheel to have a specific rotation you could add a rotate behavior to a collision rule.
I cretaed a rule to rotate if it collides with ball.But it doesnt rotate