Hi,

Suppose you want to copy a sprite image to another new sprite while using cocos2D. What you do?
See the following code…

Let oldSprite be your first sprite

CCSprite *oldSprite = [CCSprite spriteWithFile:@"ImgOne.png"];

And newSprite be your second sprite

CCSprite *newSprite  = [CCSprite spriteWithTexture:[oldSprite texture]];

That’s it! Done! Now newSprite too contain ImgOne as Sprite.

🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.