Home > other >  Cocos creator Sprite changes when keyboard events
Cocos creator Sprite changes when keyboard events

Time:09-30

Cocos creator how change when elves moving pictures, that is to say is a picture when it is still in its movement is another picture, I tried in the update and lateupdate response keyboard events have tried using loadRes (), but don't know whether I didn't do well this always run out, but not an error, is can't use the method of dynamic change? My resources is on the right of the resources to go online for a long time did not find similar demo, as a beginner, I have withered, have a great god help me, I am here into several days

CodePudding user response:

Will dynamically loaded picture into the cc. The SpriteFrame change out when assigned to a node you want to change the SpriteFrame can

CodePudding user response:

Cc. Loader. LoadRes (" resource path ", cc. SpriteFrame (err, sp)=& gt; {
If (err) return;
If (this. Node) {
Let the Sprite=this. Node. GetComponent (cc. Sprite);
If (Sprite) {
Sprite. SpriteFrame=sp;
}
}
})
  • Related