void TransitionSplitCols::onEnter()
{
    TransitionScene::onEnter();

    _gridProxy->setTarget(_outScene);
    _gridProxy->onEnter();

    ActionInterval* split = action();
    ActionInterval* seq = (ActionInterval*)Sequence::create
    (
        split,
        CallFunc::create(CC_CALLBACK_0(TransitionSplitCols::switchTargetToInscene,this)),
        split->reverse(),
        nullptr
    );

    _gridProxy->runAction
    (
        Sequence::create
        (
            easeActionWithAction(seq),
            CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
            StopGrid::create(),
            nullptr
        )
    );
}
void Tutorial::startAnimateGuideRight(eTutorialState state)
{
    if (nullptr != _guideRight)
//    if (nullptr != _guideRight && false == _rightPressed)
    {
        this->stopAnimationGuideRight();
        ActionInterval * action = nullptr;
        switch (state)
        {
            case eTutorialState::TUTORIAL_CONTROLLER_RIGHT:
            case eTutorialState::TUTORIAL_CONTROLLER_JUMP_RIGHT:
                action = _animLongPress->clone();
                break;
            case eTutorialState::TUTORIAL_CONTROLLER_JUMP_LEFT:
            case eTutorialState::TUTORIAL_CONTROLLER_JUMP_VERTICAL:
                action = _animTap->clone();
                break;
            case eTutorialState::TUTORIAL_CONTROLLER_LEFT:
            case eTutorialState::TUTORIAL_NONE:
            default:
                break;
        }
        if (action)
        {
            action->setTag(static_cast<int>(eAction::ANIMATION));
            _guideRight->runAction(action);
        }
    }
}
void ParticleComponentTest::defaultPlay()
{
	ComRender* Particle = static_cast<ComRender*>(_rootNode->getChildByTag(10020)->getComponent("CCParticleSystemQuad"));
	ActionInterval*  jump = CCJumpBy::create(5, Point(-500,0), 50, 4);
	FiniteTimeAction*  action = CCSequence::create( jump, jump->reverse(), nullptr);
	Particle->getNode()->runAction(action);
}
bool RenderTextureClippingNode::init()
{
    setContentSize(RenderContentSize);
    
    m_pTopSprite = Sprite::create("res/ui/water_bottle/bottle.png");
    m_pTopSprite->retain();
    
    m_pWater = Sprite::create("res/ui/water_bottle/water.png");
    m_pWater->retain();
    
    m_pMaskSprite = Sprite::create("res/ui/water_bottle/water_mask.png");
    m_pMaskSprite->retain();
    
    m_pTopSprite->setPosition(RenderContentSize*0.5f);
    m_pWater->setPosition(RenderContentSize*0.5f);
    m_pMaskSprite->setPosition(RenderContentSize*0.5f);
    
    Size s = Director::getInstance()->getWinSize();
    m_pTarget = RenderTexture::create(RenderContentSize.width, RenderContentSize.height);
    this->addChild(m_pTarget);
    
    BlendFunc maskBlend = {GL_ONE, GL_ZERO};
    BlendFunc waterBlend = {GL_DST_ALPHA, GL_ZERO};
    m_pMaskSprite->setBlendFunc(maskBlend);
    m_pWater->setBlendFunc(waterBlend);
    
    ActionInterval* pMoveAction = MoveBy::create(0.4f, Vec2(8.0f,0.0f));
    ActionInterval* pRepeatAction = Sequence::create(pMoveAction, pMoveAction->reverse(), NULL);
    m_pWater->runAction(RepeatForever::create(pRepeatAction));
    
    return true;
}
Beispiel #5
0
bool Parallel::initWithActions(ActionInterval * action, ...)
{
    va_list actions;
    va_start(actions, action);
    
    ActionInterval * action1 = action;
    
    while (action1 != NULL)
    {
        ActionInterval * action2 = va_arg(actions, ActionInterval *);
        if (action2 != NULL)
        {
            Parallel * tmp = new Parallel();
            tmp->autorelease();
            tmp->_initWithTwoActions(action1, action2);
            action1 = tmp;
        }
        else
        {
            ActionInterval * tmp = new ActionInterval();
            tmp->autorelease();
            _initWithTwoActions(action1, tmp);
            break;
        }
    }
    
    va_end(actions);
    
    return false;
}
void TransitionRotoZoom:: onEnter()
{
    TransitionScene::onEnter();

    _inScene->setScale(0.001f);
    _outScene->setScale(1.0f);

    _inScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    _outScene->setAnchorPoint(Vec2::ANCHOR_MIDDLE);

    ActionInterval *rotozoom = (ActionInterval*)(Sequence::create
    (
        Spawn::create
        (
            ScaleBy::create(_duration/2, 0.001f),
            RotateBy::create(_duration/2, 360 * 2),
            nullptr
        ),
        DelayTime::create(_duration/2),
        nullptr
    ));

    _outScene->runAction(rotozoom);
    _inScene->runAction
    (
        Sequence::create
        (
            rotozoom->reverse(),
            CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
            nullptr
        )
    );
}
Beispiel #7
0
ActionReverseSequence2::ActionReverseSequence2()
: ActionBase("ReverseSeq 2", NULL)
{
	// Test:
	//   Sequence should work both with IntervalAction and InstantActions
    ActionInterval *move1 = new MoveBy(1, fzPoint(250, 0));
    ActionInterval *move2 = new MoveBy(1, fzPoint(0, 50));
    ActionInstant *tog1 = new ToggleVisibility();
    ActionInstant *tog2 = new ToggleVisibility();
    ActionInterval *seq = new Sequence(move1,
                                       tog1,
                                       move2,
                                       tog2,
                                       move1->reverse(), NULL);
    
    ActionInterval *action = new Repeat(new Sequence(seq, seq->reverse(), NULL), 3);

    
	// Test:
	//   Also test that the reverse of Hide is Show, and vice-versa
    kathia->runAction(action);
    
    ActionInterval *move_tamara = new MoveBy(1, fzPoint(100, 0));
    ActionInterval *move_tamara2 = new MoveBy(1, fzPoint(50, 0));
    ActionInstant *hide = new Hide();
    ActionInterval *seq_tamara = new Sequence(move_tamara,
                                              hide,
                                              move_tamara2, NULL);
    
    ActionInterval *action_tamara = new Sequence(seq_tamara, seq_tamara->reverse(), NULL);
    tamara->runAction(action_tamara);
}
Beispiel #8
0
ActionOrbit::ActionOrbit()
: ActionBase("ActionOrbit", NULL)
{
    ActionInterval * orbit1 = new OrbitCamera(2, 1, 0, 0, 180, 0, 0);
	ActionInterval * action1 = new Sequence(orbit1, orbit1->reverse(), NULL);
    
    ActionInterval * orbit2 = new OrbitCamera(2, 1, 0, 0, 180, -45, 0);
	ActionInterval * action2 = new Sequence(orbit2, orbit2->reverse(), NULL);

	ActionInterval * orbit3 = new OrbitCamera(2, 1, 0, 0, 180, 90, 0);
	ActionInterval * action3 = new Sequence(orbit3, orbit3->reverse(), NULL);


    kathia->runAction(new RepeatForever(action1));
    tamara->runAction(new RepeatForever(action2));
    grossini->runAction(new RepeatForever(action3));
    
    
	ActionInterval * move = new MoveBy(3, fzPoint(100, -100));;
	ActionInterval * move_back = move->reverse();
	ActionInterval * seq = new Sequence(move, move_back, NULL);
	Action * rfe = new RepeatForever(seq);
    
    kathia->runAction(rfe);
    tamara->runAction(rfe->copy());
    grossini->runAction(rfe->copy());
}
Beispiel #9
0
void NewSpriteBatchTest::addNewSpriteWithCoords(Vec2 p)
{
    auto BatchNode = static_cast<SpriteBatchNode*>( getChildByTag(kTagSpriteBatchNode) );

    int idx = (int) (CCRANDOM_0_1() * 1400 / 100);
    int x = (idx%5) * 85;
    int y = (idx/5) * 121;


    auto sprite = Sprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121));
    BatchNode->addChild(sprite);

    sprite->setPosition( Vec2( p.x, p.y) );

    ActionInterval* action;
    float random = CCRANDOM_0_1();

    if( random < 0.20 )
        action = ScaleBy::create(3, 2);
    else if(random < 0.40)
        action = RotateBy::create(3, 360);
    else if( random < 0.60)
        action = Blink::create(1, 3);
    else if( random < 0.8 )
        action = TintBy::create(2, 0, -255, -255);
    else
        action = FadeOut::create(2);

    auto action_back = action->reverse();
    auto seq = Sequence::create(action, action_back, nullptr);

    sprite->runAction( RepeatForever::create(seq));
}
Beispiel #10
0
void UIBuildingBase::setSharkAction()
{
    ActionInterval * ac = TintBy::create(1,-100,-100,-100);
    ActionInterval * acback = ac->reverse();
    ActionInterval * final = RepeatForever::create(Sequence::create(ac,acback,NULL));
    setSharkAction(final);
}
Beispiel #11
0
ActionReverse::ActionReverse()
: ActionBase("Reverse", NULL)
{
    ActionInterval *jump = new JumpBy(2, fzPoint(300, 0), 50, 4);
    ActionInterval *action = new Sequence(jump, jump->reverse(), NULL);
    
    grossini->runAction(action);
}
Beispiel #12
0
void Parallel::update(float t)
{
    for (int i = 0; i < 2; i++)
    {
        ActionInterval * action = _actions[i];
        if (action != NULL && !action->isFinished())
        {
            action->update(t);
        }
    }
}
Beispiel #13
0
ActionScale::ActionScale()
: ActionBase("Scale", NULL)
{
    ActionInterval *actionTo = new ScaleTo(2, 0.5f);
    ActionInterval *actionBy = new ScaleBy(2, 1, 10);
    ActionInterval *actionBy2 = new ScaleBy(2, 5, 1);
    
    tamara->runAction(new Sequence(actionBy, actionBy->reverse(), NULL));
    grossini->runAction(actionTo);
    kathia->runAction(new Sequence(actionBy2, actionBy2->reverse(), NULL));
}
Beispiel #14
0
ActionMove::ActionMove()
: ActionBase("Move", NULL)
{
	ActionInterval* actionTo = new MoveTo(2, fzPoint(getContentSize()-fzPoint(40, 40)));
	ActionInterval* actionBy = new MoveBy(2, fzPoint(80,80));
	ActionInterval* actionByBack = actionBy->reverse();
    
    tamara->runAction(actionTo);
    grossini->runAction(new Sequence(actionBy, actionByBack, NULL));
    kathia->runAction(new MoveTo(1, fzPoint(40, 40)));
}
Beispiel #15
0
ActionRotateJerk::ActionRotateJerk()
: ActionBase("RotateJerk", NULL)
{
    ActionInterval *seq = new Sequence(new RotateTo(0.5f, -20),
                                       new RotateTo(0.5f, 20), NULL);
    
    ActionInterval *rep1 = new Repeat(seq, 10);
    Action *rep2 = new RepeatForever(seq->copy());

    tamara->runAction(rep1);
    kathia->runAction(rep2);
}
Beispiel #16
0
ActionJump::ActionJump()
: ActionBase("Jump", NULL)
{
    ActionInterval *actionTo = new JumpTo(2, fzPoint(300, 300), 50, 4);
    ActionInterval *actionBy = new JumpBy(2, fzPoint(300, 0), 50, 4);
    ActionInterval *actionUp = new JumpBy(2, fzPoint(0, 0), 80, 4);
    ActionInterval *actionByBack = actionBy->reverse();

    
    tamara->runAction(actionTo);
    grossini->runAction(new Sequence(actionBy, actionByBack, NULL));
    kathia->runAction(new RepeatForever(actionUp));
}
Beispiel #17
0
void TestFrameEvent::onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex)
{
    CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt.c_str(), currentFrameIndex);

    if (!_gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG) || _gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone())
    {
        _gridNode->stopAllActions();

        ActionInterval *action =  ShatteredTiles3D::create(0.2f, Size(16,12), 5, false);
        action->setTag(FRAME_EVENT_ACTION_TAG);
        _gridNode->runAction(action);
    }
}
Beispiel #18
0
 void PixelMapPartial::PlaySmallAnimation(cocos2d::Sprite* s)
 {
   bool scaleDirection = rand()%2;
   auto s1 = ScaleTo::create(2, kSpriteScale*0.8);
   auto s2 = ScaleTo::create(2, kSpriteScale*1.1);
   ActionInterval* loop = nullptr;
   if (scaleDirection)
     loop = RepeatForever::create(Sequence::create(s1, s2, NULL));
   else
     loop = RepeatForever::create(Sequence::create(s2, s1, NULL));;
   loop->setTag(SMALL_ANIMATION_TAG);
   s->runAction(loop);
 }
