Keep actors from moving with collision!

iPhoneDevForMeiPhoneDevForMe Member Posts: 362
edited November -1 in Working with GS (Mac)
I've spent a day or so trying to make this work, but im stuck.

I have an actor that moves left to right based on input from the accelerometer. Lets say it is called ship. An invisible actor is constrained to the ships x position so it follows the actor. This actor could be called collision.

When you press the screen it changes a boolean game attribute called move to true and change to false if touch is released.

Another actor on the screen called orb has a rule that states when the actor collides with my invisible actor called collision and if move is true, then move towards the ship. (in other words touch the screen when the ship is near an object and the object will move toward the ship)

My problem is the ship actor continues to move and if my invisible actor collides with another orb it starts to move towards the ship as well. While one orb is moving towards the ship, I dont want any other orbs to be able to move at the same time if they collide with the invisible actor.

I have tried many ways to keep this from happening without much luck! Any idea's? If this does not make since I can maybe email someone the prototype and see what they come up with?

If I cant make that work, what can I do to make the ship stop moving while the screen is being touched?

Thanks in advance

Comments

  • MappdevMappdev Member Posts: 16
    You need to use attributes (variables), preferably booleans. When something starts moving toward the ship, set the boolean to false and include this boolean in all your behaviors. If this boolean is false, then the user's taps won't have any further effects, until you set it to true again.

    Always use booleans!
  • ValanValan Member, BASIC Posts: 410
    One way is to use dummy orbs that are set to non Movable. When an orb should move a "moving" orb is spawned and the original dummy orb is destroyed. This spawn/destroy would be included in the when collide.

    Hope this helps
Sign In or Register to comment.