为什么创建一个移动中的精灵那么难?
参照论坛地球人系列,无脑码农系列,全部没有一个例子是成功的。不是缺少某个函数,就是直接内存错误。
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile(“images.plist”, “images.png”);
// 1. Add a menu item with “X” image, which is clicked to quit the program.
CCArray *animFrames = new CCArray(4);
CCSpriteFrame *frame1 = cache->spriteFrameByName(“girl1.png”);
CCSpriteFrame *frame2 = cache->spriteFrameByName(“girl2.png”);
CCSpriteFrame *frame3 = cache->spriteFrameByName(“girl3.png”);
CCSpriteFrame *frame4 = cache->spriteFrameByName(“girl4.png”);
animFrames->addObject(frame1);
animFrames->addObject(frame2);
animFrames->addObject(frame3);
animFrames->addObject(frame4);
CCAnimation *animation = CCAnimation::createWithSpriteFrames(animFrames, 0.5f);
CCSprite* girlSprite = CCSprite::createWithSpriteFrame(frame1);
CC_BREAK_IF(!girlSprite);
girlSprite->setPosition(ccp(300,300));
CCAnimate* animate=CCAnimate::actionWithAnimation(animation);
CC_BREAK_IF(!animate);
girlSprite->runAction(CCRepeatForever::create(animate));
请高手指点指点。