So, for whatever reason my animation isn’t updating, i’ve tried googling it and they all keep saying the same thing which i’ve done over and over again. I don’t know if it’s something small that i keep missing.
private void createAnimations() {
TextureRegion[] runFrames = new TextureRegion[4];
TextureRegion[] idleFrames = new TextureRegion[4];
TextureAtlas knight = assetManager.get("entities/knight.atlas", TextureAtlas.class);
TextureAtlas knightIdle = assetManager.get("entities/knight_idle.atlas", TextureAtlas.class);
runFrames[0] = (knight.findRegion("knight_m_run_anim_f0"));
runFrames[1] = (knight.findRegion("knight_m_run_anim_f1"));
runFrames[2] = (knight.findRegion("knight_m_run_anim_f2"));
runFrames[3] = (knight.findRegion("knight_m_run_anim_f3"));
idleFrames[0] = (knight.findRegion("knight_m_idle_anim_f0"));
idleFrames[1] = (knight.findRegion("knight_m_idle_anim_f1"));
idleFrames[2] = (knight.findRegion("knight_m_idle_anim_f2"));
idleFrames[3] = (knight.findRegion("knight_m_idle_anim_f3"));
runAnimation = new Animation<TextureRegion>(5f, runFrames);
idleAnimation = new Animation<TextureRegion>(0.1f, knightIdle.findRegions("knight_idle"), PlayMode.LOOP);
}
I tried two different ways to see if it would change anything. The knight idle atlas has the proper indexing, to make it easier to animate, while the knight atlas just contains all of the frames.
public void render(SpriteBatch batch, float delta) {
createAnimations();
float elapsedTime = 0;
batch.begin();
elapsedTime += delta;
currentFrame = runAnimation.getKeyFrame(elapsedTime);
player.applyLinearImpulse((playerSpeedX - player.getLinearVelocity().x) * player.getMass(),
(playerSpeedY - player.getLinearVelocity().y) * player.getMass(), player.getWorldCenter().x,
player.getWorldCenter().y, true);
this.position = player.getPosition();
batch.draw(currentFrame, position.x - 10 * 0.5f * UNIT_SCALE,
position.y - 10 * 0.5f * UNIT_SCALE, .6f, 1);
Gdx.app.log("PLAYER", "Animation: " + idleAnimation.getKeyFrame(elapsedTime));
batch.end();
}
There are no errors being thrown at all, all it shows is the first frame of the animation and doesn’t change. createAnimations wasn’t originally called in the render method i just moved it to see if it would change anything