GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to click on touch button so the actor will react for x seconds?

ZwireZwire Posts: 165Member, BASIC

I want to let a character duck after pressing a touch button. I have an animation for ducking.

How can I let my player duck for x seconds with one click on the touch button?

Any help is appreciated.

Comments

  • SocksSocks London, UK.Posts: 12,822Member
    edited April 2016

    When touch is pressed
    --play animation
    --Timer: After x seconds
    ----Change image to . . .

  • ZwireZwire Posts: 165Member, BASIC

    Hi Socks,

    Thanks for your reply.

    I cant find a behavior called play animation.

    What do you mean?

    I tried to implement the timer and change image behavior into the duck rules but nothing happened.

  • SocksSocks London, UK.Posts: 12,822Member

    @Zwire said:
    I cant find a behavior called play animation.

    My post was simply an outline of the rule structure (it was not 'code'), if you want to play an animation you can use the Animate behaviour.

    @Zwire said:
    I tried to implement the timer and change image behavior into the duck rules but nothing happened.

    Can you upload a screenshot of your rules.

  • ZwireZwire Posts: 165Member, BASIC
  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,904Member
    edited April 2016

    You need more than one frame of animation. If you only have one frame you can just use a change image instead. But if you are using animate you need to uncheck loop and restore actor image so the animation stays on the last frame for as long as you want.

  • ZwireZwire Posts: 165Member, BASIC

    Hi Oasis,

    Thanks for your help.

    If I uncheck loop and restore actor image the animation of the frame stays on forever.

    How can I change that so the animation stays on the frame only for a few seconds?

    Putting in a timer doesn't seem to work.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,904Member

    @Zwire said:
    Hi Oasis,

    Thanks for your help.

    If I uncheck loop and restore actor image the animation of the frame stays on forever.

    How can I change that so the animation stays on the frame only for a few seconds?

    Putting in a timer doesn't seem to work.

    Okay so first get rid of the change attribute in the otherwise section as that will fire as soon as the press goes away. Instead add a timer that says after X seconds change attribute game.duck to false. I reccomend watching my videos GSlogic series. Just click the guru link in my signature. This will help you understand how to build code in gamesalad.

  • SocksSocks London, UK.Posts: 12,822Member

    @Zwire said:
    If I uncheck loop and restore actor image the animation of the frame stays on forever.

    Animate is really for animated image sequences (animations), when you say 'I have an animation for ducking', people will generally take that to mean you have an image sequence rather than a still image.

    The best thing to use here would be a change image behaviour.

    @Zwire said:
    How can I change that so the animation stays on the frame only for a few seconds?

    Just to clarify the terminology, there is no animation, we are dealing with still images here.

    You can do it like this:

    Change image to A
    --Timer: After X seconds
    ----Change image to B

  • ZwireZwire Posts: 165Member, BASIC

    @Lost_Oasis_Games said:

    @Zwire said:
    Hi Oasis,

    Thanks for your help.

    If I uncheck loop and restore actor image the animation of the frame stays on forever.

    How can I change that so the animation stays on the frame only for a few seconds?

    Putting in a timer doesn't seem to work.

    Okay so first get rid of the change attribute in the otherwise section as that will fire as soon as the press goes away. Instead add a timer that says after X seconds change attribute game.duck to false. I reccomend watching my videos GSlogic series. Just click the guru link in my signature. This will help you understand how to build code in gamesalad.

    Thanks for your reply. I will check the gslogic series.

  • ZwireZwire Posts: 165Member, BASIC

    @Socks said:

    @Zwire said:
    If I uncheck loop and restore actor image the animation of the frame stays on forever.

    Animate is really for animated image sequences (animations), when you say 'I have an animation for ducking', people will generally take that to mean you have an image sequence rather than a still image.

    The best thing to use here would be a change image behaviour.

    @Zwire said:
    How can I change that so the animation stays on the frame only for a few seconds?

    Just to clarify the terminology, there is no animation, we are dealing with still images here.

    You can do it like this:

    Change image to A
    --Timer: After X seconds
    ----Change image to B

    Thanks Oasis. That did the trick. Some small things are so difficult to find out in Gamesalad :(.

    I had to check the box run to completion though. Otherwise it didnt work.

Sign In or Register to comment.