cocos2d-x CCSprite 更换图片

// 首先载入贴图集
CCSpriteBatchNode *spriteBatch=CCSpriteBatchNode::batchNodeWithFile("snake.png");
this->addChild(spriteBatch);
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("snake.plist");
// 生成Sprite
CCSprite *headSprite=CCSprite::spriteWithSpriteFrameName("headup.png");
//需要更换图片时
CCSpriteFrame *frame=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("headleft.png");
headSprite->setDisplayFrame(frame);

 

转自:http://blog.csdn.net/weyson/article/details/7746492

posted @ 2014-11-12 17:13  猿走天下  阅读(652)  评论(0编辑  收藏  举报