コード例 #1
0
bool HelloWorldScene::init(void)
{
    CCScene::init();

    CCLabelTTF* label = CCLabelTTF::labelWithString("CCCrypto", "Arial", 24);
    CCMenuItemLabel* item1 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(HelloWorldScene::testCCCrypto));

    label = CCLabelTTF::labelWithString("CCNative", "Arial", 24);
    CCMenuItemLabel* item2 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(HelloWorldScene::testCCNative));
    
    label = CCLabelTTF::labelWithString("CCNetwork", "Arial", 24);
    CCMenuItemLabel* item3 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(HelloWorldScene::testCCNetwork));
    
    label = CCLabelTTF::labelWithString("CCStore", "Arial", 24);
    CCMenuItemLabel* item4 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(HelloWorldScene::testCCStore));
    
    label = CCLabelTTF::labelWithString("CCOpenFeint", "Arial", 24);
    CCMenuItemLabel* item5 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(HelloWorldScene::testCCOpenFeint));
    
	CCMenu* pMenu = CCMenu::menuWithItems(item1, item2, item3, item4, item5, NULL);
    pMenu->alignItemsVertically();
	addChild(pMenu);
    
	return true;
}
コード例 #2
0
bool CCCryptoScene::init(void)
{
    CCScene::init();
    
    CCLabelTTF* label = CCLabelTTF::labelWithString("encryptAES256() / decryptAES256()", "Arial", 22);
    CCMenuItemLabel* item1 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(CCCryptoScene::testEncryptAES256));
    
    label = CCLabelTTF::labelWithString("encodeBase64() / decodeBase64()", "Arial", 22);
    CCMenuItemLabel* item2 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(CCCryptoScene::testEncodeBase64));
    
    label = CCLabelTTF::labelWithString("MD5()", "Arial", 22);
    CCMenuItemLabel* item3 = CCMenuItemLabel::itemWithLabel(label,
                                                            this,
                                                            menu_selector(CCCryptoScene::testMD5));
    
    label = CCLabelTTF::labelWithString("- BACK -", "Arial", 22);
    CCMenuItemLabel* itemBack = CCMenuItemLabel::itemWithLabel(label,
                                                               this,
                                                               menu_selector(CCCryptoScene::backToMainScene));
    
	CCMenu* pMenu = CCMenu::menuWithItems(item1, item2, item3, itemBack, NULL);
    pMenu->alignItemsVertically();
	addChild(pMenu);
    
    return true;
}
コード例 #3
0
/**
* Impelmentation of RenderTextureSave
*/
RenderTextureSave::RenderTextureSave()
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();

	// create a render texture, this is what we are going to draw into
	m_pTarget = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height);
	m_pTarget->retain();
	m_pTarget->setPosition(ccp(s.width / 2, s.height / 2));

	// note that the render texture is a CCNode, and contains a sprite of its texture for convience,
	// so we can just parent it to the scene like any other CCNode
	this->addChild(m_pTarget, -1);

	// create a brush image to draw into the texture with
	m_pBrush = CCSprite::spriteWithFile("Images/fire.png");
	m_pBrush->retain();
	m_pBrush->setOpacity(20);
	this->setIsTouchEnabled(true);

	// Save Image menu
	CCMenuItemFont::setFontSize(16);
	CCMenuItem *item1 = CCMenuItemFont::itemFromString("Save Image", this, menu_selector(RenderTextureSave::saveImage));
	CCMenuItem *item2 = CCMenuItemFont::itemFromString("Clear", this, menu_selector(RenderTextureSave::clearImage));
	CCMenu *menu = CCMenu::menuWithItems(item1, item2, NULL);
	this->addChild(menu);
	menu->alignItemsVertically();
	menu->setPosition(ccp(s.width - 80, s.height - 30));
}
コード例 #4
0
ファイル: Bug-422.cpp プロジェクト: ccjimmy/TweeJump4wp8
void Bug422Layer::reset()
{
	static int localtag = 0;
	localtag++;

	// TO TRIGGER THE BUG:
	// remove the itself from parent from an action
	// The menu will be removed, but the instance will be alive
	// and then a new node will be allocated occupying the memory.
	// => CRASH BOOM BANG
	CCNode *node = getChildByTag(localtag-1);
	CCLog("Menu: %p", node);
	removeChild(node, false);
//	[self removeChildByTag:localtag-1 cleanup:NO];

    CCMenuItem *item1 = CCMenuItemFont::itemFromString("One", this, menu_selector(Bug422Layer::menuCallback));
	CCLog("MenuItemFont: %p", item1);
    CCMenuItem *item2 = CCMenuItemFont::itemFromString("Two", this, menu_selector(Bug422Layer::menuCallback));
    CCMenu *menu = CCMenu::menuWithItems(item1, item2, NULL);
	menu->alignItemsVertically();

	float x = CCRANDOM_0_1() * 50;
	float y = CCRANDOM_0_1() * 50;
	menu->setPosition(ccpAdd( menu->getPosition(), ccp(x,y)));
    addChild(menu, 0, localtag);	

    //[self check:self];
}
コード例 #5
0
bool Campaign::init()
{
    if ( !SelectSave::init() )
    {
        return false;
    }
    stageNum = stageTag0;
    
    SelectStage *stages = SelectStage::create();
    addChild(stages);
    stages->setTag(campTag_SelectStage);

    
    CCMenuItemFont *start    = CCMenuItemFont::create("START",this,menu_selector(Campaign::menuCloseCallback));
    CCMenuItemFont *soldiers = CCMenuItemFont::create("SOLDIERS",this,menu_selector(Campaign::menuCloseCallback));
    CCMenuItemFont *mainMenu = CCMenuItemFont::create("mainMenu",this,menu_selector(Campaign::menuCloseCallback));
    
    start->setTag(campTag_start);
    soldiers->setTag(campTag_soldiers);
    mainMenu->setTag(campTag_mainMenu);
    
    CCMenu *menu = CCMenu::create(start,soldiers,mainMenu,NULL);
    addChild(menu,10);
    menu->setPosition(CCPointZero);
    menu->alignItemsVertically();
    
    CCSize size = menu->getContentSize();
    CCLOG("%f %f",size.width,size.height);
    menu->setPosition(ccp(size.width/6, size.height/6));
//    menu->setScale(0.5f);
    
    return true;
}
コード例 #6
0
//------------------------------------------------------------------
//
// RenderTextureSave
//
//------------------------------------------------------------------
KDvoid RenderTextureSave::onEnter ( KDvoid )
{
	TestRenderTexture::onEnter ( );

	const CCSize&  tLyrSize = this->getContentSize ( );

	// create a render texture, this is what we're going to draw into
	m_pTarget = CCRenderTexture::create ( (KDint) tLyrSize.cx, (KDint) tLyrSize.cy );	
	m_pTarget->retain ( );
	m_pTarget->setPosition ( ccpMid ( tLyrSize ) );
		
	// note that the render texture is a cocosnode, and contains a sprite of it's texture for convience,
	// so we can just parent it to the scene like any other cocos node
	this->addChild ( m_pTarget, -1 );

	// create a brush image to draw into the texture with
	m_pBrush = CCSprite::create ( "Images/fire.png" );
	m_pBrush->retain ( );
	m_pBrush->setColor ( ccRED );
	m_pBrush->setOpacity ( 20 );
	
	this->setTouchEnabled ( KD_TRUE );

	// Save Image menu
	CCMenuItemFont::setFontName ( "fonts/Marker Felt.ttf" );
	CCMenuItemFont::setFontSize ( 24 );

    CCMenuItem*  pItem1 = CCMenuItemFont::create ( "Save Image", this, menu_selector ( RenderTextureSave::saveImage  ) );
    CCMenuItem*  pItem2 = CCMenuItemFont::create ( "Clear"	   , this, menu_selector ( RenderTextureSave::clearImage ) );
    CCMenu*       pMenu = CCMenu::create ( pItem1, pItem2, KD_NULL );
    this->addChild ( pMenu );
    pMenu->alignItemsVertically ( );
    pMenu->setPosition ( ccp ( tLyrSize.cx - 80, tLyrSize.cy / 2 ) );
}
コード例 #7
0
ファイル: CocosNodeTest.cpp プロジェクト: issamux/WebGame
//------------------------------------------------------------------
//
// 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);
}
コード例 #8
0
ファイル: SoundTest.cpp プロジェクト: lowsar/cocos2dx-wisound
void SoundPlayWAV::onEnter()
{
    SoundDemo::onEnter();
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	
	CCLabelTTF* label1 = CCLabelTTF::create("Play", "Helvetica", 24);
	CCMenuItemLabel* item1 = CCMenuItemLabel::create(label1, this, menu_selector(SoundPlayWAV::onPlayClicked));
	CCLabelTTF* label2 = CCLabelTTF::create("Stop", "Helvetica", 24);
	CCMenuItemLabel* item2 = CCMenuItemLabel::create(label2, this, menu_selector(SoundPlayWAV::onStopClicked));
    CCLabelTTF* label3 = CCLabelTTF::create("Effect(mono)", "Helvetica", 24);
	CCMenuItemLabel* item3 = CCMenuItemLabel::create(label3, this, menu_selector(SoundPlayWAV::onEffectMonoClicked));
    CCLabelTTF* label4 = CCLabelTTF::create("Effect(stereo)", "Helvetica", 24);
	CCMenuItemLabel* item4 = CCMenuItemLabel::create(label4, this, menu_selector(SoundPlayWAV::onEffectStereoClicked));
    CCLabelTTF* label5 = CCLabelTTF::create("Volume Down", "Helvetica", 24);
	CCMenuItemLabel* item5 = CCMenuItemLabel::create(label5, this, menu_selector(SoundPlayWAV::onVolumeDownClicked));
    CCLabelTTF* label6 = CCLabelTTF::create("Volume Up", "Helvetica", 24);
	CCMenuItemLabel* item6 = CCMenuItemLabel::create(label6, this, menu_selector(SoundPlayWAV::onVolumeUpClicked));
	CCMenu* menu = CCMenu::create(item1, item2, item3, item4, item5, item6, NULL);
	menu->alignItemsVertically();
	menu->setPosition(ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2));
	addChild(menu);
    
    SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic("Audios/bg_wav_mono_16.wav");
    SimpleAudioEngine::sharedEngine()->preloadEffect("Audios/effect_wav_mono_16.wav");
    SimpleAudioEngine::sharedEngine()->preloadEffect("Audios/effect_wav_stereo_16.wav");
}
コード例 #9
0
ファイル: TipLayer.cpp プロジェクト: david4750/ShootGame
bool TipLayer::initTipLayer()
{
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCLayerColor *maskLayer = CCLayerColor::node();
	maskLayer->initWithColorWidthHeight(ccc4f(0x00,0x00,0x00,0x80),335,350);
	//maskLayer->setOpacity(200);
	maskLayer->setAnchorPoint(ccp(0.5, 0.5));
	maskLayer->setPosition(ccp(winSize.width/2-maskLayer->getContentSize().width/2, winSize.height/2-maskLayer->getContentSize().height/2));
	this->addChild(maskLayer);
	/*CCSprite *bgSprite = CCSprite::spriteWithFile("actor_pause_bg.png");
	this->addChild(bgSprite);
	bgSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2));*/

	
	std::string stdNameOne = "";
	std::string stdNameTwo = "";
	std::string contentImageName = "";
	stdNameOne = s_touchfile + s_language + "actor_btn_cancel.png";
	stdNameTwo = s_touchfile + s_language + "actor_btn_confirm.png";
	contentImageName = s_language + "actor_img_tipContent.png";
	//content
	CCSprite *pContentSprite = CCSprite::spriteWithFile(contentImageName.c_str());
	this->addChild(pContentSprite);
	pContentSprite->setPosition(ccp(winSize.width / 2, winSize.height / 2 +100));

	CCMenuItemImage *cancelItem = CCMenuItemImage::itemFromNormalImage(stdNameOne.c_str(), stdNameOne.c_str(), this, menu_selector(TipLayer::cancel));
	CCMenuItemImage *confirmItem = CCMenuItemImage::itemFromNormalImage(stdNameTwo.c_str(), stdNameTwo.c_str(), this, menu_selector(TipLayer::confirm));
	CCMenu *menu = CCMenu::menuWithItems(confirmItem,cancelItem,NULL);
	menu->alignItemsVertically();
	menu->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 50));
	this->addChild(menu);

	CCLayer::setIsKeypadEnabled(true);
	return true;
}
コード例 #10
0
bool GameOverScene::init()
{
	bool bRet = false;
    do
    {
        CCDirector * pDirector;
        CC_BREAK_IF( ! (pDirector = CCDirector::sharedDirector()) );
        this->setContentSize(pDirector->getWinSize());
        
        CCSprite* bg = CCSprite::create("gameover.png");
        bg->setPosition(ccp(pDirector->getWinSize().width * 0.5,pDirector->getWinSize().height * 0.5));
        this->addChild(bg);
        
        CCMenuItemFont* mainMenu = CCMenuItemFont::create("Back To Menu",
			this,menu_selector(GameScene::menuPopSceneCallback));
        CCMenuItemFont* close = CCMenuItemFont::create("Exit Game",
			this,menu_selector(GameOverScene::menuCloseCallback));
        CCMenu* menu = CCMenu::create(mainMenu,close,NULL);
        menu->setPosition(ccp(pDirector->getWinSize().width * 0.5,pDirector->getWinSize().height * 0.3));
        menu->alignItemsVertically();
        this->addChild(menu,1);
        // success
        bRet = true;
    } while (0);
    return bRet;
}
コード例 #11
0
ファイル: GameOverLayer.cpp プロジェクト: crazyboymx/games
bool GameOverLayer::init()
{
	do
	{
		CC_BREAK_IF(!CCLayer::init());

		CCLayerColor* backgroundLayer = CCLayerColor::create(
			ccc4(255, 255, 255, 128));
		addChild(backgroundLayer);

		CCSize screenSize = CocosUtils::getScreenSize();

		CCMenuItemFont* nextLevel = CCMenuItemFont::create("Next", this,
			menu_selector(GameOverLayer::menuCallback));
		nextLevel->setTag(MENU_ITEM_NEXT_LEVEL);
		nextLevel->setFontName("Consola");
		nextLevel->setFontSize(36);

		CCMenuItemFont* replay = CCMenuItemFont::create("Replay", this,
			menu_selector(GameOverLayer::menuCallback));
		replay->setTag(MENU_ITEM_REPLAY);
		replay->setFontName("Consola");
		replay->setFontSize(36);

		CCMenu* menu = CCMenu::create(nextLevel, replay, NULL);
		menu->alignItemsVertically();

		menu->setPosition(screenSize.width/2, screenSize.height/2);
		addChild(menu);

		return true;
	} while (false);

	return false;
}
コード例 #12
0
ファイル: SceneTest.cpp プロジェクト: HongXiao/Client-source
bool SceneTestLayer3::init()
{
    if (CCLayerColor::initWithColor(ccc4(0,0,255,255)))
    {
        CCSize s = CCDirector::sharedDirector()->getWinSize();

        CCMenuItemFont *item0 = CCMenuItemFont::create("Touch to pushScene (self)", this, menu_selector(SceneTestLayer3::item0Clicked));
        CCMenuItemFont *item1 = CCMenuItemFont::create("Touch to popScene", this, menu_selector(SceneTestLayer3::item1Clicked));
        CCMenuItemFont *item2 = CCMenuItemFont::create("Touch to popToRootScene", this, menu_selector(SceneTestLayer3::item2Clicked));
        CCMenuItemFont *item3 = CCMenuItemFont::create("Touch to popToSceneStackLevel(2)", this, menu_selector(SceneTestLayer3::item3Clicked));

        CCMenu *menu = CCMenu::create(item0, item1, item2, item3, NULL);
        this->addChild(menu);
        menu->alignItemsVertically();

        this->schedule(schedule_selector(SceneTestLayer3::testDealloc));

        CCSprite* sprite = CCSprite::create(s_pPathGrossini);
        addChild(sprite);
        sprite->setPosition( ccp(s.width/2, 40) );
        CCActionInterval* rotate = CCRotateBy::create(2, 360);
        CCAction* repeat = CCRepeatForever::create(rotate);
        sprite->runAction(repeat);
        return true;
    }
    return false;
}
コード例 #13
0
ファイル: MenuScene.cpp プロジェクト: vincenthou/SUV
	bool CMenuLayer::init(){

		CCLabelTTF* pLabel = CCLabelTTF::create("CraftHero", "Arial", 30);

		CCSize size = CCDirector::sharedDirector()->getWinSize();
		pLabel->setPosition(ccp(size.width / 2, size.height - 50));
		this->addChild(pLabel, 1);

		CCSprite* pSprite = CCSprite::create("background.png");

		pSprite->setPosition(ccp(size.width/2, size.height/2));

		this->addChild(pSprite, 0);

		CCMenuItemFont::setFontName("Arial");
		CCMenuItemFont::setFontSize(25);
		CCMenuItemFont *newGame = CCMenuItemFont::itemWithString("New Game", this,menu_selector(CMenuLayer::gameNew) );
		CCMenuItemFont *loading = CCMenuItemFont::itemWithString("Loading", this,menu_selector(CMenuLayer::gameLoad) );
		CCMenuItemFont *option = CCMenuItemFont::itemWithString("Option", this,menu_selector(CMenuLayer::gameSetting) );
		CCMenuItemFont *quit = CCMenuItemFont::itemWithString("Quit", this,menu_selector(CMenuLayer::gameQuit) );

		CCMenu *menu = CCMenu::menuWithItems(newGame,loading,option,quit,NULL);
		menu->alignItemsVertically();
		this->addChild(menu, 1, 2);

		return true;
	}
