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'});