void Player::move(Vec2 direction, int tag) { MoveBy* moveAction = MoveBy::create(1.0f, direction); RepeatForever* repAction = RepeatForever::create(moveAction); repAction->setTag(tag); this->runAction(repAction); }
RepeatForever *RepeatForever::create(ActionInterval *action) { RepeatForever *ret = new(std::nothrow) RepeatForever(); if (ret && ret->initWithAction(action)) { return ret; } SAFE_RELEASE(ret); return nullptr; }
void AirShip::playCatchAnimation() { Animation * animation = AnimationUtil::getAnimationByName(Value(catchingAnimationName)); animation->setDelayPerUnit(0.2f); animation->setRestoreOriginalFrame(true); Animate * action = Animate::create(animation); RepeatForever * repeat = RepeatForever::create(action); repeat->setTag(kAirShipCatching); this->runAction(repeat); }
RepeatForever *RepeatForever::create(ActionInterval *pAction) { RepeatForever *pRet = new RepeatForever(); if (pRet && pRet->initWithAction(pAction)) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }
void GameLayer::startTintGameTileView(GameTileView* gameTileView) { TintTo* tintToWhite = TintTo::create(0.3, TINT_MAX.r, TINT_MAX.g, TINT_MAX.b); TintTo* tintToBlack = TintTo::create(0.3, TINT_MIN.r, TINT_MIN.g, TINT_MIN.b); Sequence* sequence = Sequence::create(tintToWhite, tintToBlack, NULL); RepeatForever* repeatForEver = RepeatForever::create(sequence); repeatForEver->setTag(TAG_TINT); gameTileView->getSprite()->setColor(TINT_MIN); // gameTileView->getForegroundLayer()->setVisible(true); // gameTileView->getForegroundLayer()->runAction(repeatForEver); gameTileView->getSprite()->runAction(repeatForEver); // gameTileView->getEffectSprite()->setVisible(true); }
void AirShip::startMove() { //椭圆旋转 // EllipseConfig config; // config.ellipseA = 5; // config.ellipseB = 15; // config.cenPos = Vec2(startX, startY); // config.isAntiClockwise = true; // config.startAngle = 0; // config.selfAngle = 45; // this->runAction(RepeatForever::create(EllipseBy::create(2.5f,config))); stopCatchAnimation(); MoveTo *moveTo = MoveTo::create(2.0f, Vec2(startX, startY + 30)); MoveTo *moveBack = MoveTo::create(2.0f, Vec2(startX, startY)); Sequence *seq = Sequence::create(moveTo,moveBack,NULL); RepeatForever * moveAction = RepeatForever::create(seq); moveAction->setTag(kAirShipMove); this->runAction(moveAction); }
void TankStateRebirth::init() { //CCLOG("Opacity: %hhu", _tank->getOpacity()); _tagBackup = _tank->getTag(); _tank->setOpacity(0x00); _tank->stopAllActions(); float dtime = 3.0f; //CCLOG("afterSetOpacity: %hhu", _tank->getOpacity()); if (_tank->getTag() == NodeWithCollision::COLL_FELLOWS) { Vec2 homexy = MAPDATA->getHomePos(); _tank->setPosition(homexy); _tank->setRefX(homexy.x); _tank->setRefY(homexy.y); _tank->setDirection(TUP); TankSprite *tankSprite = dynamic_cast<TankSprite *>(_tank); tankSprite->setBulletAwardNum(0); } else if(_tank->getTag() == NodeWithCollision::COLL_ENEMIES) { dtime = 1.5f; } FadeTo *fadeLight = FadeTo::create(0.5, 50); FadeTo *fadeDense = FadeTo::create(0.5, 100); //_tank->runAction(fadeIn); //vector<FiniteTimeAction*> repeatActions{fadeDense, fadeLight}; RepeatForever *fadeForever = RepeatForever::create(Sequence::createWithTwoActions(fadeDense, fadeLight)); fadeForever->setTag(TankNode::ACTION_FADE); _tank->runAction(fadeForever); _myTimer = FinishRebirthTimer::create(); _myTimer->initTimer(this, dtime); _tank->addChild(_myTimer); _tank->setTag(NodeWithCollision::COLL_REBIRTH); }