Silly Question

gariantrollgariantroll Member Posts: 219
edited November -1 in Working with GS (Mac)
How do I put in an animation with a key press? The problem is my animation only plays when the input is held down from the keypad. I just want the input to be pressed and not held down and the animation to play once. How do I accomplish this? Thanks for helping me.

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    create a game.Attribute boolean call it keyPressed

    in the key Actor create a [Rule] when key is down changeAttribute [exp] game.keyPressed To: true

    in your animation Actor create a [Rule] when keyPressed = true
    do the animation

    to free things up:
    time the animation and drag in a Timer and set After to that animation time and drag in change.Attribute to change keyPressed to false.

    MH
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Do a rule
    When Key is Down
    --Change Attribute self.animate to true

    When Attribute self.animate equals true
    --animate

    then since i'm assuming you want to be able to replay the animation with more key presses.
    find the image name of the last frame of your animation and add one more rule

    When Attribute self.image equals imagename.png
    --Change Attribute self.animate to false

    You could also try using an otherwise in the first rule to change attribute back to false but that may kill your animation just like you released the key.

    Good Luck
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Well looks like you go two answers 4 seconds apart. I've got to learn to type faster. LOL
  • MotherHooseMotherHoose Member Posts: 2,456
    oh @tenrdmer... I like your way best!

    ;) so many ways to skin this cat!

    MH
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    MotherHoose said:
    ;) so many ways to skin this cat!

    MH

    So true.

    I'm not a fan of the GS timers. I've had them act real funny on me. If I cant use interpolate for the timer I usually will look for another way before that freaking timer.
  • gariantrollgariantroll Member Posts: 219
    thanks guys

    I will try this out.
  • gariantrollgariantroll Member Posts: 219
    Hey guys, I have one more problem. I can't find the animate attribute.
  • gariantrollgariantroll Member Posts: 219
    oh that is a made attribute i guess
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    yes that is one you have to make
    Also keep in mind you may need to combine both ways since mine is based on a keyboard key and motherhoose's is based on an actor button on screen. that will determine wether you want to create a game attribute or self attribute. if you plan on making an iphone game I would go ahead and create it as a game attribute and put the key rule inside you button actor. then you have keyboard button assigned to do the same as on onscreen button and it make testing more realistic.
  • gariantrollgariantroll Member Posts: 219
    Thank you, I am having no problems. Now on to some collisions.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    Just put in the rule a for inf second timer and say run to completion.
Sign In or Register to comment.