コード例 #14
0
KDbool Ch3_SavingSimpleData::init ( KDvoid )
{	
	if ( !Recipe::init ( ) )
	{
		return KD_FALSE;
	}

	// Set font size
	CCMenuItemFont::setFontSize ( 30 );

	// Add main label
	CCLabelBMFont*	pChooseDifficultyLabel = CCLabelBMFont::create ( "CHOOSE DIFFICULTY:", "eurostile_30.fnt" );
	pChooseDifficultyLabel->setPosition ( ccp ( 240, 250 ) );
	pChooseDifficultyLabel->setScale ( 0.5f );
	this->addChild ( pChooseDifficultyLabel, 1 );
	
	// Add difficulty choices
	m_pEasyMIF	 = CCMenuItemFont::create ( "Easy"  , this, menu_selector ( Ch3_SavingSimpleData::chooseEasy ) );
	m_pMediumMIF = CCMenuItemFont::create ( "Medium", this, menu_selector ( Ch3_SavingSimpleData::chooseMedium ) );
	m_pHardMIF	 = CCMenuItemFont::create ( "Hard"  , this, menu_selector ( Ch3_SavingSimpleData::chooseHard ) );
	m_pInsaneMIF = CCMenuItemFont::create ( "Insane", this, menu_selector ( Ch3_SavingSimpleData::chooseInsane ) );

	CCMenu*		pMainMenu = CCMenu::create ( m_pEasyMIF, m_pMediumMIF, m_pHardMIF, m_pInsaneMIF, KD_NULL );
	pMainMenu->alignItemsVertically ( );
	pMainMenu->setPosition ( ccp ( 240, 140 ) );
	this->addChild ( pMainMenu, 1 );	
	
	// Load any previously chosen difficulty
	this->loadDifficulty ( );

	return KD_TRUE;
}
コード例 #15
0
bool ConnectionOverlay::init()
{
    bool bRet = false;
	do
	{
		CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)));
		
        
        CCMenuItemSprite* qItem = createMenuItemSprite((char*)"btnArrow_Back128x128.png", menu_selector(ConnectionOverlay::onClose));
        
        CCMenu* menu = CCMenu::create(qItem, NULL);
        
        menu->alignItemsVertically();
        menu->setPosition(ccp(200,270));
		// add this to the layer
		this->addChild( menu, 1 );
        
        CCLabelTTF* message = CCLabelTTF::create("Finding an open game...", "Arial", 24);
        message->setPosition(ccp(400,100));
                             
        this->addChild(message);
        
		bRet = true;
	} while (0);
    
	return bRet;
}
コード例 #16
0
ファイル: NodeTest.cpp プロジェクト: HongXiao/Client-source
//------------------------------------------------------------------
//
// 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);
}
コード例 #17
0
ファイル: TitleScene.cpp プロジェクト: sukesan1984/chain2
// on "init" you need to initialize your instance
bool Title::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    srand(time(NULL));
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("panels.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("title.plist");
    SimpleAudioEngine::sharedEngine()->preloadEffect("menu.wav");
    SimpleAudioEngine::sharedEngine()->preloadEffect("pon.wav");
    SimpleAudioEngine::sharedEngine()->preloadEffect("shupiin.wav");
    
    
    //CCLabelTTF* titleLabel  = CCLabelTTF::create("Hello", "arial", 20);
    //titleLabel->setPosition(CCPoint(visibleSize.width / 2, visibleSize.height / 2));
    //this->addChild(titleLabel);
    
    CCSprite* titleBackground = CCSprite::createWithSpriteFrameName("title.png");
    titleBackground->setAnchorPoint(CCPoint(0.5, 0.5));
    titleBackground->setScale(visibleSize.width / 640);
    titleBackground->setPosition(CCPoint(visibleSize.width / 2, visibleSize.height / 2));
    this->addChild(titleBackground, 1);
    
    CCMenuItemFont* gameMainFont = CCMenuItemFont::create("GAME START", this, menu_selector(Title::gameMainAction));
    gameMainFont->setFontNameObj(MISAKI_FONT);
    CCMenuItemLabel *gameMainButton = gameMainFont;
    gameMainButton->setColor(ccBLACK);
    
    CCMenuItemFont* rankingFont = CCMenuItemFont::create("RANKING", this, menu_selector(Title::rankingAction));
    rankingFont->setFontNameObj(MISAKI_FONT);
    CCMenuItemLabel *rankingButton  =rankingFont;
    rankingButton->setColor(ccBLACK);
    //CCMenuItemLabel *gamecenterButton  = CCMenuItemFont::create("GameCenterLogin", this, menu_selector(Title::login));
    
    CCMenuItemFont* creditFont = CCMenuItemFont::create("CREDIT", this, menu_selector(Title::creditAction));
    creditFont->setFontNameObj(MISAKI_FONT);
    CCMenuItemLabel *creditButton  =creditFont;
    creditButton->setColor(ccBLACK);
    
    //CCMenu *menu = CCMenu::createWithItems(gameMainButton, NULL);
    CCMenu *menu  = CCMenu::create(gameMainButton, rankingButton, creditButton, NULL);
    menu->setPosition(ccp(visibleSize.width/2, visibleSize.height/4));
    menu->alignItemsVertically();
    
    this->addChild(menu, 2);
    
    CCGATracker::sendView("Title");
    
    setTouchEnabled(true);
    
    this->schedule(schedule_selector(Title::update));
    return true;
}
コード例 #18
0
bool StatusMenu::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayer::init() )
	{
		return false;
	}
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCLayerColor* layer = CCLayerColor::create( ccc4(135, 135 , 135, 255));
    layer->ignoreAnchorPointForPosition(false);
    layer->setPosition( CCPointMake(s.width/2, s.height/2) );
    addChild(layer, 0);
    CCMenuItemImage *closebutton = CCMenuItemImage::create("close.png", "close_down.png", this, menu_selector(StatusMenu::CloseCallback));
    CCMenuItemImage *itembutton = CCMenuItemImage::create("package.png", "package_down.png", this, menu_selector(StatusMenu::ItemMenuCallback));
    CCMenuItemImage *charabutton = CCMenuItemImage::create("chara.png", "chara_down.png", this, menu_selector(StatusMenu::CharacterMenuCallback));
    closebutton->setPosition(ccp(-250, 50));
    itembutton->setPosition(ccp(-250, 105));
    charabutton->setPosition(ccp(-250, 160));
    CCMenu *menu = CCMenu::create(charabutton,itembutton,closebutton,NULL);
    addChild(menu,1);
    CCSprite *charabox = CCSprite::create("menu_bg_all.png");
    charabox->setPosition(ccp(450, s.height/2));
    addChild(charabox,1,12);
    CCSprite *itembox = CCSprite::create("item_bg_all.png");
    itembox->setPosition(ccp(450, s.height/2));
    addChild(itembox,1,13);

    CCMenu *itemmenu = CCMenu::create();
    for (int i=0; i<player->items.size(); i++) {
        switch (player->items[i]) {
            case 4:{
                CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("手电筒         X1", "AR PLMingU20 Light", 24));
                itemmenu->addChild(item, i+1, i+1);
                break;
            }
            case 6:{
                CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("水果刀         X1", "AR PLMingU20 Light", 24));
                itemmenu->addChild(item, i+1, i+1);
                break;
            }
            case 12:{
                CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("钥匙          X1", "AR PLMingU20 Light", 24));
                itemmenu->addChild(item, i+1, i+1);
                break;
            }
            default:
                break;
        }
    }
    itemmenu->setAnchorPoint(ccp(0, 1));
    itemmenu->alignItemsVertically();
    itemmenu->setPosition(itembox->getPositionX()-300,itembox->getPositionY()+130);
    itembox->addChild(itemmenu);
    CharacterMenuCallback(NULL);
	return true;
}
コード例 #19
0
ファイル: WaitingScene.cpp プロジェクト: Group2/The-New-Lines
// on "init" you need to initialize your instance
bool WaitingScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayerColor::initWithColor(ccc4(255,255,255,255)) )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	
    CCMenuItemImage *playButton = CCMenuItemImage::create(
                                        "play.png",
                                        "play.png",
                                        this,
                                        menu_selector(WaitingScene::singlePlay));
	
    CCMenuItemImage *multiPlayButton = CCMenuItemImage::create(
                                        "multiplay.png",
                                        "multiplay.png",
                                        this,
                                        menu_selector(WaitingScene::multiPlay));
    
    exitButton = CCMenuItemImage::create(
                                        "exit.png",
                                        "exit.png",
                                        this,
                                        menu_selector(WaitingScene::exit));
	
	exitButton->setPosition(ccp(origin.x + visibleSize.width - 50,
								origin.y + 30));
    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create();
	pMenu->addChild(playButton);
	pMenu->addChild(multiPlayButton);
    pMenu->setPosition(ccp(origin.x + visibleSize.width/2,
								origin.y + visibleSize.height/2 - 30));
	pMenu->alignItemsVertically();

    this->addChild(pMenu, 1);
	this->addChild(exitButton);
	this->setTouchEnabled(true);

	notify = "";
    pLabel = CCLabelTTF::create(notify, "Arial", TITLE_FONT_SIZE);
    
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - 20));
	ccColor3B color = { 0,0,0};
    pLabel->setColor(color);

	this->addChild(pLabel);

    return true;
}
コード例 #20
0
// on "init" you need to initialize your instance
bool TestLayer::init()
{
	bool bRet = false;
	do
	{
		//////////////////////////////////////////////////////////////////////////
		// super init first
		//////////////////////////////////////////////////////////////////////////
                
		//////////////////////////////////////////////////////////////////////////
		// add your codes below...
		//////////////////////////////////////////////////////////////////////////
        this->setTouchEnabled(true);
        
        CCArray* itemsArray = CCArray::create();
        
		CCMenuItemFont* item = CCMenuItemFont::create("Back", this,
                                                      menu_selector(TestLayer::menuCallback));
        item->setTag(1);
        itemsArray->addObject(item);
        
        CCMenu* menu = CCMenu::createWithArray(itemsArray);
        menu->alignItemsVertically();
        this->addChild(menu);
        
//        menu->setPosition(item->getContentSize().width, CCDirector::sharedDirector()->getWinSize().height - item->getContentSize().height/2);
        
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        

        menu->setPosition(20, winSize.height - 50);

        
        std::string message = this->initTest();
        
        CCSize s = CCDirector::sharedDirector()->getWinSize();
        
        float fontSize = 14;
        if(s.height > 1024)
        {
            fontSize = 34;
        }

        
        CCLabelTTF* label =  CCLabelTTF::create(message.c_str(), "Arial", fontSize);
        
        CCSize labelSize = label->getContentSize();
        
        label->setPosition(ccp(s.width/2, labelSize.height));
        this->addChild(label, -2);
        
		bRet = true;
	} while (0);
    
	return bRet;
}
コード例 #21
0
ファイル: SceneStart.cpp プロジェクト: tooever/JumpBall
bool SceneStart::init()
{
	//CCSprite* sprite = CCSprite::create(SceneStartBg);
	//sprite->setPosition(ccp(winSize.width/2, winSize.height/2));
	//addChild(sprite);
	CCMenuItemImage* menuItemStart = CCMenuItemImage::create("startgame.png", "startgame.png", this, menu_selector(SceneStart::menuStart));
	CCMenuItemImage* menuItemQuit = CCMenuItemImage::create("quitgame.png", "quitgame.png", this, menu_selector(SceneStart::menuQuit));
	CCMenu* menu = CCMenu::create(menuItemStart, menuItemQuit, NULL);
	addChild(menu);
	menu->alignItemsVertically();
	return true;
}
コード例 #22
0
ファイル: MenuTest.cpp プロジェクト: 0309/cocos2d-x
// BugsTest
BugsTest::BugsTest()
{
    CCMenuItemFont *issue1410 = CCMenuItemFont::create("Issue 1410", this, menu_selector(BugsTest::issue1410MenuCallback));
    CCMenuItemFont *issue1410_2 = CCMenuItemFont::create("Issue 1410 #2", this, menu_selector(BugsTest::issue1410v2MenuCallback));
    CCMenuItemFont *back = CCMenuItemFont::create("Back", this, menu_selector(BugsTest::backMenuCallback));
    
    CCMenu *menu = CCMenu::create(issue1410, issue1410_2, back, NULL);
    addChild(menu);
    menu->alignItemsVertically();
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    menu->setPosition(ccp(s.width/2, s.height/2));
}
コード例 #23
0
ファイル: CCLobbyView.cpp プロジェクト: kaznog/t09
bool CCLobbyView::initTopMenu()
{
    CCDirector* director = CCDirector::sharedDirector();
    const CCSize winSize = director->getWinSize();
    const CCSize mySize = this->getContentSize();
    const CCPoint center = ccpMult( ccpFromSize( mySize ), 0.5f );
    
    CCLabelTTF* consoleLabel = CCLabelTTF::create( "disconnected", "Arial", FONT_SIZE(24), CCSizeMake( winSize.width, FONT_SIZE(24) ), kCCTextAlignmentCenter );
    consoleLabel->setColor( ccc3(255, 255, 255) );
    CCMenuItemLabel* consoleItem = CCMenuItemLabel::create( consoleLabel );
    
    // bottom
    const CCSize editSize = CCSizeMake( winSize.width, FONT_SIZE(48) );
    CCMenuItem* editItem = CCMenuItem::create();
    editItem->setContentSize( editSize );
    
    CCMenu* topMenu = CCMenu::create( consoleItem, editItem, NULL );
    if( topMenu )
    {
        this->setConsole( consoleLabel );
        
        topMenu->alignItemsVertically();
        topMenu->setPosition( CCPointMake( center.x, winSize.height - (editItem->getContentSize().height + consoleItem->getContentSize().height)/2 ) );
        this->addChild( topMenu, 0, Child::CCMenu_topMenu );
        
        const CCPoint editItemPosition = editItem->getParent()->convertToWorldSpace( editItem->getPosition() );
        editItem->setContentSize( winSize );
        editItem->ignoreAnchorPointForPosition( false );
        editItem->setAnchorPoint( ccp( 0.5f, (winSize.height / (editItemPosition.y - winSize.height)) * 0.5f ) );
        
        CCScale9Sprite* editSprite = CCScale9Sprite::create("extensions/yellow_edit.png");
        CCEditBox* edit = CCEditBox::create( editSize, editSprite );
        edit->setPlaceHolder("PlayerName");
        edit->setReturnType(kKeyboardReturnTypeDone);
        edit->setFontColor(ccGRAY);
        edit->setMaxLength( 20 );
        edit->setDelegate(this);
        edit->setTouchEnabled( true );
        edit->setPosition( editItemPosition );
        CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
        JString userName = network->getUserName();
        edit->setText(userName.UTF8Representation().cstr());
        this->addChild( edit );
        this->setEditName(edit);
    }
    
    return topMenu;
}
コード例 #24
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
	
    if ( !CCLayer::init() )
    {
        return false;
    }
