初玩cocos2d-x在用缓存帧方式创建精灵时,出了问题,折腾了一早上,去掉所有的类,直接在一类中编写,
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("spfont.plist");
CCSpriteBatchNode* _batchNode=CCSpriteBatchNode::create("spfont.pvr.ccz");
this->addChild(_batchNode,6);
bear = CCSprite::createWithSpriteFrameName("s1.png");
bear->setPosition(ccp(100,200));
_batchNode->addChild(bear );
1、精灵缓存,2、渲染精灵根节点建立_batchNode,3、将这个节点加入到当前层,3、取出其中某帧建立精灵 bear,设置位置4、将精灵节点加入到根渲染节点。
可以显示了。查看自己原来写的代码,this->_batchNode,多了个this->_,在层次先后出现问题。还得好好学习,努力努力。