Exemple #1
0
//------------------------------------------------------------------
//
// LayerTest2
//
//------------------------------------------------------------------
void LayerTest2::onEnter()
{
    LayerTest::onEnter();

    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCLayerColor* layer1 = CCLayerColor::create( ccc4(255, 255, 0, 80), 100, 300);
    layer1->setPosition(ccp(s.width/3, s.height/2));
    layer1->ignoreAnchorPointForPosition(false);
    addChild(layer1, 1);
    
    CCLayerColor* layer2 = CCLayerColor::create( ccc4(0, 0, 255, 255), 100, 300);
    layer2->setPosition(ccp((s.width/3)*2, s.height/2));
    layer2->ignoreAnchorPointForPosition(false);
    addChild(layer2, 1);
    
    CCActionInterval* actionTint = CCTintBy::create(2, -255, -127, 0);
    CCActionInterval* actionTintBack = actionTint->reverse();
    CCActionInterval* seq1 = CCSequence::create( actionTint, actionTintBack, NULL);
    layer1->runAction(seq1);

    CCActionInterval* actionFade = CCFadeOut::create(2.0f);
    CCActionInterval* actionFadeBack = actionFade->reverse();
    CCActionInterval* seq2 = CCSequence::create(actionFade, actionFadeBack, NULL);        
    layer2->runAction(seq2);
}
Exemple #2
0
//------------------------------------------------------------------
//
// LayerTest2
//
//------------------------------------------------------------------
void LayerTest2::onEnter()
{
	LayerTest::onEnter();

	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLayerColor* layer1 = CCLayerColor::layerWithColorWidthHeight( ccc4(255, 255, 0, 80), 100, 300);
	layer1->setPosition(CCPointMake(s.width/3, s.height/2));
	layer1->setIsRelativeAnchorPoint(true);
	addChild(layer1, 1);
	
	CCLayerColor* layer2 = CCLayerColor::layerWithColorWidthHeight( ccc4(0, 0, 255, 255), 100, 300);
	layer2->setPosition(CCPointMake((s.width/3)*2, s.height/2));
	layer2->setIsRelativeAnchorPoint(true);
	addChild(layer2, 1);
	
	CCActionInterval* actionTint = CCTintBy::actionWithDuration(2, -255, -127, 0);
	CCActionInterval* actionTintBack = actionTint->reverse();
	CCActionInterval* seq1 = (CCActionInterval*)CCSequence::actions( actionTint, actionTintBack, NULL);
	layer1->runAction(seq1);

	CCActionInterval* actionFade = CCFadeOut::actionWithDuration(2.0f);
	CCActionInterval* actionFadeBack = actionFade->reverse();
	CCActionInterval* seq2 = (CCActionInterval*)CCSequence::actions(actionFade, actionFadeBack, NULL);		
	layer2->runAction(seq2);
}
Parallax1::Parallax1()
{
    // Top Layer, a simple image
    CCSprite* cocosImage = CCSprite::spriteWithFile(s_Power);
    // scale the image (optional)
    cocosImage->setScale( 2.5f );
    // change the transform anchor point to 0,0 (optional)
    cocosImage->setAnchorPoint( ccp(0,0) );
    

    // Middle layer: a Tile map atlas
    CCTileMapAtlas *tilemap = CCTileMapAtlas::tileMapAtlasWithTileFile(s_TilesPng, s_LevelMapTga, 16, 16);
    tilemap->releaseMap();
    
    // change the transform anchor to 0,0 (optional)
    tilemap->setAnchorPoint( ccp(0, 0) );

    // Anti Aliased images
    tilemap->getTexture()->setAntiAliasTexParameters();
    

    // background layer: another image
    CCSprite* background = CCSprite::spriteWithFile(s_back);
    // scale the image (optional)
    background->setScale( 1.5f );
    // change the transform anchor point (optional)
    background->setAnchorPoint( ccp(0,0) );

    
    // create a void node, a parent node
    CCParallaxNode* voidNode = CCParallaxNode::node();
    
    // NOW add the 3 layers to the 'void' node

    // background image is moved at a ratio of 0.4x, 0.5y
    voidNode->addChild(background, -1, ccp(0.4f,0.5f), CCPointZero);
    
    // tiles are moved at a ratio of 2.2x, 1.0y
    voidNode->addChild(tilemap, 1, ccp(2.2f,1.0f), ccp(0,-200) );
    
    // top image is moved at a ratio of 3.0x, 2.5y
    voidNode->addChild(cocosImage, 2, ccp(3.0f,2.5f), ccp(200,800) );
    
    
    // now create some actions that will move the 'void' node
    // and the children of the 'void' node will move at different
    // speed, thus, simulation the 3D environment
    CCActionInterval* goUp = CCMoveBy::actionWithDuration(4, ccp(0,-500) );
    CCActionInterval* goDown = goUp->reverse();
    CCActionInterval* go = CCMoveBy::actionWithDuration(8, ccp(-1000,0) );
    CCActionInterval* goBack = go->reverse();
    CCFiniteTimeAction* seq = CCSequence::actions(goUp, go, goDown, goBack, NULL);
    voidNode->runAction( (CCRepeatForever::actionWithAction((CCActionInterval*) seq) ));
    
    addChild( voidNode );
}
//------------------------------------------------------------------
//
// SpriteEaseBack
//
//------------------------------------------------------------------
KDvoid SpriteEaseBack::onEnter ( KDvoid )
{
	TestEaseActions::onEnter ( );

    CCSize s = this->getContentSize ( );
    
    CCActionInterval* move = CCMoveBy::create(3, ccp(s.cx-130, 0 ) );
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseBackIn::create ( CCCA ( move ) );
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseBackOut::create ( CCCA ( move ) );
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
    
    CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), KD_NULL);
    CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), KD_NULL);
    CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), KD_NULL);
    
    m_grossini->runAction(CCRepeatForever::create ( seq1 ) );
    m_tamara->runAction(CCRepeatForever::create ( seq2 ) );
    m_kathia->runAction(CCRepeatForever::create ( seq3 ) ); 
}
//------------------------------------------------------------------
//
// SpriteEase
//
//------------------------------------------------------------------
KDvoid SpriteEase::onEnter ( KDvoid )
{
	TestEaseActions::onEnter ( );
	
    const CCSize&  s = this->getContentSize ( );
    
    CCActionInterval* move = CCMoveBy::create(3, ccp(s.cx-130,0 ) );
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseIn::create ( CCCA ( move ), 2.5f);
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseOut::create ( CCCA ( move ), 2.5f);
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
    
    CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), KD_NULL);
    CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), KD_NULL);
    CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), KD_NULL);
    
    
    CCAction *a2 = m_grossini->runAction(CCRepeatForever::create ( seq1 ) );
    a2->setTag(1);

    CCAction *a1 = m_tamara->runAction(CCRepeatForever::create ( seq2 ) );
    a1->setTag(1);

    CCAction *a = m_kathia->runAction(CCRepeatForever::create ( seq3 ) );
    a->setTag(1);

    schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);

}
Exemple #6
0
void GameScene::birdReadyAction()
{
    CCSize winSize =CCDirector::sharedDirector()->getWinSize();
    // 添加bird精灵
    CCSprite *bird =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird1.png"));
    bird->setPosition(ccp(winSize.width/2-80,winSize.height/2+20));
    bird->setZOrder(20);
    bird->setScale(0.6);
    bird->setTag(TAG_BIRD);
    bird->setVisible(false);
    this->addChild(bird);
    // 创建动画对象
    CCAnimation *birdAnimation =CCAnimation::create();
    birdAnimation->setDelayPerUnit(0.2);
    birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird1.png"));
    birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird2.png"));
    birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird3.png"));
    // 创建动画动作
    birdanimate =CCAnimate::create(birdAnimation);
    CCActionInterval *action =CCMoveBy::create(0.2,ccp(0,10));
    CCActionInterval *action1 =action->reverse();
    CCActionInterval *sequence =CCSequence::create(action,action1,NULL);
    CCSpawn *spawn =CCSpawn::create(sequence,birdanimate,NULL);
    CCRepeatForever *birdrepeatForever =CCRepeatForever::create(spawn);
    // 让bird精灵一直运行动画
    bird->runAction(birdrepeatForever);
}
void ParticleComponentTest::defaultPlay()
{
	CCComRender* Particle = static_cast<CCComRender*>(m_rootNode->getChildByTag(10020)->getComponent("CCParticleSystemQuad"));
	CCActionInterval*  jump = CCJumpBy::create(5, ccp(-500,0), 50, 4);
	CCFiniteTimeAction*  action = CCSequence::create( jump, jump->reverse(), NULL);
	Particle->getNode()->runAction(action);
}
Exemple #8
0
//------------------------------------------------------------------
//
// NodeToWorld
//
//------------------------------------------------------------------
NodeToWorld::NodeToWorld()
{
    //
    // This code tests that nodeToParent works OK:
    //  - It tests different anchor Points
    //  - It tests different children anchor points

    CCSprite *back = CCSprite::create(s_back3);
    addChild( back, -10);
    back->setAnchorPoint( ccp(0,0) );
    CCSize backSize = back->getContentSize();
    
    CCMenuItem *item = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect);
    CCMenu *menu = CCMenu::create(item, NULL);
    menu->alignItemsVertically();
    menu->setPosition( ccp(backSize.width/2, backSize.height/2));
    back->addChild(menu);
    
    CCActionInterval* rot = CCRotateBy::create(5, 360);
    CCAction* fe = CCRepeatForever::create( rot);
    item->runAction( fe );
    
    CCActionInterval* move = CCMoveBy::create(3, ccp(200,0));
    CCActionInterval* move_back = move->reverse();
    CCSequence* seq = CCSequence::create( move, move_back, NULL);
    CCAction* fe2 = CCRepeatForever::create(seq);
    back->runAction(fe2);
}
//------------------------------------------------------------------
//
// Effect2
//
//------------------------------------------------------------------
void Effect2::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCNode* target = getChildByTag(kTagBackground);
	
	// To reuse a grid the grid size and the grid type must be the same.
	// in this case:
	//     ShakyTiles is TiledGrid3D and it's size is (15,10)
	//     Shuffletiles is TiledGrid3D and it's size is (15,10)
	//	   TurnOfftiles is TiledGrid3D and it's size is (15,10)
	CCActionInterval* shaky = CCShakyTiles3D::actionWithRange(4, false, ccg(15,10), 5);
	CCActionInterval* shuffle = CCShuffleTiles::actionWithSeed(0, ccg(15,10), 3);
	CCActionInterval* turnoff = CCTurnOffTiles::actionWithSeed(0, ccg(15,10), 3);
	CCActionInterval* turnon = turnoff->reverse();
	
	// reuse 2 times:
	//   1 for shuffle
	//   2 for turn off
	//   turnon tiles will use a new grid
	CCFiniteTimeAction* reuse = CCReuseGrid::actionWithTimes(2);

	CCActionInterval* delay = CCDelayTime::actionWithDuration(1);
	
