How to click on touch button so the actor will react for x seconds?
Zwire
Member, PRO Posts: 182
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
When touch is pressed
--play animation
--Timer: After x seconds
----Change image to . . .
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.
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.
Can you upload a screenshot of your rules.
Yes I can.
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
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 for your reply. I will check the gslogic series.
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.