//给精灵创建帧动画 Animation* EnemyBase::createAnimation(std::string prefixName, int framesNum, float delay) { // 1 Vector<SpriteFrame*> animFrames; // 2 for (int i = 1; i <= framesNum; i++) { char buffer[20] = { 0 }; sprintf(buffer, "_%i.png", i); std::string str = prefixName + buffer; auto frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(str); animFrames.pushBack(frame); } // 3 return Animation::createWithSpriteFrames(animFrames, delay); }
每一个敌人精灵都带有一个帧动画