bool FireAOE::init() { if (!AOEArea::init()) { return false; } auto fireS = Sprite::create(); auto boom = Animation::create(); for (int i = 0; i < 6; i++) { char szName[100]; sprintf(szName, "Fire_Attack_Boom_%02d.png", i); boom->addSpriteFrameWithFileName(szName); } boom->setDelayPerUnit(0.1); boom->setRestoreOriginalFrame(true); auto aniBoom = Animate::create(boom); fireS->runAction(aniBoom); fireS->setOpacity(150); this->addChild(fireS); this->scheduleOnce(schedule_selector(FireAOE::update), 0.2); return true; }
void Level01::animCache() { anim1 = Animation::create(); anim1->addSpriteFrameWithFileName("img/player02.png"); anim1->addSpriteFrameWithFileName("img/player03.png"); anim1->addSpriteFrameWithFileName("img/player04.png"); anim1->setLoops(1); anim1->setDelayPerUnit(0.2f); anim1->setRestoreOriginalFrame(true); auto standAnim = Animation::create(); standAnim->addSpriteFrameWithFileName("img/player01.png"); standAnim->addSpriteFrameWithFileName("img/player01-2.png"); standAnim->addSpriteFrameWithFileName("img/player01-3.png"); standAnim->setLoops(1); standAnim->setDelayPerUnit(0.7f); standAnim->setRestoreOriginalFrame(true); m_animCache = AnimationCache::getInstance(); m_animCache->addAnimation(anim1, "walking"); m_animCache->addAnimation(standAnim, "stand"); }
void GameScene27::tremble(float tmd){ auto animation1 = Animation::create(); for (int n=1;n<=2;n++) { char szName[100] = {0}; sprintf(szName,"new/compare%d.png",n); animation1->addSpriteFrameWithFileName(szName); } animation1->setDelayPerUnit(0.4f); animation1->setRestoreOriginalFrame(true); auto action1 = Animate::create(animation1); compare->runAction(action1) ; }
void Level01::setBG() { m_worldMap = Node::create(); if (UserDefault::getInstance()->getBoolForKey("light")) { m_collision = m_visibleSize.width*0.3; } else { m_collision = -m_visibleSize.width*0.7; } Sprite* bg[3]; for (int i = 0; i < 3; i++) { bg[i] = Sprite::create("img/background.png"); // position the sprite on the center of the screen bg[i]->setScale(m_visibleSize.width / m_visibleSize.height); bg[i]->setPosition(Point((m_visibleSize.width) * i+1, m_visibleSize.height / 2)); // add the sprite as a child to this layer m_worldMap->addChild(bg[i]); } createObjectOnFloor(bg[1]->getBoundingBox().getMidX()- 200, "img/chair.png"); createObjectOnFloor(bg[1]->getBoundingBox().getMidX(), "img/chair.png"); createObjectOnFloor(bg[1]->getBoundingBox().getMidX(), "img/table.png"); createObjectOnFloor(bg[0]->getBoundingBox().getMidX(), "img/chair.png"); auto drawing2 = Sprite::create("img/drawing01.png"); drawing2->setScale(2); drawing2->setPosition(Vec2(m_visibleSize.width * 1.3, m_visibleSize.height / 1.4)); //m_worldMap->addChild(drawing2); //m_doorList[2] = createDoor(m_visibleSize.width * 2.7); m_doorList[0] = createDoor(convertToNodeSpace(sprite->getPosition()).x); //m_doorList[1] = createDoor(m_visibleSize.width * 3.4); auto sadman = Sprite::create("img/sadman01.png"); sadman->setScale(1.8); sadman->setPosition(Vec2(m_visibleSize.width * 1.2 + 55, m_floorPoint + sadman->getBoundingBox().getMaxY())); m_worldMap->addChild(sadman); if (UserDefault::getInstance()->getBoolForKey("light")) { sadman->setVisible(true); } else { sadman->setVisible(false); } auto sadmanAnim = Animation::create(); sadmanAnim->addSpriteFrameWithFileName("img/sadman01.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman01.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman02.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman01.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman02.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman03.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman02.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman03.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman02.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman03.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman02.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman03.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman04.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman04.png"); sadmanAnim->addSpriteFrameWithFileName("img/sadman04.png"); sadmanAnim->setLoops(-1); sadmanAnim->setDelayPerUnit(0.3f); sadmanAnim->setRestoreOriginalFrame(true); auto sadmanAnimate = Animate::create(sadmanAnim); sadman->runAction(RepeatForever::create(sadmanAnimate)); m_doorList[1] = sadman; this->addChild(m_worldMap); }