So, I'm familiarizing with the object model and I hit this problem.
I have a sprite, it contains an image and 2 animations to move left and right.
this is the code of onUpdate
if (wade.isKeyDown ('left')) {
if (this.getSprite().getCurrentAnimationName()!='Walk_left') this.playAnimation('Walk_left');
this.moveTo(this.getPosition().x-2,this.getPosition().y);
} else if (wade.isKeyDown('right')) {
if (this.getSprite().getCurrentAnimationName()!='Walk_right') this.playAnimation('Walk_right');
this.moveTo(this.getPosition().x-2,this.getPosition().y);
} else {
// ????? Display the original image of the sprite
//this.getSpriteByName('Still')
}
I assume that this is the SceneObject so it appears that I can play a sprite animation directly from this and not this.getSprite(). But SceneObjects can have multiple sprites, which may contain animations (maybe with the same names, I will try).
But the real problem is: how do I show the original sprite, the one that appers when the game is loaded, when no keys are currently pressed?
The whole thing is here, if you want to take a look
https://github.com/iospetrosky/wade_1st_test/tree/wade_forum_01
Cheers
L.