Depending on your marte engine version you will find a setAnim in entity
. If this method does not exist you can use currentAnim.
If you use the latest version from the dev branch you can load an animation from resources.xml
This works like this:
Like any other resource you add a line in the resources.xml file:
anim name imgName frameDuration row frames(default=all horizontal frames)
<anim key="homer" imgName="homer" frameDuration="250" row="0" frames="1,2,3,4,5"
name: name of your animation, this is the key to retrieve it later on
imgName: The spritesheet key where the animation should be read from(the spritesheet should already be loaded)
frameDuration: The duration of all frames
row: what row in the sheet contains your images
frames: what images should be in the animation on that row
Animation animWalkLeft = ResourceManager.getAnimation("homer")
// and finally when you need the entity to walk left