开发者

Change graphic but keep properties

Is there a way to change a graphic, but keep the properties across frames such as size and positioning, so that the new graphic does everything the same? That's pretty much开发者_JS百科 all I can ask since I don't really know where to start.


You have quite a few options, here are two:

1) transfer across all the properties you need to your new sprite/graphic eg.

myNewSprite.x = myOldSprite.x;
myNewSprite.width = myOldSprite.width;
myNewSprite.height = myOldSprite.height;
myNewSprite.rotation = myOldSprite.rotation;
this.removeChild(myOldSprite);
this.addChild(myNewSprite);

2) keep your graphics within a containing sprite add instead of altering the graphics directly alter the containers properties.

myContainerSprite.rotation = 180;
myContainerSprite.x = 200;
myContainerSprite.removeChild(redTriangle);
myContainerSprite.addChild(blueTriangle);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