Rotating a image

SANDEEP410SANDEEP410 Member Posts: 46
edited May 2012 in Working with GS (Mac)
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

Best Answer

  • MotherHooseMotherHoose Posts: 2,456
    Accepted Answer
    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/?5rf2ubb9fhooeb2

    image MH

Answers

  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    edited May 2012
    If you want it to not move then uncheck the movable option in the wheel actor. There you will also find a drop down menu with the collision types, choose circle.

    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.

  • SANDEEP410SANDEEP410 Member Posts: 46
    using the circle option also doesnt use precise collision
    I cretaed a rule to rotate if it collides with ball.But it doesnt rotate
Sign In or Register to comment.