更改actor的颜色和alpha不能在Scene2D中工作; scaleTo,moveBy虽然工作。可能是什么问题?
@Override
public void render(float alpha){
stage.act(delta);
table.setTransform(true);
//works
table.addAction(Actions.scaleTo(2.3f, 2.5f, 2f)));
//does not work
table.addAction(Actions.alpha(0.2f, 2f));
//does not work either
table.addAction(Actions.color(new Color(1f,1f,1f, 0.2f), 2f));
stage.draw();
}
答案 0 :(得分:3)
每次要渲染屏幕时都会调用方法render()
。所以你的代码从每一帧开始就开始动作,没有任何变化。
您应该将这些行从render()
方法移到其他位置(例如show()
对象的Screen
方法:
table.setTransform(true);
//works
table.addAction(Actions.scaleTo(2.3f, 2.5f, 2f)));
//does not work
table.addAction(Actions.alpha(0.2f, 2f));
//does not work either
table.addAction(Actions.color(new Color(1f,1f,1f, 0.2f), 2f));