예제 #1
0
void Effect4::onEnter()
{
    EffectAdvanceTextLayer::onEnter();
    //Node* gridNode = NodeGrid::create();
    
    auto lens = Lens3D::create(10, Size(32,24), Vec2(100,180), 150);
    auto move = JumpBy::create(5, Vec2(380,0), 100, 4);
    auto move_back = move->reverse();
    auto seq = Sequence::create( move, move_back, NULL);

    /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'Lens3D' as its target.
        While in cocos2d-x, the target of action only supports Node or its subclass,
        so we make an encapsulation for Lens3D to achieve that.
    */

    auto director = Director::getInstance();
    auto pTarget = Lens3DTarget::create(lens);
    // Please make sure the target been added to its parent.
    this->addChild(pTarget);
    //gridNode->addChild(pTarget);

    director->getActionManager()->addAction(seq, pTarget, false);
    
    _bgNode->runAction( lens );
}
예제 #2
0
void PauseTest::unpause(float dt)
{
    unschedule( schedule_selector(PauseTest::unpause) );
    auto node = getChildByTag( kTagGrossini );
    auto director = Director::getInstance();
    director->getActionManager()->resumeTarget(node);
}
예제 #3
0
void PauseTest::onEnter()
{
    //
    // This test MUST be done in 'onEnter' and not on 'init'
    // otherwise the paused action will be resumed at 'onEnter' time
    //
    ActionManagerTest::onEnter();
    

    auto l = Label::createWithTTF("After 5 seconds grossini should move", "fonts/Thonburi.ttf", 16.0f);
    addChild(l);
    l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y-75) );
    
    
    //
    // Also, this test MUST be done, after [super onEnter]
    //
    auto grossini = Sprite::create(s_pathGrossini);
    addChild(grossini, 0, kTagGrossini);
    grossini->setPosition(VisibleRect::center() );
    
    auto action = MoveBy::create(1, Point(150,0));

    auto director = Director::getInstance();
    director->getActionManager()->addAction(action, grossini, true);

    schedule( schedule_selector(PauseTest::unpause), 3); 
}
예제 #4
0
void ResumeTest::resumeGrossini(float time)
{
    this->unschedule(schedule_selector(ResumeTest::resumeGrossini));

    auto pGrossini = getChildByTag(kTagGrossini);
    auto director = Director::getInstance();
    director->getActionManager()->resumeTarget(pGrossini);
}
예제 #5
0
void SchedulerUnscheduleAllHard::onExit()
{
    if(!_actionManagerActive) {
        // Restore the director's action manager.
        auto director = Director::getInstance();
        director->getScheduler()->scheduleUpdate(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false);
    }
    
    SchedulerTestLayer::onExit();
}
예제 #6
0
void ResumeTest::onEnter()
{
    ActionManagerTest::onEnter();

    auto l = Label::createWithTTF("Grossini only rotate/scale in 3 seconds", "fonts/Thonburi.ttf", 16.0f);
    addChild(l);
    l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75));

    auto pGrossini = Sprite::create(s_pathGrossini);
    addChild(pGrossini, 0, kTagGrossini);
    pGrossini->setPosition(VisibleRect::center());

    pGrossini->runAction(ScaleBy::create(2, 2));

    auto director = Director::getInstance();
    director->getActionManager()->pauseTarget(pGrossini);
    pGrossini->runAction(RotateBy::create(2, 360));

    this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f);
}
예제 #7
0
void GameLayer::ccTouchesBegan(CCSet* pTouches, CCEvent* event) {
	CCSetIterator i;
	CCTouch * touch;
	CCPoint tap;

	for (i = pTouches->begin(); i != pTouches->end(); i++) {
		touch = (CCTouch *) (*i);

		if (touch) {
			// begin to handle a touch event
			tap = touch->getLocation();

			if (_back->boundingBox().containsPoint(tap)) {
				_back->setPositionY(800 - 56.5);
			}
			if (_restart->boundingBox().containsPoint(tap)) {
				_restart->setPositionY(800 - 56.5);
			}

			for (unsigned b = 0; b < _numButtons->count(); b++) {
				CCSprite* button = (CCSprite*) _numButtons->objectAtIndex(b);
				if (button->boundingBox().containsPoint(tap)) {
					onButtonClicked(button, b);
				}
			}

			if(_hint->boundingBox().containsPoint(tap)) {
				if(Sudoku::state == Running && !Sudoku::isCurPosFilled() && Stats::hintNum > 0) {
					CCSprite* button = (CCSprite*)_numButtons->objectAtIndex(Sudoku::getResult() - 1);
					int actionNum = getActionManager()->numberOfRunningActionsInTarget(button);
					if(!actionNum) {
						consumeHint();
						button->runAction(
								CCSequence::create(
										CCRotateBy::create(1, 360),
										CCDelayTime::create(0.3),
										CCRotateBy::create(1, 360),
										NULL
								)
						);
					}
				}
			}

			if(_penToRun->boundingBox().containsPoint(tap)) {
				Sudoku::state = (Sudoku::state == Running) ? Note : Running;
				_pencilToNote->setVisible(Sudoku::state == Running);
				_penToRun->setVisible(Sudoku::state == Note);
				if(Sudoku::state == Note) updateBackplane();
				for(int i = 0; i < 9; i++) {
					CCSprite * rb = (CCSprite *) _numButtons->objectAtIndex(i);
					rb->setVisible(Sudoku::state == Running);

					CCSprite * nb = (CCSprite *) _numNote->objectAtIndex(i);
					nb->setVisible(Sudoku::state == Note);
				}
			}
			// end handling
		}
	}
}