How to make actors do the specific action one after another in Libgdx

帅比萌擦擦* 提交于 2019-12-13 19:45:26

问题


I've got three questions.>.<

  1. 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) actor2. Or randomly choose the actor to behave the action, and repeat the process n times.

  2. Are there any methods like squenceAction, but could be like this "sequence(Actor1.action,delay,Actor2.action,......)"

  3. Or is there be the timeline API which i can put the action of actor on several specific time points?


回答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.



来源:https://stackoverflow.com/questions/28020559/how-to-make-actors-do-the-specific-action-one-after-another-in-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!