错误在于
CCAnimation *_runAnim = CCAnimation::createWithSpriteFrames(zoewalkingFrames, 0.1);
这条线,当我试图将 CCArray zoewalkingFrames 传递给 CCAnimation _runAnim 时,日志显示“对类型 'const Vector 的引用无法绑定到类型为 'CCArray' aka '”的左值,所以我应该怎么做才能做到将 CCArray var 传递给 SpriteFrame?谢谢
#include "ZoeAnime.h"
using namespace cocos2d;
bool ZoeAnime::init()
{
if ( !Node::init() )
{
return false;
}
auto spritecache = SpriteFrameCache::getInstance();
spritecache->addSpriteFramesWithFile("zoeanime.plist");
CCSpriteBatchNode *_spritesheet = CCSpriteBatchNode::create("zoeanime.png");
this->addChild(_spritesheet);
CCArray* zoewalkingFrames = CCArray::create();
for(int i = 1; i <= 3; i++) {
CCString* filename = CCString::createWithFormat("zoewalking%0d.png", i);
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(filename->getCString());
zoewalkingFrames->addObject(frame);
}
CCAnimation *_runAnim = CCAnimation::createWithSpriteFrames(zoewalkingFrames, 0.1);
CCSprite* zoe = CCSprite::createWithSpriteFrameName("zoewalking01.png");
CCSize winsize = CCDirector::sharedDirector()->getWinSize();
zoe->setPosition(ccp(winsize.width*0.5, winsize.height*0.5));
CCAction* action = CCRepeatForever::create(CCAnimate::create(_runAnim));
zoe->runAction(action);
_spritesheet->addChild(zoe);
return true;
}