Change Sprite with a button

I have a sprite selection that is sectioned that activates a button and then I would like it to change the selected sprite to another sprite
Is it possible ?
I have a sprite selection that is sectioned that activates a button and then I would like it to change the selected sprite to another sprite
Is it possible ?

Here are some pictures

sp.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(…);

Can’t you just replace it?

Yes indeed that’s what I would like to do, but I can’t and this piece of code you put there, I went this way but I don’t quite understand

NewProject_26.zip (276.1 KB)
Like this?


since this block here

This project is made with 2.3.3.

I think, it’s straight forward?

  • get Sprite’ texture of the button being clicked
  • assign that texture to Profile Sprite

can you give me a sample code please