#if ENABLE_PHYSICS_BOX2D_DETECT

    //create menu and it's button

	CCMenuItemFont* start = CCMenuItemFont::create("Start Game",this,menu_selector(HelloWorld::menuStartGameCallback));
	CCMenuItemFont* next = CCMenuItemFont::create("Next Stage",this,menu_selector(HelloWorld::menuStageTwoCallback));
	CCMenuItemFont* exit = CCMenuItemFont::create("Exit",this,menu_selector(HelloWorld::menuCloseCallback));

	CCMenu* menu = CCMenu::create(start,next,exit,NULL);
	menu->alignItemsVertically();

	this->addChild(menu,3);

    return true;
#else
	CCLabelTTF *pLabel = CCLabelTTF::create("Should define CC_ENABLE_BOX2D_INTEGRATION=1\n for more please read Readme",
                                            "Arial",
                                            18);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    pLabel->setPosition(ccp(size.width/2, size.height/2));
    
    addChild(pLabel);
	
	CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width*0.9 ,
                                CCDirector::sharedDirector()->getVisibleSize().height*0.1));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);
	return true;
#endif
}
コード例 #25
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    	bool bRet = false;
	do
	{
		CC_BREAK_IF(! CCLayer::init());

		// 用一个图片做画面的背景
		CCSprite *sp = CCSprite::create("bg.png");
		CC_BREAK_IF(! sp);
		sp->setAnchorPoint(CCPointZero);
		// 既然是背景,zOrder值尽量小。
		this->addChild(sp, 0, 1);

		// 设置菜单项字体
		CCMenuItemFont::setFontName("Marker Felt");
		CCMenuItemFont::setFontSize(25);

		// 逐一创建5个菜单项
		CCMenuItemFont *newGame = CCMenuItemFont::itemWithString("New Game", this, menu_selector(HelloWorld::onNewGame));
		CC_BREAK_IF(! newGame);
		CCMenuItemFont *loadGame = CCMenuItemFont::itemWithString("Load");
		CC_BREAK_IF(! loadGame);
		CCMenuItemFont *gameSettings = CCMenuItemFont::itemWithString("Option", this, menu_selector(HelloWorld::onSettings));
		CC_BREAK_IF(! gameSettings);
		CCMenuItemFont *help = CCMenuItemFont::itemWithString("Help");
		CC_BREAK_IF(! help);
		CCMenuItemFont *quit = CCMenuItemFont::itemWithString("Quit", this, menu_selector(HelloWorld::onQuit));
		CC_BREAK_IF(! quit);

		// 将这些菜单项都加入到菜单对象中
		CCMenu *menu = CCMenu::menuWithItems(newGame, loadGame, gameSettings, help, quit, NULL);
		CC_BREAK_IF(! menu);
		// 设置菜单以纵向布局显示
		menu->alignItemsVertically();
		// 最重要的是不要忘记把菜单加入主层对象,否则不会显示
		this->addChild(menu, 1, 2);

		bRet = true;
	} while (0);

	return bRet;
}
コード例 #26
0
ファイル: MenuScene.cpp プロジェクト: ClAndHHL/cocos3d-x
void CMenuLayer::createMenu()
{
	CCMenuItemFont::setFontSize( 32 );
	CCMenuItemFont::setFontName("Courier New");

	setTouchEnabled(true);

	// Font Item
	CCMenuItem* quit = CCMenuItemImage::create( "images/CloseNormal.png", "images/CloseSelected.png", this, menu_selector(CMenuLayer::onQuit) );
	CCMenu* menu = CCMenu::create( quit, NULL);
	menu->alignItemsVertically();

	addChild( menu );

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCSize itemSize = quit->getContentSize();

	menu->setPositionX( winSize.width - itemSize.width / 2 );
	menu->setPositionY( winSize.height - itemSize.height / 2 );
}
コード例 #27
0
ファイル: ControllPanel.cpp プロジェクト: david4750/ShootGame
void ControllPanel::createTurnBarrelButton()
{
	CCMenuItemImage *pTurnLeftItem = CCMenuItemImage::itemFromNormalImage(
		"actor_btn_turnLeft.png",
		"actor_btn_turnLeft.png",
		this,
		menu_selector(ControllPanel::barrelTurnLeftClick));

	CCMenuItemImage *pTurnRightItem = CCMenuItemImage::itemFromNormalImage(
		"actor_btn_turnRight.png",
		"actor_btn_turnRight.png",
		this,
		menu_selector(ControllPanel::barrelTurnRightClick));
	CCMenu *pTurnBarrelMenu = CCMenu::menuWithItems(pTurnLeftItem, pTurnRightItem, NULL);
	
	CCSize bgSize = this->m_pBg->getContentSize();
	pTurnBarrelMenu->alignItemsVertically();
	pTurnBarrelMenu->setPosition(ccp(100, bgSize.height / 2));
	this->addChild(pTurnBarrelMenu);
}
コード例 #28
0
KDbool Ch5_SwitchingScenes::init ( KDvoid )
{	
	if ( !Recipe::init ( ) )
	{
		return KD_FALSE;
	}

	// Font size/name
	CCMenuItemFont::setFontSize ( 30 );
	CCMenuItemFont::setFontName ( "Marker Felt.ttf" );

	// Go to our initial scene
	CCMenuItemFont*		pGoToScene1 = CCMenuItemFont::create ( "Go To Scene 1", this, menu_selector ( Ch5_SwitchingScenes::goToScene1 ) );
	CCMenu*				pMenu = CCMenu::create ( pGoToScene1, KD_NULL );
	pMenu->setPosition ( ccp ( 240, 160 ) );
	pMenu->alignItemsVertically ( );
	this->addChild ( pMenu );

	return KD_TRUE;
}
コード例 #29
0
ファイル: MenuTest.cpp プロジェクト: 0309/cocos2d-x
RemoveMenuItemWhenMove::RemoveMenuItemWhenMove()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF* label = CCLabelTTF::create("click item and move, should not crash", "Arial", 20);
    label->setPosition(ccp(s.width/2, s.height - 30));
    addChild(label);
    
    item = CCMenuItemFont::create("item 1");
    item->retain();
    
    CCMenuItemFont *back = CCMenuItemFont::create("go back", this, menu_selector(RemoveMenuItemWhenMove::goBack));
    
    CCMenu *menu = CCMenu::create(item, back, NULL);
    addChild(menu);
    menu->alignItemsVertically();
    
    menu->setPosition(ccp(s.width/2, s.height/2));
    
    setTouchEnabled(true);
}
コード例 #30
0
ファイル: SceneTest.cpp プロジェクト: HongXiao/Client-source
SceneTestLayer1::SceneTestLayer1()
{
    CCMenuItemFont* item1 = CCMenuItemFont::create( "Test pushScene", this, menu_selector(SceneTestLayer1::onPushScene) );
    CCMenuItemFont* item2 = CCMenuItemFont::create( "Test pushScene w/transition", this, menu_selector(SceneTestLayer1::onPushSceneTran) );
    CCMenuItemFont* item3 = CCMenuItemFont::create( "Quit", this, menu_selector(SceneTestLayer1::onQuit) );
    
    CCMenu* menu = CCMenu::create( item1, item2, item3, NULL );
    menu->alignItemsVertically();
    
    addChild( menu );
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCSprite* sprite = CCSprite::create(s_pPathGrossini);
    addChild(sprite);
    sprite->setPosition( ccp(s.width-40, s.height/2) );
    CCActionInterval* rotate = CCRotateBy::create(2, 360);
    CCAction* repeat = CCRepeatForever::create(rotate);
    sprite->runAction(repeat);

    schedule( schedule_selector(SceneTestLayer1::testDealloc) );
}