Spawn only one actor at a time?

kungfupanda99kungfupanda99 Member Posts: 27
edited May 2012 in Working with GS (Mac)
k so im working on a game where when you shake the device it spawns an actor but I only want one actor on the screen at a time so each time the user shakes it again I want it to be replaced with a different random actor any ideas?

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I assume from your post that you don't want to just change the image, but the entire actor. The most consistent approach would be to have one actor that just changes its image (and/or size) and its rule index and then have rules based on specific rule index values. The other way would be to destroy and spawn actors probably with a delay so that you can't just shake and have it destroy/spawn every 0.1 seconds.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • lukey5227lukey5227 Member Posts: 111
    Have a global variable of "Shake". Whatever spawns the actor, make sure right before that it changes "Shake" to true if its false and to false if its already true.

    In the actor, have "Shake" also. Do a Change Attribute "Self.Shake" to "Game.Shake". That way, make a rule saying "If Self.ShakeGame.Shake" meaning its been shaken, "Destroy this actor".

    Then, it should of already spawned another actor.

    Hope I helped! -5227
  • PoolePoole Member Posts: 3
    sure, The most consistent approach would be to have one actor that just changes its image (and/or size) and its rule index and then have rules based on specific rule index values.

    _______________
    Wonderful...The Prince of Tennis Costumes
Sign In or Register to comment.