Destroys before animation starts!
Hello everyone. I've downloaded GS and this is my first question.
I made simple game: Amoeba swims to place where I click with mouse. But when it collides with food, Amoeba changes animation (eating animation). After that I made rule, if food collides with Amoeba, it destroys itself. But, when I started to play, when they are colliding, the food dissapears, but Amoebas eating animation wont play.
Question: WHY ????
I made simple game: Amoeba swims to place where I click with mouse. But when it collides with food, Amoeba changes animation (eating animation). After that I made rule, if food collides with Amoeba, it destroys itself. But, when I started to play, when they are colliding, the food dissapears, but Amoebas eating animation wont play.
Question: WHY ????
Best Answers
-
gyroscope I am here.Posts: 6,598
@Apex
Hi, because GSC doesn't wait for the animation to finish before the Destroy Behaviour kicks in; you have to put a delay into the rules, exactly the same length of time that your Animate Behaviour plays. (Make sure your food actors are all instances, i.e unlocked; also I've made a boolean called AmoEat but this'll only work for one amoeba; if you're wanting more, the rules will become a bit more complicated):
Rule: When Actor (--food) overlaps or collides with actor of type Amoeba
Change Attribute AmoEat to true
Timer: After ?? seconds ( ---- "??" is the time the amoeba animation takes to run--)
Destroy
----and in the Amoeba actor:
Rule: When AmoEat is true
Animate
Timer: After ?? seconds
Change Attribute AmoEat to false
Hope that helps out.""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
-
gyroscope I am here.Posts: 6,598
Before GameSalad i used only GameEditor engine. There exits event called "Animation Finish".
Interesting to know, cheers. :-)
I've just had a thought, rather than the food just disappearing, have it fade out before the destroy. So the food actor Rule would change to:
Rule: When Actor (--food) overlaps or collides with actor of type Amoeba
Change Attribute AmoEat to true
Interpolate FoodActor.Color Alpha to 0 time: ?? secs
Timer: After ?? seconds ( ---- "??" is the time the amoeba animation takes to run--)
Destroy
--- might make it a bit more visually interesting...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
-
gyroscope I am here.Posts: 6,598
Sounding good! Best of luck with your game. :-)
PS Welcome to the Forums!""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers
And to make food respawn in random position when it has eaten:
Rule: When Food collides with Amoeba
Change Attribute canRespawn to true
in Amoebas rule: When if canRespawn is True
spawn actor food in randomX and randomY position.