Skip to content Skip to sidebar Skip to footer

How To Make Actors Do The Specific Action One After Another In Libgdx

I've got three questions.>.< I have 2 actors(actor1,actor2), and an action(eg. ScaleTo). My willing is to make actor1 do the scaleTo firstly,and then(maybe after two seconds

Solution 1:

not if be the more correct way, but it occurs to me that if I understand your question, you can put in your listener for example this:

Actor1.addAction(Actions.sequence(Actions.delay(0.1f),
                                 Actions.parallel(
                                 Actions.moveBy(0f, 600, 1f),
                                 Actions.fadeOut(0.8f))));

and in your render this one:

if (Actor1.getActions().size == 0) {

Actor2.addAction(Actions.sequence(Actions.delay(0.2f),
                                  Actions.parallel(
                                  Actions.moveBy(0f, 600, 1f),
                                  Actions.fadeOut(0.8f))));

//Actor1.addAction(Actions......add actions to the actor one again or// whatever you can think is that it's not what you really want to do,// but you can handle yourself with the method called from the if
}

depends what you want to do, I think it would be better that worked it how long the first actor to finish the action, before the 2 second for example, put it in the second actor two second delay, for start amimacion in second actor.

test: 0.2f + 1.8, not + fadeOut becouse is parallel

Actor1.addAction(Actions.sequence(Actions.delay(0.2f),
                                 Actions.parallel(
                                 Actions.moveBy(0f, 600, 1.8f),
                                 Actions.fadeOut(0.8f))));

add delay; 2.1f

Actor2.addAction(Actions.sequence(Actions.delay(2.1f),
                                  Actions.parallel(
                                  Actions.moveBy(0f, 600, 1f),
                                  Actions.fadeOut(0.8f))));

P.S: I hope you can understand what I say.

Post a Comment for "How To Make Actors Do The Specific Action One After Another In Libgdx"