如何使演员在Libgdx中一个接一个地执行特定动作 [英] How to make actors do the specific action one after another in Libgdx

查看:98
本文介绍了如何使演员在Libgdx中一个接一个地执行特定动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个问题.>.

  1. 我有2个actor(actor1,actor2)和一个动作(例如ScaleTo).我的意愿是首先使actor1达到比例,然后(也许两秒钟后)将actor2缩放.或随机选择演员执行动作,然后重复该过程n次.

  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.

有没有像squenceAction这样的方法,但是可能像这样的序列(Actor1.action,delay,Actor2.action,......)"

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

还是有时间轴API,我可以将actor的动作放在几个特定的​​时间点上?

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

推荐答案

不是一种更正确的方法,但是在我看来,如果我理解了您的问题,则可以在您的侦听器中输入以下内容:

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
}

取决于您要做什么,我认为最好将第一个演员完成动作多长时间,例如在2秒之前,将其放置在第二个演员两秒钟的延迟中,以便在第二演员.

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.

测试:0.2f + 1.8,不是+ fadeOut,因为是平行的

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

添加延迟; 2.1f

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

P.S:希望您能理解我所说的话.

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

这篇关于如何使演员在Libgdx中一个接一个地执行特定动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