Question about Sprites because google hates me [ i figured it out on my own lol]

How do i make a sprite change when i press a button, say i press W and it switches to a jump sprite. im trying to make a game and i could use some help plz

Hi @vilothaine_2,

Check this manual page on how to create sprites using the sprite editor:

Then you can add a script to listen for keyboard input, here is a simple tutorial on that:

Last when you have everything in place, to change the active sprite frame on a sprite component, you use some code:

// Specifies which frame from the current sprite asset to render.
this.entity.sprite.frame = 1;


alright, so i tryed this but it appears nothing happens
SidescrollMovement.prototype.update = function(dt) {
if (; {
this.entity.sprite.frame = 2;
its supposed to call upon the code every second, but the sprite doesent change.

Does the sprite asset have more than 1 frame? Can you post a link to your project if you are still stuck please?

The other way to do this is to have multiple sprite assets, one for the walk and another for the jump and swap the assets on the entity’s sprite component when the user jumps.

how do i switch sprites, i thought that did it but it hasnt.not frames.

Can you post a link to your project please? It helps to see how it’s been currently setup.