Need help with animation stopping

brett-nortonbrett-norton Member, BASIC Posts: 64
edited April 2017 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.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2017

    Your rule looks something like this:

    When self.Image=animation45.png
         Animate

    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
         Animate

    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)
              Animate

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

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

  • brett-nortonbrett-norton Member, BASIC Posts: 64

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

  • brett-nortonbrett-norton Member, BASIC Posts: 64

    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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Can you post a screenshot of your rules?

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Check out this demo.

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

  • brett-nortonbrett-norton Member, BASIC Posts: 64

    Still cant get it to work, :s

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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...

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

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

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

  • brett-nortonbrett-norton Member, BASIC Posts: 64

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You're welcome.

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

Sign In or Register to comment.