예제 #1
0
bool MainMenu::init()
{
    if(CCLayer::init())
    {
        CCSprite *bg = CCSprite::create("bg.png");
        bg->setPosition(ccp(240, 160));
        this->addChild(bg);
        
        CCMenuItemFont *item1 = CCMenuItemFont::create("interval");
        CCMenuItemFont *item2 = CCMenuItemFont::create("intant");
        CCMenuItemFont *item3 = CCMenuItemFont::create("speed");
        CCMenuItemFont *item4 = CCMenuItemFont::create("follow");
        CCMenuItemFont *item5 = CCMenuItemFont::create("manager");
        
        item1->setTarget(this, menu_selector(MainMenu::actionIntervalCallBack));
        item2->setTarget(this, menu_selector(MainMenu::actionIntantCallBack));
        item3->setTarget(this, menu_selector(MainMenu::actionSpeedCallBack));
        item4->setTarget(this, menu_selector(MainMenu::actionFollowCallBack));
        item5->setTarget(this, menu_selector(MainMenu::actionManagerCallBack));
        
        CCMenu *menu = CCMenu::create(item1,item2,item3,item4,item5,NULL);
        menu->setColor(ccc3(0, 255, 0));
        menu->alignItemsInColumns(1,2,2);
        menu->setPosition(ccp(240,160));
        this->addChild(menu);
        return true;
    }
    return false;
}
예제 #2
0
bool Options::init()
{
    if (!CCLayer::init()) {
        return false;
    }
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *sp = CCSprite::create(s_loading);
    sp->setAnchorPoint(CCPointZero);
    addChild(sp, 0, 1);
    
    CCTexture2D *imageCache = CCTextureCache::sharedTextureCache()->addImage(s_menuTitle);
    CCSprite *title = CCSprite::createWithTexture(imageCache, CCRectMake(0, 0, 134, 34));
    title->setPosition(ccp(winSize.width/2, winSize.height - 60));
    addChild(title);

    CCMenuItemFont *menuTitle = CCMenuItemFont::create("Sound");
    menuTitle->setFontName("Arial");
    menuTitle->setFontSize(18);
    menuTitle->setEnabled(false);
    
    CCMenuItemFont::setFontName("Arial");
    CCMenuItemFont::setFontSize(26);
    CCMenuItemToggle *toggle = CCMenuItemToggle::createWithTarget(this, menu_selector(Options::setOptions), CCMenuItemFont::create("On"),CCMenuItemFont::create("Off"), NULL);
    
    int selectId = Config::sharedConfig()->getAudioState()? 0 : 1;
    toggle->setSelectedIndex(selectId);
    
    CCLabelBMFont *backLb = CCLabelBMFont::create("Go Back", s_font);
    CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(Options::goBack));
    goBack->setScale(0.6);
    CCActionInterval *fadeIn = CCFadeTo::create(1, 80);
    CCActionInterval *fadeOut = CCFadeTo::create(1, 255);
    CCEaseSineInOut *ease1 = CCEaseSineInOut::create(fadeIn);
    CCEaseSineInOut *ease2 = CCEaseSineInOut::create(fadeOut);
    CCFiniteTimeAction *seq = CCSequence::create(ease1, ease2, NULL);
    // 这里也是,参数必须强转,否则NDK编译不过
    goBack->runAction(CCRepeatForever::create((CCActionInterval*)seq));
    
    CCMenu *menu = CCMenu::create( menuTitle, toggle, goBack, NULL);
    menu->alignItemsInColumns(2,1);
    addChild(menu);

    
    CCPoint pos =  goBack->getPosition();
    pos.y -= 50;
    goBack->setPosition(pos);
    
    
    return true;
}
예제 #3
0
bool ActionSequence::init()
{
    if(CCLayer::init())
    {
        CCSprite *bg = CCSprite::create("bg.png");
        bg->setPosition(ccp(240, 160));
        this->addChild(bg);
        
        CCMenuItemImage *itemImage = CCMenuItemImage::create("b1.png", "b2.png");
        itemImage->setTarget(this, menu_selector(ActionSequence::back));
        CCMenu *backMenu = CCMenu::create(itemImage,NULL);
        backMenu->setPosition(ccp(50,280));
        this->addChild(backMenu);
        
        CCMenuItemFont *item1 = CCMenuItemFont::create("CCSequence");
        CCMenuItemFont *item2 = CCMenuItemFont::create("CCSpawn");
       
        
        item1->setTarget(this, menu_selector(ActionSequence::showSequence));
        item2->setTarget(this, menu_selector(ActionSequence::showSpawn));
        
        
        CCMenu *menu = CCMenu::create(item1,item2,NULL);
        menu->setColor(ccc3(0, 255, 0));
        menu->alignItemsInColumns(1,1);
        menu->setPosition(ccp(240,80));
        this->addChild(menu);
        
        mySprite = CCSprite::create("bird.png");
        mySprite->setPosition(ccp(60, 180));
        this->addChild(mySprite);
        
        return true;
    }
    return false;
}
KDbool OptionsMenu::init ( KDvoid )
{
	if ( !CCLayer::init ( ) )
	{
		return KD_FALSE;
	}

	// Random background color
	CCSprite*	pBG = CCSprite::create ( "blank.png" );
	pBG->setPosition ( ccp ( 240, 160 ) );
	pBG->setTextureRect ( CCRect ( 0, 0, 480, 320 ) );
	pBG->setColor ( ccc3 ( kdRand ( ) % 150, kdRand ( ) % 150, kdRand ( ) % 150 ) );
	this->addChild ( pBG );

	// Init our message label
	m_pMessage = CCLabelBMFont::create ( "", "eurostile_30.fnt" );
	m_pMessage->setPosition ( ccp ( 160, 270 ) );
	m_pMessage->setScale ( 0.5f );
	m_pMessage->setColor ( ccc3 ( 255, 255, 255 ) );
	this->addChild ( m_pMessage, 10 );

	// Disabled title label for Sound option
	CCMenuItemFont*		pTitle1 = CCMenuItemFont::create ( "Sound" );
	pTitle1->setEnabled ( KD_FALSE );
	pTitle1->setColor ( ccc3 ( 0, 0, 0 ) );

	// Toggleable item for Sound option
	CCMenuItemToggle*	pItem1 = CCMenuItemToggle::createWithTarget
	(
		this,
		menu_selector ( OptionsMenu::soundToggle ),
		CCMenuItemFont::create ( "On" ),
		CCMenuItemFont::create ( "Off" ),
		KD_NULL
	);

	// Disabled title label for Difficulty option
	CCMenuItemFont*		pTitle2 = CCMenuItemFont::create ( "Difficulty" );
	pTitle2->setEnabled ( KD_FALSE );
	pTitle2->setColor ( ccc3 ( 0, 0, 0 ) );

	// Toggleable item for Difficulty option
	CCMenuItemToggle*	pItem2 = CCMenuItemToggle::createWithTarget
	(
		this,
		menu_selector ( OptionsMenu::difficultyToggle ),
		CCMenuItemFont::create ( "Easy" ),
		CCMenuItemFont::create ( "Medium" ),
		CCMenuItemFont::create ( "Hard" ),
		CCMenuItemFont::create ( "Insane" ),
		KD_NULL
	);

	// Back button
	CCMenuItemFont*		pBack = CCMenuItemFont::create ( "Back", this, menu_selector ( OptionsMenu::back ) );

	// Finally, create our menu
	CCMenu*				pMenu = CCMenu::create ( pTitle1, pTitle2, pItem1, pItem2, pBack, KD_NULL );		// 5 items.

	// Align items in columns
	pMenu->alignItemsInColumns ( 2, 2, 1, KD_NULL );
	pMenu->setPosition ( ccp ( 240, 160 ) );
	this->addChild ( pMenu );

	return KD_TRUE;
}
예제 #5
0
OptionsLayer::OptionsLayer()
{
	CCMenuItemFont::setFontName("American Typewriter");
	CCMenuItemFont::setFontSize(26);
	CCMenuItemFont*title1 = CCMenuItemFont::create("Sound");
	title1->setEnabled(false);
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(46);
	CCMenuItemToggle* item1 = CCMenuItemToggle::createWithTarget(this, 
		menu_selector(OptionsLayer::menuCallback), 
		CCMenuItemFont::create( "On" ),
		CCMenuItemFont::create( "Off"),
		NULL );

	CCMenuItemFont::setFontName( "American Typewriter" );
	CCMenuItemFont::setFontSize(26);
	CCMenuItemFont* title2 = CCMenuItemFont::create( "Music" );
	title2->setEnabled(false);
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(46);
	CCMenuItemToggle *item2 = CCMenuItemToggle::createWithTarget(this, 
		menu_selector(OptionsLayer::menuCallback),
		CCMenuItemFont::create( "On" ),
		CCMenuItemFont::create( "Off"),
		NULL );

	CCMenuItemFont::setFontName( "American Typewriter" );
	CCMenuItemFont::setFontSize(26);
	CCMenuItemFont* title3 = CCMenuItemFont::create( "Quality" );
	title3->setEnabled( false );
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(46);
	CCMenuItemToggle *item3 = CCMenuItemToggle::createWithTarget(this, 
		menu_selector(OptionsLayer::menuCallback), 
		CCMenuItemFont::create( "High" ),
		CCMenuItemFont::create( "Low" ),
		NULL );

	CCMenuItemFont::setFontName( "American Typewriter" );
	CCMenuItemFont::setFontSize(26);
	CCMenuItemFont* title4 = CCMenuItemFont::create( "Orientation" );
	title4->setEnabled(false);
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(46);
	CCMenuItemToggle *item4 = CCMenuItemToggle::createWithTarget(this, 
		menu_selector(OptionsLayer::menuCallback), 
		CCMenuItemFont::create( "Off" ), 
		NULL );

	//UxArray* more_items = UxArray::arrayWithObjects(
	//                                                 CCMenuItemFont::create( "33%" ),
	//                                                 CCMenuItemFont::create( "66%" ),
	//                                                 CCMenuItemFont::create( "100%" ),
	//                                                 NULL );
	// TIP: you can manipulate the items like any other CCMutableArray
	item4->getSubItems()->addObject( CCMenuItemFont::create( "33%" ) ); 
	item4->getSubItems()->addObject( CCMenuItemFont::create( "66%" ) ); 
	item4->getSubItems()->addObject( CCMenuItemFont::create( "100%" ) ); 

	// you can change the one of the items by doing this
	item4->setSelectedIndex( 2 );

	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize( 60 );

	CCSize size = CCDirector::sharedDirector()->getWinSize();

	CCMenu *menu = CCMenu::create(
		title1, title2,
		item1, item2,
		title3, title4,
		item3, item4, NULL); 

	menu->alignItemsInColumns(2, 2, 2, 2);

	this->addChild(menu, 1);

	CCLabelBMFont *label = CCLabelBMFont::create( "go back", "futura-48.fnt" );
	CCMenuItemLabel* back = CCMenuItemLabel::create(label, this, menu_selector(OptionsLayer::backCallback) );
	CCMenu *menuBack = CCMenu::create(back, NULL);
	menuBack->setPosition(ccp(size.width - 100, 50));
	this->addChild(menuBack, 1);
	
	menu->setPosition(ccp(size.width/2, size.height/2));

	// add "MainMenu" splash screen"
	CCSprite* pSprite = CCSprite::create("safe_background.jpg");

	// position the sprite on the center of the screen
	pSprite->setPosition( ccp(size.width / 2, size.height / 2) );

	// add the sprite as a child to this layer
	this->addChild(pSprite, 0);
}
예제 #6
0
//------------------------------------------------------------------
//
// MenuLayer4
//
//------------------------------------------------------------------
MenuLayer4::MenuLayer4()
{
	CCMenuItemFont::setFontName("American Typewriter");
	CCMenuItemFont::setFontSize(18);
	CCMenuItemFont*title1 = CCMenuItemFont::itemFromString("Sound");
    title1->setIsEnabled(false);
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(34);
	CCMenuItemToggle* item1 = CCMenuItemToggle::itemWithTarget(	this, 
																menu_selector(MenuLayer4::menuCallback), 
																CCMenuItemFont::itemFromString( "On" ),
																CCMenuItemFont::itemFromString( "Off"),
																NULL );
    
	CCMenuItemFont::setFontName( "American Typewriter" );
	CCMenuItemFont::setFontSize(18);
	CCMenuItemFont* title2 = CCMenuItemFont::itemFromString( "Music" );
    title2->setIsEnabled(false);
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(34);
	CCMenuItemToggle *item2 = CCMenuItemToggle::itemWithTarget(	this, 
																menu_selector(MenuLayer4::menuCallback),
																CCMenuItemFont::itemFromString( "On" ),
																CCMenuItemFont::itemFromString( "Off"),
																NULL );
    
	CCMenuItemFont::setFontName( "American Typewriter" );
	CCMenuItemFont::setFontSize(18);
	CCMenuItemFont* title3 = CCMenuItemFont::itemFromString( "Quality" );
    title3->setIsEnabled( false );
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(34);
	CCMenuItemToggle *item3 = CCMenuItemToggle::itemWithTarget(	this, 
																menu_selector(MenuLayer4::menuCallback), 
																CCMenuItemFont::itemFromString( "High" ),
																CCMenuItemFont::itemFromString( "Low" ),
																NULL );
    
	CCMenuItemFont::setFontName( "American Typewriter" );
	CCMenuItemFont::setFontSize(18);
	CCMenuItemFont* title4 = CCMenuItemFont::itemFromString( "Orientation" );
    title4->setIsEnabled(false);
	CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize(34);
	CCMenuItemToggle *item4 = CCMenuItemToggle::itemWithTarget( this, 
																menu_selector(MenuLayer4::menuCallback), 
																CCMenuItemFont::itemFromString( "Off" ), 
																NULL );
	
	//UxArray* more_items = UxArray::arrayWithObjects(
	//												 CCMenuItemFont::itemFromString( "33%" ),
	//												 CCMenuItemFont::itemFromString( "66%" ),
	//												 CCMenuItemFont::itemFromString( "100%" ),
	//												 NULL );
	// TIP: you can manipulate the items like any other NSMutableArray
	item4->getSubItems()->addObject( CCMenuItemFont::itemFromString( "33%" ) ); 
	item4->getSubItems()->addObject( CCMenuItemFont::itemFromString( "66%" ) ); 
	item4->getSubItems()->addObject( CCMenuItemFont::itemFromString( "100%" ) ); 
	
    // you can change the one of the items by doing this
    item4->setSelectedIndex( 2 );
    
    CCMenuItemFont::setFontName( "Marker Felt" );
	CCMenuItemFont::setFontSize( 34 );
	
	CCBitmapFontAtlas *label = CCBitmapFontAtlas::bitmapFontAtlasWithString( "go back", "fonts/bitmapFontTest3.fnt" );
	CCMenuItemLabel* back = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer4::backCallback) );
    
	CCMenu *menu = CCMenu::menuWithItems(
                  title1, title2,
                  item1, item2,
                  title3, title4,
                  item3, item4,
                  back, NULL ); // 9 items.
    
	menu->alignItemsInColumns(2, 2, 2, 2, 1, NULL);
    
	addChild( menu );
}
예제 #7
0
//------------------------------------------------------------------
//
// MenuLayer4
//
//------------------------------------------------------------------
MenuLayer4::MenuLayer4()
{
    CCMenuItemFont::setFontName("American Typewriter");
    CCMenuItemFont::setFontSize(18);
    CCMenuItemFont*title1 = CCMenuItemFont::create("Sound");
    title1->setEnabled(false);
    CCMenuItemFont::setFontName( "Marker Felt" );
    CCMenuItemFont::setFontSize(34);
    CCMenuItemToggle* item1 = CCMenuItemToggle::create(    this, 
                                                                menu_selector(MenuLayer4::menuCallback), 
                                                                CCMenuItemFont::create( "On" ),
                                                                CCMenuItemFont::create( "Off"),
                                                                NULL );
    
    CCMenuItemFont::setFontName( "American Typewriter" );
    CCMenuItemFont::setFontSize(18);
    CCMenuItemFont* title2 = CCMenuItemFont::create( "Music" );
    title2->setEnabled(false);
    CCMenuItemFont::setFontName( "Marker Felt" );
    CCMenuItemFont::setFontSize(34);
    CCMenuItemToggle *item2 = CCMenuItemToggle::create(    this, 
                                                                menu_selector(MenuLayer4::menuCallback),
                                                                CCMenuItemFont::create( "On" ),
                                                                CCMenuItemFont::create( "Off"),
                                                                NULL );
    
    CCMenuItemFont::setFontName( "American Typewriter" );
    CCMenuItemFont::setFontSize(18);
    CCMenuItemFont* title3 = CCMenuItemFont::create( "Quality" );
    title3->setEnabled( false );
    CCMenuItemFont::setFontName( "Marker Felt" );
    CCMenuItemFont::setFontSize(34);
    CCMenuItemToggle *item3 = CCMenuItemToggle::create(    this, 
                                                                menu_selector(MenuLayer4::menuCallback), 
                                                                CCMenuItemFont::create( "High" ),
                                                                CCMenuItemFont::create( "Low" ),
                                                                NULL );
    
    CCMenuItemFont::setFontName( "American Typewriter" );
    CCMenuItemFont::setFontSize(18);
    CCMenuItemFont* title4 = CCMenuItemFont::create( "Orientation" );
    title4->setEnabled(false);
    CCMenuItemFont::setFontName( "Marker Felt" );
    CCMenuItemFont::setFontSize(34);
    CCMenuItemToggle *item4 = CCMenuItemToggle::create( this, 
                                                                menu_selector(MenuLayer4::menuCallback), 
                                                                CCMenuItemFont::create( "Off" ), 
                                                                NULL );
    
    //UxArray* more_items = UxArray::arrayWithObjects(
    //                                                 CCMenuItemFont::create( "33%" ),
    //                                                 CCMenuItemFont::create( "66%" ),
    //                                                 CCMenuItemFont::create( "100%" ),
    //                                                 NULL );
    // TIP: you can manipulate the items like any other CCMutableArray
    item4->getSubItems()->addObject( CCMenuItemFont::create( "33%" ) ); 
    item4->getSubItems()->addObject( CCMenuItemFont::create( "66%" ) ); 
    item4->getSubItems()->addObject( CCMenuItemFont::create( "100%" ) ); 
    
    // you can change the one of the items by doing this
    item4->setSelectedIndex( 2 );
    
    CCMenuItemFont::setFontName( "Marker Felt" );
    CCMenuItemFont::setFontSize( 34 );
    
    CCLabelBMFont *label = CCLabelBMFont::create( "go back", "fonts/bitmapFontTest3.fnt" );
    CCMenuItemLabel* back = CCMenuItemLabel::create(label, this, menu_selector(MenuLayer4::backCallback) );
    
    CCMenu *menu = CCMenu::create(
                  title1, title2,
                  item1, item2,
                  title3, title4,
                  item3, item4,
                  back, NULL ); // 9 items.
    
    menu->alignItemsInColumns(2, 2, 2, 2, 1, NULL);
    
    addChild( menu );

    CCSize s = CCDirector::sharedDirector()->getWinSize();
    menu->setPosition(ccp(s.width/2, s.height/2));
}