CCSpriteBatchNode读取plist

来源:互联网 发布:java工作日报 编辑:程序博客网 时间:2024/06/05 21:01

//首先将plist读到缓存中

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("popstar.plist", "popstar.png");

//将资源添加到CCSpriteBatchNode里。

CCSpriteBatchNode *aParent = CCSpriteBatchNode::create("popstar.png"); 
addChild(aParent); 

//创建精灵并添加到CCSpriteBatchNode里,1000.png是popstar.plist的一个资源

CCSprite *pFather = CCSprite::createWithSpriteFrameName("1000.png"); 
pFather->setPosition(ccp(200,200)); 
aParent->addChild(pFather); 


如此一来,不管需要显示多少个精灵,相同的精灵只会添加一个。

0 0
原创粉丝点击