我正在尝试使用动作扩展我的Actor。 但它不起作用。我只是希望我的演员在给定时间内增加/减小它的大小。
演员将等待我给出ScaleTo
的2秒持续时间。它根据我给它的MoveTo
动作正确移动。
public class SpriteTest extends Actor {
private Sprite sprite;
private TextureAtlas atlas;
Rectangle boundsd = new Rectangle();
public SpriteTest(FirstGame game) {
//super(game);
Gdx.app.log( FirstGame.LOG, "spritetest's costructor" );
atlas = new TextureAtlas(Gdx.files.internal("pages-info.atlas"));
sprite = atlas.createSprite("Plus");
}
public void draw(SpriteBatch batch,float parentAlpha) {
batch.draw(sprite, x, y);
}
// We are adding the actor to the stage in another class
public class LevelScreen extends AbstractScreen {
private Jumper2D jumper2d;
SpriteTest obstacled = new SpriteTest(game);
public LevelScreen(FirstGame game) {
super(game);
}
@Override
protected boolean isGameScreen() {
return true;
}
@Override
public void show() {
super.show();
stage.addActor(obstacled);
obstacled.action
(Forever.$
(Sequence.$
(ScaleTo.$(1.4f, 1.4f, 2),(MoveTo.$(100,120, 3f) ))
));
jumper2d = Jumper2D.create(getAtlas());
stage.addActor(jumper2d);
stage.draw();
}
public void render () {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();
}
}
感谢任何帮助
答案 0 :(得分:8)
draw()
的{{1}}方法忽略了SpriteTest
上的任何缩放或旋转设置。你需要适当地绘制缩放/旋转/大小的精灵。 (您可能还需要设置Actor的x,y,width和height ---请参阅
setBounds
)
Actor