Posted By

saturngod on 11/12/10


Tagged

cocos2d


Versions (?)

Change Sprite Texture in Cocos2d


 / Published in: Objective C
 

URL: http://stackoverflow.com/questions/2720289/problem-with-migrating-from-texture2d-to-cctexture2d-setting-ccsprite-texture

  1. mySprite = [CCSprite spriteWithFile:@"mySprite.png"]];
  2.  
  3. ...
  4.  
  5. // change current stage here
  6.  
  7. CCTexture2D *newTexture=[[[CCTexture2D alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"stage number %d.png",currentStageNumber]]]autorelease];
  8.  
  9. [mySprite setTexture:newTexture];
  10.  
  11. [mySprite setTextureRect:CGRectMake(0,0, newTexture.contentSize.width, newTexture.contentSize.height)];

Report this snippet  

You need to login to post a comment.