Sprite

I have a sprite of a cat that runs when i push the arrows.
how can i make it sit when i don't push the arrows.
catgame
I also have a sprite of sitting cats.
don't now where to start.

On the InteractiveAnimation page at https://zimjs.com/ia there is a recent simpler example of a space guy shooting. We walk with one "animation" and we shoot with another "animation". ZIM - Interactive Animation Example - JavaScript Canvas Framework This is one way to do it where it is all in the same spritesheet. This example uses a MotionController with "mousemove" but a MotionController with DPad should work the same way.

You could also use two spritesheets and hide the walking sprite with vis(false) when it is not moving - the MotionController dispatches a stopmoving and startmoving events. So

// if you have two Sprites
// and mc is your MotionController for the walkingSprite
mc.on("stopmoving", ()=>{
   walkingSprite.vis(true);
   sittingSprite.vis(false);
});

mc.on("startmoving", ()=>{
   walkingSprite.vis(false);
   sittingSprite.loc(walkingSprite).vis(true);
});

I have recently strictly been using the dynamo. You can create a dynamo per animation label.

const walkingAnim = new Dynamo(sprite, 30, "walk");
spriteDynamo = walkingAnim
const runningAnim = new Dynamo(sprite, 30, "run").pause(true);

Ticker.add(()=>{
    spriteDynamo.percentSpeed = 100;
});

function changeAnim() {
spriteDynamo = runningAnim;
}
1 Like