我已经定义了一组动作,并试图将其添加到多个参与者中。这是代码:
ParallelAction actions = new ParallelAction();
RotateByAction rotateAction = new RotateByAction();
rotateAction.setAmount(rotationAmount);
ScaleByAction scaleAction = new ScaleByAction();
scaleAction.setAmount(-0.01f);
DelayAction delayAction = new DelayAction();
delayAction.setDuration(0.05f);
RepeatAction rAction = new RepeatAction();
rAction.setCount(100);
actions.addAction(rotateAction);
actions.addAction(scaleAction);
actions.addAction(delayAction);
rAction.setAction(actions);
for(Monster mon : mons) // mons is ArrayList of type Monster (which extends Image)
mon.addAction(rAction);
但是上面的逻辑只是将动作添加到我的 ArrayList 中的最后一个actor。为什么我不能对多个演员使用相同的动作?我需要定义与演员一样多的动作,还是有其他方法可以做到这一点?
我在这里查看了 Pool https://code.google.com/p/libgdx/wiki/scene2d我似乎没有掌握它。它对我的问题有用吗?如果是,那么如何?