so i have this node and i want to change its image how do i do that?
i used this inside onLoad so that if the picture was changed it would load the new one
var image2 = cc.url.raw("Texture/balloon0.png");
this.balloon.getComponent(cc.Sprite).spriteFrame.setTexture(image2);
on first picture thats the balloon with its new picture
so on the right one it kinda shrinks but the outline of the rigid body stays the same because the balloon reacts as if its the same size as in the first picture
i think this is a very bad explanation but honestly i dont know how to explain so if you ask questions to understand better ill try to answer as best as i can
I change sprites at runtime by creating a cc.SpriteFrame property, and assigning it to the cc.Sprite component in my TypeScript code:
// the property. assign a value in the Cocos Creator!
@property(cc.SpriteFrame)
mySprite: cc.SpriteFrame = null;
changeSprite() {
// change sprite frame to the one specified by the property
this.getComponent(cc.Sprite).spriteFrame = mySprite;
}