Tank* Tank::createTankWithTankType(const char* tankTypeName, TileMapInfo* tileMapInfo) { CCSpriteFrameCache* pCache = CCSpriteFrameCache::sharedSpriteFrameCache(); pCache->addSpriteFramesWithFile("tank.plist"); initActionSet(); Tank* tank = new Tank(); tank->initTankWithTankType(tankTypeName, tileMapInfo); tank->autorelease(); return tank; }
bool Runner::init(){ //加载图片到缓存池 auto frameCache = SpriteFrameCache::getInstance(); frameCache->addSpriteFramesWithFile("parkour.plist","parkour.png"); m_runner = Sprite::createWithSpriteFrameName("runner0.png"); run_jumpSize = m_runner->getContentSize(); crouchSize = Sprite::createWithSpriteFrameName("runnerCrouch0.png")->getContentSize(); this->addChild(m_runner); initActionSet(frameCache);//初始化动作集合 //m_state = running; initBody(); this->scheduleUpdate(); //设置主角为1,为碰撞做准备 this->setTag(1); return true; }