[Solved] Animation and clickable object

Started by actaria, Wed 27/07/2022 12:42:21

Previous topic - Next topic

actaria

Hello,

Once again i will need your help.

I made a cuckoo animation with 2 loops.
view 6 is used for cuckoo animations
loop 0 = is the clock working
loop 1 = is the bird coming out of the cuckoo


What i wanted to make is the cuckoo animate when i enter the room and if the player click on it the bird comes out of it

It works really well but the problem is that once you click on it and the bird came out the animation is stop and the clock isn't working anymore.

Of course if want the program to go back to the 1st loop so the clock still look animated.

Code: ags

function room_AfterFadeIn()
{

object[0].SetView(6);
object[0].Animate(0, 4, eRepeat, eNoBlock);

}


function cuckoo_Interact()
{

object[0].SetView(6);
object[0].Animate(1, 4, eOnce, eNoBlock);


}


Thank you so much again for you help.

Matti

#1
You can put a check in the repeatedly execute-function.

Code: ags

if (!object[0].Animating) object[0].Animate(0, 4, eRepeat, eNoBlock);


So if the cuckoo clock isn't currently animating, the animation starts again.

I advice you to give the objects a name, otherwise it can get quite confusing if you have a lot of objects.
Edit: Looking at the function it seems you have given the object a name. Then you can use it like this: cuckoo.Animate(0, 4, eRepeat, eNoBlock);

actaria

It's perfectly working thanks a lot Matti for the explanation have a great day.

SMF spam blocked by CleanTalk