Need help with animation stopping

brett-nortonbrett-norton Posts: 54
edited April 25 in Working with GS (Mac)

Hi All

I Have built a game similar to the Whack a Monster template. (Whack A Mole Type Game)
I have animation up working and down working but i want an animation in between basically an idle animation.

Actor Pop Up Code
If Self.Enemy.Up is false - Do Timer Random 1,10 Animate & Change Attribute Self.Enemy.Up to True

Actor Pop Back Down Code.
If Self.Enemy.Up is True Do - Timer Random 1,4 Animate & Change Attribute Self.Enemy.Up to False

Now problem is i want to add another animation in between actor up and actor down kind of a waiting motion/idle
the code i have is:

Rule When self image contains (Last image of the up animation) Do Animate.

Now it will work but the image will change but it will not animate it changes to a still image.

What am i doing wrong. :neutral:

Thanks in advance.


  • tatiangtatiang Posts: 10,713
    edited April 25

    Your rule looks something like this:

    When self.Image=animation45.png

    The problem is that when the animation begins, self.Image changes value to whatever the first frame is (e.g. animation1.png). So the rule condition becomes false and the animation stops.

    You can fix this one of two ways... either by changing an attribute value or by using a Timer with run to completion checked:

    Method 1:
    When self.Image=animation45.png
         Change Attribute self.idleAnimation to true

    When attribute self.idleAnimation is true

    But then you'd need a way to change self.idleAnimation back to false.

    Method 2:
    When self.Image=animation45.png
         Timer after 0 seconds (run to completion must be checked)

    Run to completion causes the behavior(s) in the Timer to run even if the rule condition becomes false.

  • Sounds like a plan... will give that a shot tommorow. Thanks tatiang

  • This didnt work either, it picked up the self.image = certain image do animate. But it still did not animate it just changed the first image in the animation.

  • tatiangtatiang Posts: 10,713

    Can you post a screenshot of your rules?

  • tatiangtatiang Posts: 10,713

    Check out this demo.

  • Still cant get it to work, :s

    G.jpg 659.6K
  • tatiangtatiang Posts: 10,713

    Having the rules is helpful but also... did my demo work for you? If your rules are not working, what happens when you test them? I'm assuming you changed something after your original post based on seeing my demo...

  • tatiangtatiang Posts: 10,713

    Your last Animate behavior needs to be inside a Timer with run to completion set to true, as I suggested (and demo'ed) above.

  • Thanks i got it working from the above method works great now. Thanks again

  • tatiangtatiang Posts: 10,713

    You're welcome.

Sign In or Register to comment.