Beispiel #19
0
ActionRotateToRepeat::ActionRotateToRepeat()
: ActionBase("RotateToRepeat", NULL)
{
    ActionInterval *action1 = new RotateTo(1, 90);
    ActionInterval *action2 = new RotateTo(1, 0);
    ActionInterval *seq = new Sequence(action1, action2, NULL);
    
    
    Action *rep1 = new RepeatForever(seq->copy());   
    Action *rep2 = new Repeat(seq, 5);

    tamara->runAction(rep1);
    kathia->runAction(rep2);
}
Beispiel #20
0
ActionReverseSequence::ActionReverseSequence()
: ActionBase("ReverseSeq", NULL)
{
    ActionInterval *move1 = new MoveBy(1, fzPoint(250, 0));
    ActionInterval *move2 = new MoveBy(1, fzPoint(0, 50));
    ActionInterval *seq = new Sequence(move1,
                                       move2, 
                                       move1->reverse(), NULL);
    
    ActionInterval *action = new Sequence(seq,
                                          seq->reverse(), NULL);

	grossini->runAction(action);
}
Beispiel #21
0
ActionRotate::ActionRotate()
: ActionBase("Rotate", NULL)
{
    ActionInterval *actionTo = new RotateTo(2, 45);
    ActionInterval *actionTo2 = new RotateTo(2, -45);
    ActionInterval *actionTo0 = new RotateTo(2, 0);
    
    ActionInterval *actionBy = new RotateBy(2, 360);
    ActionInterval *actionByBack = actionBy->reverse();
    
    tamara->runAction(new Sequence(actionTo, actionTo0, NULL));
    grossini->runAction(new Sequence(actionBy, actionByBack, NULL));
    kathia->runAction(new Sequence(actionTo2, actionTo0->copy(), NULL));
}
Beispiel #22
0
void Leaf::initBody() {
    CSprite* leafSprite = new CSprite(SPRITE_TYPE_MAIN);
    leafSprite->initWithIdentifier(FRAME_LEAF_IDLE);
    leafSprite->bind(CStringUtil::getPattern(FRAME_LEAF_IDLE));

    ActionInterval* drownAction = (ActionInterval*) leafSprite->getAction(FRAME_LEAF_FALL, false);
    this->drownDuration = drownAction->getDuration();
    this->getSprites()->pushBack(leafSprite);

    RectBody* rectBody = new RectBody(leafSprite->getContentSize().width, leafSprite->getContentSize().height);
    rectBody->setAnchorPoint(Point(0.5, 0.5));
    CC_SAFE_RETAIN(rectBody);
    this->body = rectBody;
}
Beispiel #23
0
ActionSkew::ActionSkew()
: ActionBase("Action Skew", NULL)
{
    ActionInterval *actionTo = new SkewTo(2, 37.2f, -37.2f);
    ActionInterval *actionToBack = new SkewTo(2, 0, 0);
    ActionInterval *actionBy = new SkewBy(2, 0, -90);
    ActionInterval *actionBy2 = new SkewBy(2, 45, 45);
    ActionInterval *actionByBack = actionBy->reverse();
    
    
    tamara->runAction(new Sequence(actionTo, actionToBack, NULL));
    grossini->runAction(new Sequence(actionBy, actionByBack, NULL));
    kathia->runAction(new Sequence(actionBy2, actionBy2->reverse(), NULL));
}
Beispiel #24
0
cocos2d::Node* ParticleComponentTest::createGameScene()
{
    Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.json");
	if (node == nullptr)
	{
		return nullptr;
	}

	ComRender* Particle = static_cast<ComRender*>(node->getChildByTag(10020)->getComponent("CCParticleSystemQuad"));
	ActionInterval*  jump = JumpBy::create(5, Point(-500,0), 50, 4);
	FiniteTimeAction*  action = Sequence::create( jump, jump->reverse(), nullptr);
	Particle->getNode()->runAction(action);
    return node;
}
Beispiel #25
0
void StartPanel::hide() {
    ActionInterval * fadeout = FadeOut::create(1);
    Vector<Node *> children_list = this->getChildren();
    Vector<Node *>::iterator itor = children_list.begin();
    Vector<Node *>::iterator iend = children_list.end();
    while (itor != iend) {
        ActionInterval * pAction = fadeout->clone();
        (*itor)->runAction(pAction);

        itor++;
    }
    Smart09::create()->RemoveTouchHandle(m_pButtons[STARTUI_MENU_PLAY]);
    Smart09::create()->RemoveTouchHandle(m_pButtons[STARTUI_MENU_HELP]);
    Smart09::create()->RemoveTouchHandle(m_pButtonSound);
}
////////////////////////////////////////////////////////
//
// For test functions
//
////////////////////////////////////////////////////////
void performanceActions(Sprite* pSprite)
{
    Size size = Director::sharedDirector()->getWinSize();
    pSprite->setPosition(ccp((rand() % (int)size.width), (rand() % (int)size.height)));

    float period = 0.5f + (rand() % 1000) / 500.0f;
    RotateBy* rot = RotateBy::create(period, 360.0f * CCRANDOM_0_1());
    ActionInterval* rot_back = rot->reverse();
    Action *permanentRotation = RepeatForever::create(Sequence::create(rot, rot_back, NULL));
    pSprite->runAction(permanentRotation);

    float growDuration = 0.5f + (rand() % 1000) / 500.0f;
    ActionInterval *grow = ScaleBy::create(growDuration, 0.5f, 0.5f);
    Action *permanentScaleLoop = RepeatForever::create(Sequence::create(grow, grow->reverse(), NULL));
    pSprite->runAction(permanentScaleLoop);
}
Beispiel #27
0
void StartPanel::show(const bool start) {
    ActionInterval * fadein = FadeIn::create(1);
    Vector<Node *> children_list = this->getChildren();
    Vector<Node *>::iterator itor = children_list.begin();
    Vector<Node *>::iterator iend = children_list.end();
    while (itor != iend) {
        ActionInterval * pAction = fadein->clone();
        (*itor)->runAction(pAction);

        itor++;
    }

    Smart09::create()->AddTouchHandle(TOUCH_GRADE_UI, m_pButtons[STARTUI_MENU_PLAY]);
    Smart09::create()->AddTouchHandle(TOUCH_GRADE_UI, m_pButtons[STARTUI_MENU_HELP]);
    Smart09::create()->AddTouchHandle(TOUCH_GRADE_UI, m_pButtonSound);
}
Beispiel #28
0
void EnemyFlower::launchEnemy()
{
	enemyBody->runAction(RepeatForever::create(AnimationManager::getInstance()->createAnimate(eAniflower)));
	Point pos = this->getPosition();	
	pos.y -= bodySize.height;
	startPos = pos;
	this->runAction(Place::create(pos));

	ActionInterval *pMoveBy = MoveBy::create(1.0f, Point(0.0f, bodySize.height));
	ActionInterval *pDelay = DelayTime::create(1.0f);
	ActionInterval *pMoveByBack = pMoveBy->reverse();
	ActionInterval *pDelay2 = DelayTime::create(2.0f);
	this->runAction(RepeatForever::create(
		(ActionInterval*)Sequence::create(pMoveBy, pDelay, pMoveByBack, pDelay2, NULL)));

	this->scheduleUpdate();
}
Beispiel #29
0
bool BirdSprite::createBird()
{
	this->createBirdByRandom();
	if (Sprite::initWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName(this->birdName)))
	{
		Animation *pAnimation = this->createAnimation(this->birdNameFormat.c_str(), 3, 10);
		Animate *pAnimate = Animate::create(pAnimation);
		this->idleAction = RepeatForever::create(pAnimate);

		//Create the swing action
		ActionInterval *pUp = CCMoveBy::create(0.4f, Point(0, 8));
		ActionInterval *pUpBack =pUp->reverse();
		this->swingAction = RepeatForever::create(Sequence::create(pUp, pUpBack, NULL));
		return true;
	}

	return false;
}
Beispiel #30
0
bool BirdSprite::createBird(){
	this->createBirdByRandom();
	if(Sprite::initWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName(this->birdName))) {
		// init idle status
		//create the bird animation
		Animation* animation = this->createAnimation(this->birdNameFormat.c_str(), 3, 10);
		Animate* animate = Animate::create(animation);
		this->idleAction = RepeatForever::create(animate);

		// create the swing action
		ActionInterval *up = CCMoveBy::create(0.4f,Point(0, 8));
		ActionInterval *upBack= up->reverse();
		this->swingAction = RepeatForever::create(Sequence::create(up, upBack, NULL));
		return true;
	}else {
		return false;
	}
}