diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index 444d699..908f2cf 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -130,7 +130,7 @@ public class GladiatorBrawler extends ApplicationAdapter { Sprite player2 = SpriteLoader.loadSprite(Name.PLAYERIMG, 1, 0, 64, 64); SpriteSequence sequence = new SpriteSequence(1).addSprite(player1).addSprite(player2); renderedObject.addSequence("Idle", sequence); - renderedObject.setCurrentSequence("Idle"); + renderedObject.playAnimation("Idle"); player.add(renderedObject); player.add(new CPhysics()); player.getComponent(CPhysics.class).body = body; diff --git a/core/src/com/saltosion/gladiator/components/CRenderedObject.java b/core/src/com/saltosion/gladiator/components/CRenderedObject.java index d9c9d08..def9b08 100644 --- a/core/src/com/saltosion/gladiator/components/CRenderedObject.java +++ b/core/src/com/saltosion/gladiator/components/CRenderedObject.java @@ -38,6 +38,21 @@ public class CRenderedObject extends Component { return spritesequences.get(key); } + public void playAnimation(String key) { + playAnimation(key, 0); + } + + public void playAnimation(String key, int startingframe) { + if (spritesequences.containsKey(key)) { + currentSequence = key; + currentframe = startingframe; + return; + } + String[] s = (String[]) spritesequences.keySet().toArray(); + currentSequence = s[0]; + currentframe = 0; + } + public float getCurrentFrame() { return currentframe; }