//	id orbit = [OrbitCamera::actionWithDuration:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90];
//	id orbit_back = [orbit reverse];
//
//	[target runAction: [RepeatForever::actionWithAction: [Sequence actions: orbit, orbit_back, nil]]];
	target->runAction( (CCActionInterval *)(CCSequence::actions( shaky, delay, reuse, shuffle, delay->copy()->autorelease(), turnoff, turnon, NULL) ) );
}
Exemple #10
0
void MapScene::reduceLife(int num)
{
    (player->getsprite())->stopAllActions();

    /*switch(playerlife){
    case 3:
       life1->setIsVisible(false);
       playerlife --;
       break;
    case 2:
       life2->setIsVisible(false);
       playerlife --;
       break;
    case 1:
       life3->setIsVisible(false);
       playerlife --;
       break;
    }*/
    if(player->life-num == 5)
    {

    }
    CCActionInterval*  action = CCRotateBy::actionWithDuration(0.05, 15);
    (player->getsprite())->runAction(CCSequence::actions(action, action->reverse(), NULL));
    //这里还需要加入对frozen状态的判断此时不无敌,即reduce=false;
    //schedule(schedule_selector(MapScene::resetreduce), 0.2f);
    //isreduce = true;
}
Exemple #11
0
void SpriteEaseBack::onEnter()
{
    EaseSpriteDemo::onEnter();
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0));
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseBackIn::create((CCActionInterval*)(move->copy()->autorelease()));
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseBackOut::create((CCActionInterval*)(move->copy()->autorelease()));
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
    
    CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
    CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
    CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
    
    m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)seq1));
    m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)seq2));
    m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)seq3));    
}
Exemple #12
0
void CCTransitionSplitCols::onEnter()
{
    CCTransitionScene::onEnter();
    m_pInScene->setVisible(false);

    CCActionInterval* split = action();
    CCActionInterval* seq = (CCActionInterval*)CCSequence::create
    (
        split,
        CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
        split->reverse(),
        NULL
    );

    this->runAction
    ( 
        CCSequence::create
        (
            easeActionWithAction(seq),
            CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
            CCStopGrid::create(),
            NULL
        )
    );
}
Exemple #13
0
void CCTransitionRotoZoom:: onEnter()
{
    CCTransitionScene::onEnter();

    m_pInScene->setScale(0.001f);
    m_pOutScene->setScale(1.0f);

    m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f));
    m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f));

    CCActionInterval *rotozoom = (CCActionInterval*)(CCSequence::create
    (
        CCSpawn::create
        (
            CCScaleBy::create(m_fDuration/2, 0.001f),
            CCRotateBy::create(m_fDuration/2, 360 * 2),
            NULL
        ),
        CCDelayTime::create(m_fDuration/2),
        NULL
    ));

    m_pOutScene->runAction(rotozoom);
    m_pInScene->runAction
    (
        CCSequence::create
        (
            rotozoom->reverse(),
            CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
            NULL
        )
    );
}
Exemple #14
0
//------------------------------------------------------------------
//
// Test6
//
//------------------------------------------------------------------
Test6::Test6()
{
    CCSprite* sp1 = CCSprite::create(s_pPathSister1);
    CCSprite* sp11 = CCSprite::create(s_pPathSister1);

    CCSprite* sp2 = CCSprite::create(s_pPathSister2);
    CCSprite* sp21 = CCSprite::create(s_pPathSister2);
        
    sp1->setPosition(ccp(100,160));
    sp2->setPosition(ccp(380,160));
        
    CCActionInterval* rot = CCRotateBy::create(2, 360);
    CCActionInterval* rot_back = rot->reverse();
    CCAction* forever1 = CCRepeatForever::create(CCSequence::create(rot, rot_back, NULL));
    CCAction* forever11 =  (CCAction*)(forever1->copy()->autorelease());

    CCAction* forever2 =  (CCAction*)(forever1->copy()->autorelease());
    CCAction* forever21 =  (CCAction*)(forever1->copy()->autorelease());
    
    addChild(sp1, 0, kTagSprite1);
    sp1->addChild(sp11);
    addChild(sp2, 0, kTagSprite2);
    sp2->addChild(sp21);
    
    sp1->runAction(forever1);
    sp11->runAction(forever11);
    sp2->runAction(forever2);
    sp21->runAction(forever21);
    
    schedule( schedule_selector(Test6::addAScutRemove), 2.0f);
}
void SpriteEaseSine::onEnter()
{
    EaseSpriteDemo::onEnter();

    CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130, 0));
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseSineIn::create((CCActionInterval*)(move->copy()->autorelease()) );
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseSineOut::create((CCActionInterval*)(move->copy()->autorelease()) );
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
        
    CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
    CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
    CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
    
    
    m_grossini->runAction( CCRepeatForever::create(seq1));
    m_tamara->runAction( CCRepeatForever::create(seq2));
    m_kathia->runAction( CCRepeatForever::create(seq3));    

}
void SpriteEase::onEnter()
{
    EaseSpriteDemo::onEnter();
    
    CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0));
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseIn::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
    
    CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
    CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
    CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
    
    
    CCAction *a2 = m_grossini->runAction(CCRepeatForever::create(seq1));
    a2->setTag(1);

    CCAction *a1 = m_tamara->runAction(CCRepeatForever::create(seq2));
    a1->setTag(1);

    CCAction *a = m_kathia->runAction(CCRepeatForever::create(seq3));
    a->setTag(1);

    schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);
}
//------------------------------------------------------------------
//
// ParallaxParticle
//
//------------------------------------------------------------------
void ParallaxParticle::onEnter()
{
	ParticleDemo::onEnter();
	
	m_background->getParent()->removeChild(m_background, true);
    m_background = NULL;

	CCParallaxNode* p = CCParallaxNode::node(); 
	addChild(p, 5);

	CCSprite *p1 = CCSprite::spriteWithFile(s_back3);
	CCSprite *p2 = CCSprite::spriteWithFile(s_back3);
	
	p->addChild( p1, 1, CGPointMake(0.5f,1), CGPointMake(0,250) );
	p->addChild(p2, 2, CGPointMake(1.5f,1), CGPointMake(0,50) );

	m_emitter = CCParticleFlower::node();
    m_emitter->retain();
    m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) );

	p1->addChild(m_emitter, 10);
	m_emitter->setPosition( CGPointMake(250,200) );
	
	CCParticleSun* par = CCParticleSun::node();
	p2->addChild(par, 10);
    par->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) );
	
	CCActionInterval* move = CCMoveBy::actionWithDuration(4, CGPointMake(300,0));
	CCActionInterval* move_back = move->reverse();
	CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
	p->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq));	
}
void SpriteEase::onEnter()
{
	EaseSpriteDemo::onEnter();
	
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0) );
	CCActionInterval* move_back = move->reverse();
	
	CCActionInterval* move_ease_in = (CCActionInterval*)CCEaseIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f);
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();
	
	CCActionInterval* move_ease_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f);
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();
	
	
	CCFiniteTimeAction* seq1 = CCSequence::actions(move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, move_ease_out_back, NULL);
	
	
	CCAction *a2 = m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) );
	a2->setTag(1);

	CCAction *a1 = m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
	a1->setTag(1);

	CCAction *a = m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
	a->setTag(1);

	schedule(schedule_selector(SpriteEase::testStopAction), 6);
}
Exemple #19
0
//------------------------------------------------------------------
//
// NodeToWorld
//
//------------------------------------------------------------------
NodeToWorld::NodeToWorld()
{
	//
	// This code tests that nodeToParent works OK:
	//  - It tests different anchor Points
	//  - It tests different children anchor points

	CCSprite *back = CCSprite::spriteWithFile(s_back3);
	addChild( back, -10);
	back->setAnchorPoint( CCPointMake(0,0) );
	CCSize backSize = back->getContentSize();
	
	CCMenuItem *item = CCMenuItemImage::itemFromNormalImage(s_PlayNormal, s_PlaySelect);
	CCMenu *menu = CCMenu::menuWithItems(item, NULL);
	menu->alignItemsVertically();
	menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2));
	back->addChild(menu);
	
	CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360);
	CCAction* fe = CCRepeatForever::actionWithAction( rot);
	item->runAction( fe );
	
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0));
	CCActionInterval* move_back = move->reverse();
	CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
	CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
	back->runAction(fe2);
}
Exemple #20
0
//------------------------------------------------------------------
//
// Test6
//
//------------------------------------------------------------------
Test6::Test6()
{
	CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1);
	CCSprite* sp11 = CCSprite::spriteWithFile(s_pPathSister1);

	CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2);
	CCSprite* sp21 = CCSprite::spriteWithFile(s_pPathSister2);
		
	sp1->setPosition(CCPointMake(100,160));
	sp2->setPosition(CCPointMake(380,160));
		
	CCActionInterval* rot = CCRotateBy::actionWithDuration(2, 360);
	CCActionInterval* rot_back = rot->reverse();
	CCAction* forever1 = CCRepeatForever::actionWithAction(
															(CCActionInterval*)(CCSequence::actions(rot, rot_back, NULL)));
	CCAction* forever11 =  (CCAction*)(forever1->copy()->autorelease());

	CCAction* forever2 =  (CCAction*)(forever1->copy()->autorelease());
	CCAction* forever21 =  (CCAction*)(forever1->copy()->autorelease());
	
	addChild(sp1, 0, kTagSprite1);
	sp1->addChild(sp11);
	addChild(sp2, 0, kTagSprite2);
	sp2->addChild(sp21);
	
	sp1->runAction(forever1);
	sp11->runAction(forever11);
	sp2->runAction(forever2);
	sp21->runAction(forever21);
	
	schedule( schedule_selector(Test6::addAndRemove), 2.0f);
}
void FairyControlPanel::setVisiable(){
	if(!isDoClick){
		CCActionInterval * moveBy = CCMoveBy::create(0.3f,ccp(0,
			-panelBack->getContentSize().height - 30));
		panelBack->runAction(CCSequence::create(moveBy->reverse(), 
			CCCallFuncN::create(this,callfuncN_selector(FairyControlPanel::finishDoClick)),NULL));
	}
}
Exemple #22
0
void BaseBug::byPress(){
    m_bug->setScale(1.0f);
    CCActionInterval* action = CCScaleBy::create(0.05f, 0.9f);
    CCActionInterval* actionReverse = action->reverse();
    CCFiniteTimeAction* finiteAction = CCSequence::create(action, actionReverse,NULL);
    m_bug->runAction(finiteAction);
	CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("press.mp3");
    showFlower();
}
ParticleDemo::ParticleDemo(void)
{
	initWithColor( ccc4(127,127,127,255) );

	m_emitter = NULL;

	setIsTouchEnabled( true );
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28);
	addChild(label, 100, 1000);
	label->setPosition( CCPointMake(s.width/2, s.height-50) );
	
	CCLabelTTF *tapScreen = CCLabelTTF::labelWithString("(Tap the Screen)", "Arial", 20);
	tapScreen->setPosition( CCPointMake(s.width/2, s.height-80) );
	addChild(tapScreen, 100);
	
	CCMenuItemImage* item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ParticleDemo::backCallback) );
	CCMenuItemImage* item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ParticleDemo::restartCallback) );
	CCMenuItemImage* item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2,  this, menu_selector(ParticleDemo::nextCallback) );
	
	CCMenuItemToggle* item4 = CCMenuItemToggle::itemWithTarget(	this, 
																menu_selector(ParticleDemo::toggleCallback), 
																CCMenuItemFont::itemFromString( "Free Movement" ),
                                                                CCMenuItemFont::itemFromString( "Relative Movement" ),
																CCMenuItemFont::itemFromString( "Grouped Movement" ),
																NULL );
	
	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, item4, NULL);
		
	menu->setPosition( CCPointZero );
	item1->setPosition( CCPointMake( s.width/2 - 100,30) );
	item2->setPosition( CCPointMake( s.width/2, 30) );
	item3->setPosition( CCPointMake( s.width/2 + 100,30) );
	item4->setPosition( CCPointMake( 0, 100) );
	item4->setAnchorPoint( CCPointMake(0,0) );

	addChild( menu, 100 );	
	
    CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.');
    addChild(labelAtlas, 100, kTagLabelAtlas);
	labelAtlas->setPosition( CCPointMake(s.width-66,50) );
	
	// moving background
	m_background = CCSprite::spriteWithFile(s_back3);
	addChild(m_background, 5);
	m_background->setPosition( CCPointMake(s.width/2, s.height-180) );

	CCActionInterval* move = CCMoveBy::actionWithDuration(4, CCPointMake(300,0) );
	CCActionInterval* move_back = move->reverse();
	CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
	m_background->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq) );
	
	
	schedule( schedule_selector(ParticleDemo::step) );
}
//跟踪动画  
void HelloWorld::GZCallback(CCObject* pSender)  
{  
    CCActionInterval* Moveto = CCMoveBy::actionWithDuration(3.0f,CCPointMake(s.width*2+100, 0));  
    CCActionInterval* MoveBack = Moveto->reverse();  
    CCFiniteTimeAction* All = CCSequence::actions(Moveto,MoveBack,NULL);  
    CCAction* rep = CCRepeatForever::actionWithAction((CCActionInterval*)All);//包装动作为永久循环  
  
    m_tamara->runAction(rep);//执行rep动作  
    this->runAction(CCFollow::actionWithTarget(m_tamara,CCRectMake(0,0,s.width*2, s.height)));//执行跟踪动作  
}  
Exemple #25
0
TextLayer::TextLayer(void)
{
	initWithColor( ccc4(32,32,32,255) );
		
	float x,y;
	
	CGSize size = CCDirector::sharedDirector()->getWinSize();
	x = size.width;
	y = size.height;
	
	CCNode* node = CCNode::node();
	CCActionInterval* effect = getAction();
	node->runAction(effect)
		;
	addChild(node, 0, kTagBackground);
	
	CCSprite *bg = CCSprite::spriteWithFile(s_back3);
	node->addChild(bg, 0);
	bg->setAnchorPoint( CGPointZero );

	CCSprite* grossini = CCSprite::spriteWithFile(s_pPathSister2);
	node->addChild(grossini, 1);
	grossini->setPosition( CGPointMake(x/3,y/2) );
	CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc_back = sc->reverse();
	grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) );

	CCSprite* tamara = CCSprite::spriteWithFile(s_pPathSister1);
	node->addChild(tamara, 1);
	tamara->setPosition( CGPointMake(2*x/3,y/2) );
	CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc2_back = sc2->reverse();
	tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL))) );
	
	CCLabelTTF* label = CCLabelTTF::labelWithString((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
	
	label->setPosition( CGPointMake(x/2,y-80) );
	addChild(label);
	label->setTag( kTagLabel );

	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

	menu->setPosition( CGPointZero );
	item1->setPosition( CGPointMake( size.width/2 - 100,30) );
	item2->setPosition( CGPointMake( size.width/2, 30) );
	item3->setPosition( CGPointMake( size.width/2 + 100,30) );
	
	addChild(menu, 1);	

	schedule( schedule_selector(TextLayer::checkAnim) );
}
void EffectAdvanceTextLayer::onEnter(void)
{
	CCLayer::onEnter();
	float x,y;
	
	CGSize size = CCDirector::sharedDirector()->getWinSize();
	x = size.width;
	y = size.height;
	
	CCSprite *bg = CCSprite::spriteWithFile("Images/background3.png");
	addChild(bg, 0, kTagBackground);
	bg->setPosition( ccp(x/2,y/2) );
	
	CCSprite* grossini = CCSprite::spriteWithFile("Images/grossinis_sister2.png");
	bg->addChild(grossini, 1, kTagSprite1);
	grossini->setPosition( ccp(x/3.0f,200) );
	CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc_back = sc->reverse();
	grossini->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) );

	CCSprite* tamara = CCSprite::spriteWithFile("Images/grossinis_sister1.png");
	bg->addChild(tamara, 1, kTagSprite2);
	tamara->setPosition( ccp(2*x/3.0f,200) );
	CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc2_back = sc2->reverse();
	tamara->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL)) ) );
	
	CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Marker Felt", 28);
	
	label->setPosition( ccp(x/2,y-80) );
	addChild(label);
	label->setTag( kTagLabel );

	std::string strSubtitle = subtitle();
	if( ! strSubtitle.empty() ) 
	{
		CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
		addChild(l, 101);
		l->setPosition( ccp(size.width/2, size.height-80) );
	}	

	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

	menu->setPosition( CGPointZero );
	item1->setPosition( ccp( size.width/2 - 100,30) );
	item2->setPosition( ccp( size.width/2, 30) );
	item3->setPosition( ccp( size.width/2 + 100,30) );
	
	addChild(menu, 1);	
}
Exemple #27
0
//------------------------------------------------------------------
//
// ActionReverse
//
//------------------------------------------------------------------
void ActionReverse::onEnter()
{
    ActionsDemo::onEnter();

    alignSpritesLeft(1);

    CCActionInterval*  jump = CCJumpBy::actionWithDuration(2, CGPointMake(300,0), 50, 4);
    CCFiniteTimeAction*  action = CCSequence::actions( jump, jump->reverse(), NULL);

    m_grossini->runAction(action);
}
Exemple #28
0
//------------------------------------------------------------------
//
// Atlas4
//
//------------------------------------------------------------------
Atlas4::Atlas4()
{
	m_time = 0;

	// Upper Label
	CCLabelBMFont *label = CCLabelBMFont::labelWithString("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
	addChild(label);
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	
	label->setPosition( ccp(s.width/2, s.height/2) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );
	
	
	CCSprite* BChar = (CCSprite*) label->getChildByTag(0);
	CCSprite* FChar = (CCSprite*) label->getChildByTag(7);
	CCSprite* AChar = (CCSprite*) label->getChildByTag(12);
	
	
	CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360);
	CCAction* rot_4ever = CCRepeatForever::actionWithAction(rotate);
	
	CCActionInterval* scale = CCScaleBy::actionWithDuration(2, 1.5f);
	CCActionInterval* scale_back = scale->reverse();
	CCFiniteTimeAction* scale_seq = CCSequence::actions(scale, scale_back,NULL);
	CCAction* scale_4ever = CCRepeatForever::actionWithAction((CCActionInterval*)scale_seq);
	
	CCActionInterval* jump = CCJumpBy::actionWithDuration(0.5f, CCPointZero, 60, 1);
	CCAction* jump_4ever = CCRepeatForever::actionWithAction(jump);
	
	CCActionInterval* fade_out = CCFadeOut::actionWithDuration(1);
	CCActionInterval* fade_in = CCFadeIn::actionWithDuration(1);
	CCFiniteTimeAction* seq = CCSequence::actions(fade_out, fade_in, NULL);
	CCAction* fade_4ever = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
	
	BChar->runAction(rot_4ever);
	BChar->runAction(scale_4ever);
	FChar->runAction(jump_4ever);
	AChar->runAction(fade_4ever);
	
	
	// Bottom Label
	CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("00.0", "fonts/bitmapFontTest.fnt");
	addChild(label2, 0, kTagBitmapAtlas2);
	label2->setPosition( ccp(s.width/2.0f, 80) );
	
	CCSprite* lastChar = (CCSprite*) label2->getChildByTag(3);
	lastChar->runAction( (CCAction*)(rot_4ever->copy()->autorelease()) );
	
	schedule( schedule_selector(Atlas4::step), 0.1f);
}
void EffectAdvanceTextLayer::onEnter(void)
{
    CCLayer::onEnter();
    
    CCSprite *bg = CCSprite::create("Images/background3.png");
    addChild(bg, 0, kTagBackground);
    bg->setPosition( VisibleRect::center() );
    
    CCSprite* grossini = CCSprite::create("Images/grossinis_sister2.png");
    bg->addChild(grossini, 1, kTagSprite1);
    grossini->setPosition( ccp(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) );
    CCActionInterval* sc = CCScaleBy::create(2, 5);
    CCActionInterval* sc_back = sc->reverse();
    grossini->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc, sc_back, NULL)) ) );

    CCSprite* tamara = CCSprite::create("Images/grossinis_sister1.png");
    bg->addChild(tamara, 1, kTagSprite2);
    tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) );
    CCActionInterval* sc2 = CCScaleBy::create(2, 5);
    CCActionInterval* sc2_back = sc2->reverse();
    tamara->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc2, sc2_back, NULL)) ) );
    
    CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28);
    
    label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
    addChild(label);
    label->setTag( kTagLabel );

    std::string strSubtitle = subtitle();
    if( ! strSubtitle.empty() ) 
    {
        CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
        addChild(l, 101);
        l->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
    }    

    CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
    CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
    CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );

    CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);

    menu->setPosition(CCPointZero);
    item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
    item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
    item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
    
    addChild(menu, 1);    
}
Exemple #30
0
TextLayer::TextLayer(void)
{
    initWithColor( ccc4(32,128,32,255) );
    
    CCNode* node = CCNode::create();
    CCActionInterval* effect = getAction();
    node->runAction(effect);
    addChild(node, 0, kTagBackground);
    
    CCSprite *bg = CCSprite::create(s_back3);
    node->addChild(bg, 0);
//  bg->setAnchorPoint( CCPointZero );
    bg->setPosition(VisibleRect::center());

    CCSprite* grossini = CCSprite::create(s_pPathSister2);
    node->addChild(grossini, 1);
    grossini->setPosition( ccp(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
    CCActionInterval* sc = CCScaleBy::create(2, 5);
    CCActionInterval* sc_back = sc->reverse();
    grossini->runAction( CCRepeatForever::create(CCSequence::create(sc, sc_back, NULL) ) );

    CCSprite* tamara = CCSprite::create(s_pPathSister1);
    node->addChild(tamara, 1);
    tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
    CCActionInterval* sc2 = CCScaleBy::create(2, 5);
    CCActionInterval* sc2_back = sc2->reverse();
    tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) );
    
    CCLabelTTF* label = CCLabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
    
    label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
    addChild(label);
    label->setTag( kTagLabel );

    CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
    CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
    CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );

    CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);

    menu->setPosition(CCPointZero);
    item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
    item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
    item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
    
    addChild(menu, 1);    

    schedule( schedule_selector(TextLayer::checkAnim) );
}