예제 #1
0
IntervalLayer::IntervalLayer()
{
	m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;

	CCSize s = CCDirector::sharedDirector()->getWinSize();
	// sun
	CCParticleSystem* sun = CCParticleSun::node();
    sun->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png"));
	sun->setPosition( CCPointMake(s.width-32,s.height-32) );

	sun->setTotalParticles(130);
	sun->setLife(0.6f);
	this->addChild(sun);

	// timers
    m_label0 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
	m_label1 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
	m_label2 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
	m_label3 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");
    m_label4 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt");

    scheduleUpdate();
	schedule(schedule_selector(IntervalLayer::step1));
	schedule(schedule_selector(IntervalLayer::step2), 0);
	schedule(schedule_selector(IntervalLayer::step3), 1.0f);
    schedule(schedule_selector(IntervalLayer::step4), 2.0f);

    m_label0->setPosition(CCPointMake(s.width*1/6, s.height/2));
	m_label1->setPosition(CCPointMake(s.width*2/6, s.height/2));
	m_label2->setPosition(CCPointMake(s.width*3/6, s.height/2));
	m_label3->setPosition(CCPointMake(s.width*4/6, s.height/2));
    m_label4->setPosition(CCPointMake(s.width*5/6, s.height/2));

    addChild(m_label0);
	addChild(m_label1);
	addChild(m_label2);
	addChild(m_label3);
    addChild(m_label4);

	// Sprite
	CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	sprite->setPosition( CCPointMake(40,50) );
	
	CCJumpBy* jump = CCJumpBy::actionWithDuration(3, CCPointMake(s.width-80,0), 50, 4);
	
	addChild(sprite);
	sprite->runAction( CCRepeatForever::actionWithAction(
															(CCActionInterval*)(CCSequence::actions(jump, jump->reverse(), NULL ))
														)
					 );
	// pause button
	CCMenuItem* item1 = CCMenuItemFont::itemFromString("Pause", this, menu_selector(IntervalLayer::onPause) );
	CCMenu* menu = CCMenu::menuWithItems(item1, NULL);
	menu->setPosition( CCPointMake(s.width/2, s.height-50) );

	addChild( menu );
}
예제 #2
0
//------------------------------------------------------------------
//
// MenuLayer3
//
//------------------------------------------------------------------
MenuLayer3::MenuLayer3()
{
    CCMenuItemFont::setFontName("Marker Felt");
    CCMenuItemFont::setFontSize(28);

    CCLabelBMFont* label = CCLabelBMFont::create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
    CCMenuItemLabel* item1 = CCMenuItemLabel::create(label, this, menu_selector(MenuLayer3::menuCallback2) );
    CCMenuItemFont* item2 = CCMenuItemFont::create("--- Go Back ---", this, menu_selector(MenuLayer3::menuCallback) );
    
    CCSprite *spriteNormal   = CCSprite::create(s_MenuItem,  CCRectMake(0,23*2,115,23));
    CCSprite *spriteSelected = CCSprite::create(s_MenuItem,  CCRectMake(0,23*1,115,23));
    CCSprite *spriteDisabled = CCSprite::create(s_MenuItem,  CCRectMake(0,23*0,115,23));
    
    
    CCMenuItemSprite* item3 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayer3::menuCallback3));
    m_disabledItem = item3;  item3->retain();
    m_disabledItem->setEnabled( false );
    
    CCMenu *menu = CCMenu::create( item1, item2, item3, NULL);    
    menu->setPosition( CCPointMake(0,0) );

    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    item1->setPosition( CCPointMake(s.width/2 - 150, s.height/2) );
    item2->setPosition( CCPointMake(s.width/2 - 200, s.height/2) );
    item3->setPosition( CCPointMake(s.width/2, s.height/2 - 100) );
    
    CCJumpBy* jump = CCJumpBy::create(3, CCPointMake(400,0), 50, 4);
    item2->runAction( CCRepeatForever::create(
                                (CCActionInterval*)(CCSequence::create( jump, jump->reverse(), NULL))
                                )
                    );
    CCActionInterval* spin1 = CCRotateBy::create(3, 360);
    CCActionInterval* spin2 = (CCActionInterval*)(spin1->copy()->autorelease());
    CCActionInterval* spin3 = (CCActionInterval*)(spin1->copy()->autorelease());
    
    item1->runAction( CCRepeatForever::create(spin1) );
    item2->runAction( CCRepeatForever::create(spin2) );
    item3->runAction( CCRepeatForever::create(spin3) );
    
    addChild( menu ); 

    menu->setPosition(ccp(0,0));
}