android - LIBGDX 动画不播放或循环播放
问题描述
我有一个似乎是正确的硬币动画,但它不播放或循环,只出现第一张图像。我还有一个名为 Moedas(coins) 的类,我想使用它们的位置来设置动画 x 和 y,但如果我这样做,它甚至不会出现在屏幕上。这可能是什么原因造成的?
public Janela2 (MyGdxGame mgg){
super(mgg);
TextureAtlas at = new TextureAtlas("Arquivos.txt");
coin1 = new Moedas(texture);
coin2 = new Moedas(texture);
TextureAtlas atlas = new TextureAtlas("Arquivos.txt");
TextureRegion tr1 = new TextureRegion(atlas.findRegion("m321"));
TextureRegion tr2 = new TextureRegion((atlas.findRegion("m322")));
TextureRegion tr3 = new TextureRegion(atlas.findRegion("m323"));
TextureRegion tr4 = new TextureRegion((atlas.findRegion("m324")));
TextureRegion array[] = {tr1, tr2, tr3, tr4};
time = 0f;
ani = new Animation<TextureRegion>(0.5f,array);
ani.setPlayMode(Animation.PlayMode.LOOP);
}
public void render(float delta) {
sp.begin();
sp.draw(img, 0,0);
sp.draw(player2, player2.getX(), player2.getY());
Movimento.movement2(player2, boundingRecPlayer);
if (Player.saimoeda(boundingRecCoin, boundingRecPlayer)) {
//collision method for testing if the player has touched the coin
sp.draw(img, 0, 0);
Movimento.movement(player, boundingrecp);
sp.draw(player2, player2.getX(), player2.getY())
} else {
time = Gdx.graphics.getDeltaTime();
TextureRegion t = ani.getKeyFrame(time, true);
sp.draw(t, 50, 50);//static x and y because Moedas.x and Moedas.y doesnt work
}
sp.end();
}
@Override
public void dispose() {
super.dispose();
}
}
解决方案
推荐阅读
- python - Python:在类中将函数作为参数传递
- cplex - 使用 Pyomo 时不能使用 Cplex 作为求解器
- python - 针对概率标准化的二维直方图
- jmeter - Taurus 从 Internet 下载 Jmeter,而不是参考本地安装
- android - 运行改造 api 单元测试时出现 IllegalArgumentException
- java - 避免第三个活动回到第一个活动
- ios - UILable上面的UITableVIew,UILable不能触摸,为什么?
- c# - BotFramework PrivateConversationData 集问题
- perl - Perl:需要一个实际有效的 LWP 和 HTTP::Request POST 代码
- highcharts - 如何获取世界各国主要城市的geojson