void LevelManager::repeatAction(Node *pSender) { DelayTime *delay = DelayTime::create(1); MoveBy *mv = MoveBy::create(1, Vec2(100 + 100 * CCRANDOM_0_1(), 0)); FiniteTimeAction *seq = Sequence::create(delay, mv, delay->clone(), mv->reverse(), NULL); pSender->runAction(RepeatForever::create((ActionInterval*)seq)); }
MoveBy* MoveBy::create(float duration, const Point& deltaPosition) { MoveBy *pRet = new MoveBy(); pRet->initWithDuration(duration, deltaPosition); pRet->autorelease(); return pRet; }
void HelloWorld::createSpaceCastle(std::string fileName) { // add sprite with space castle Sprite* castle = Sprite::create(fileName); // position the spaceCastle castle->setPosition(Point(visibleSize.width + origin.x - castle->getContentSize().width/2, visibleSize.height/2 + origin.y)); // Add floating effect to spaceCastle MoveBy* floating = MoveBy::create(2.0f,Point(0,visibleSize.height/15)); castle->runAction(RepeatForever::create(Sequence::create(floating, floating->reverse(),nullptr))); // add the castle as a child of this layer this->addChild(castle, 0); }
gdx::Action* MoveBy::copy () { MoveBy* moveBy = MoveBy::build(initialX, initialY, duration); if (interpolator != NULL) moveBy->setInterpolator(interpolator->copy()); return moveBy; }