Sprite won't change with keyboard input

Hello,

I am trying to replace Sprite when entering a keyboard input. Here is example of the code:

Script.prototype.zmenaSmeru = function(rytir, vlevo, dole, vpravo)  {
    if (this.app.keyboard.isPressed(pc.KEY_A)){
        rytir.sprite.spriteAsset = vlevo;
    }
      
    if (this.app.keyboard.isPressed(pc.KEY_S)){
        rytir.sprite.spriteAsset = dole;
    }
    

    if (this.app.keyboard.isPressed(pc.KEY_D)){
        rytir.sprite.spriteAsset = vpravo;
    }
};

When I click the keyboard input, Sprite asset does not change at all. I am implementing in prototype.update method but it won’t change the sprite at all. I did debug and it is there but it won’t change it at all.

Dashboard of the project.

EDIT: Forgot to mention that I am using attributes to add for easier access of my other Sprites I want to use.
Example:

Script.attributes.add('zlutyVlevo', {type: 'asset', assetType: 'sprite'});
Script.attributes.add('zlutyDole',  {type: 'asset', assetType: 'sprite'});
Script.attributes.add('zlutyVpravo', {type: 'asset', assetType: 'sprite'});

Hi @fingerzz ,

You need to target the active clip to make your animated sprite change, try this (I’ve also changed your input target to wasReleased so the change happens only once):

    if (this.app.keyboard.wasReleased(pc.KEY_A)){
        rytir.sprite.currentClip.spriteAsset = vlevo;
    }
      
    if (this.app.keyboard.wasReleased(pc.KEY_S)){
        rytir.sprite.currentClip.spriteAsset = dole;
    }
    

    if (this.app.keyboard.wasReleased(pc.KEY_D)){
        rytir.sprite.currentClip.spriteAsset = vpravo;
    }