Hi there!
I must create many modified sprites from one texture utilizing a part of this texture.
To do that, I clone the spriteFrame:
let spr:SpriteFrame = new SpriteFrame();
spr = this.sprite.spriteFrame.clone();
The whole lot works, however the .clone() technique – “since v3.5.0, that is an engine non-public interface that might be eliminated sooner or later.”
So:
let spr:SpriteFrame = new SpriteFrame();
spr = instantiate(this.sprite.spriteFrame);
doesn’t work.
Are you able to please inform me if there’s one other means that won’t be canceled sooner or later?
Listed here are all particulars you need to want:
// this.spriteFrame is your sprite you need to clone
this.spriteComponent.sprite = this.spriteFrame;
// Create a brand new node
const newNode = new Node('New Node');
// Add a sprite element
newNode.addComponent(Sprite);
// Get the newly created sprite
const newSpriteComponent = newNode.getComponent(Sprite); element
// Right here you employ the identical spriteframe
newSpriteComponent.sprite = this.spriteFrame;
// Add the brand new node as a toddler to this.node
this.node.addChild(newNode);