Ejemplo n.º 1
0
bool Pause::init(){
	if (!CCLayer::init()) {
		return false;
	}
	SpriteWithText *pause = SpriteWithText::createWithSpriteFrameNamee("onButton.png","PAUSED",ccColor3B{0,0,0});
	SpriteWithText *mainMenuOn = SpriteWithText::createWithSpriteFrameNamee("onButton.png","MENU",ccColor3B{0,0,0});
	SpriteWithText *mainMenuOff = SpriteWithText::createWithSpriteFrameNamee("offButton.png","MENU",ccColor3B{0,0,0});
	CCSprite *resumeOn = CCSprite::createWithSpriteFrameName("onPaused.png");
	CCSprite *resumeOff = CCSprite::createWithSpriteFrameName("offPaused.png");
	CCSprite *goBackOn = CCSprite::createWithSpriteFrameName("goBackOn.png");
	CCSprite *goBackOff = CCSprite::createWithSpriteFrameName("goBackOff.png");
	CCMenuItemSprite *restartBtn = CCMenuItemSprite::create(goBackOn, goBackOff, this, menu_selector(Pause::restartGame));
	CCMenuItemSprite *resumeBtn = CCMenuItemSprite::create(resumeOn,resumeOff,this,menu_selector(Pause::toggle));
	CCMenuItemSprite *mainMenuBtn = CCMenuItemSprite::create(mainMenuOn,mainMenuOff,this,menu_selector(Pause::goToMainMenu));
	Utils::scaleButton(restartBtn,2.1f);
	Utils::scaleButton(resumeBtn,2.1);
	Utils::scaleButton(mainMenuBtn,1.7);
	Utils::scaleSprite(pause,1.1,1,true);
	CCMenu *menuContinue = CCMenu::create(restartBtn,resumeBtn,NULL);
	menuContinue->alignItemsHorizontally();
	CCMenu *menuMainMenu = CCMenu::create(mainMenuBtn,NULL);
	pause->setPosition(Utils::getCorrectPosition(0.5,0.8));
	menuContinue->setPosition(Utils::getCorrectPosition(0.5,0.5));
	menuMainMenu->setPosition(Utils::getCorrectPosition(0.5,0.26));
	paused = false;
	anim = Animated::create();
	anim->addChild(menuMainMenu);
	anim->addChild(menuContinue);
	anim->addChild(pause);
	anim->setPosition(Utils::getCorrectPosition(0,1));
	anim->initAnim(0,0,1,0,0.2f,0,0.2f,0,0,0);
	this->addChild(anim);
	return true;
}
Ejemplo n.º 2
0
SlotEffectTest::SlotEffectTest()
{
	int startX = 10;
	int startY = 500;
	int gap = 5;
	int index = 1;
	for (int i = 1; i <=15; i++)
	{
		CCSprite* spt = CCSprite::create("effect/a1.png");
		spt->setPositionX((startX + gap + spt->getContentSize().height) * index);
		spt->setPositionY(startY);
		this->addChild(spt);
		spt->setTag(i);
		index++;
		if (i % 5 == 0)
		{
			index = 1;
			startY -= spt->getContentSize().height + gap;
		}
	}
	SlotEffect* se = SlotEffect::create(1, 15, 1, 50, 100);
	se->setTag(100);
	this->addChild(se);
	se->addEventListener(this, callfunc_selector(SlotEffectTest::selectSpt));

	CCMenuItemLabel* randomItem = CCMenuItemLabel::create(CCLabelTTF::create("randomBtn", "Arial", 30), this, menu_selector(SlotEffectTest::randomClick));
	CCMenuItemLabel* item = CCMenuItemLabel::create(CCLabelTTF::create("startBtn", "Arial", 30), this, menu_selector(SlotEffectTest::itemClick));
	CCMenu* menu = CCMenu::create(randomItem, item, NULL);
	menu->setPosition(ccp(400, 100));
	this->addChild(menu);
	menu->alignItemsHorizontally();
}
Ejemplo n.º 3
0
bool RS_Main::CreateMenu()
{
    bool bRet = false;

    do
    {
        s = CCDirector::sharedDirector()->getWinSize();

        // 뒤로가기 버튼
        CCMenuItemImage* pBackItem = CCMenuItemImage::create("common/back_btn_2.png", "common/back_pressed_btn_2.png", this, menu_selector(RS_Main::menuClickCallback));
        pBackItem->setTag(1);

        // 다시하기 버튼
        CCMenuItemImage* pRetryItem = CCMenuItemImage::create("common/again_btn_2.png", "common/again_pressed_btn_2.png", this, menu_selector(RS_Main::menuClickCallback));
        pRetryItem->setTag(2);

        CCMenu* pMenu = CCMenu::create();
        pMenu->addChild(pBackItem);
        pMenu->addChild(pRetryItem);
        pMenu->setPosition(ccp(19 + pBackItem->getContentSize().width , s.height - 40));
        pMenu->alignItemsHorizontally();
        this->addChild(pMenu, 100);

        bRet = true;
    } while(0);

    return bRet;
}
Ejemplo n.º 4
0
bool LoadGameLayer::init(void)
{
	bool bRet = false;
	do
	{
		CC_BREAK_IF(! CCLayer::init());

		CCMenuItemFont *back = CCMenuItemFont::create("Go back",this, menu_selector(LoadGameLayer::backCallback));
		CC_BREAK_IF(! back);
	
		CCMenu *menu = CCMenu::create(back, NULL);
		CC_BREAK_IF(! menu);	
		menu->alignItemsHorizontally();
		this->addChild(menu);

		// 手工微调一下最后一个菜单项的位置
		/*
		cocos2d::CCPoint cp_back = back->getPosition();
		cp_back.y -= 50.0f;
		back->setPosition(cp_back);
		*/

		bRet = true;
	} while (0);

	return bRet;
}
Ejemplo n.º 5
0
bool HomeScene::init()
{
	//init layer
	if ( !CCLayer::init() )	return false;

//----------------------------------------------------------------------------------------------------------------------------------------------------
//--add sprites: title, author, option, and begin
//----------------------------------------------------------------------------------------------------------------------------------------------------
	//get window size
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	//create author, set scale, set position
	CCSprite *author = CCSprite::create("author.png");
	author->setScaleX((3*winSize.width)/(author->getContentSize().width*8));
	author->setScaleY(winSize.height/(author->getContentSize().height*8));
	author->setPosition(ccp(winSize.width/2, (5*winSize.height)/8));
	this->addChild(author);

	//create title, set scale, set position, add title
	CCSprite *title = CCSprite::create("bb.png");
	title->setScaleX(winSize.width/title->getContentSize().width);
	title->setScaleY((winSize.height)/(title->getContentSize().height*4));
	title->setPosition(ccp(winSize.width/2, (13*winSize.height)/16));
	this->addChild(title);

	//create title, set scale
	CCSprite *option = CCSprite::create("options.png");
	option->setScaleX(winSize.width/(option->getContentSize().width*4));
	option->setScaleY(winSize.height/(option->getContentSize().height*4));

	//create title, set scale
	CCSprite *begin = CCSprite::create("begin.png");
	begin->setScaleX(winSize.width/(4*begin->getContentSize().width));
	begin->setScaleY(winSize.height/(4*begin->getContentSize().height));

//----------------------------------------------------------------------------------------------------------------------------------------------------
//--add menu items
//----------------------------------------------------------------------------------------------------------------------------------------------------

	//create the two items
	CCMenuItemSprite *pOptionItem = CCMenuItemSprite::create(option, option, this, menu_selector(HomeScene::menuOptionCallback));
	if(!pOptionItem) return false;
	CCMenuItemSprite *pBeginItem = CCMenuItemSprite::create(begin, begin, this, menu_selector(HomeScene::menuBeginCallback));
	if(!pBeginItem) return false;

	//create menu
	CCMenu* pMenu = CCMenu::create(pOptionItem, pBeginItem, NULL);
	if(!pMenu) return false;

	//setup positioning
	pMenu->setPosition(ccp(9*winSize.width/16, 3*winSize.height/8));
	pMenu->alignItemsHorizontally();

	//add menu item as layer
	this->addChild(pMenu, 1);


	return true;
}
Ejemplo n.º 6
0
// on "init" you need to initialize your instance
bool CurlTest::init() {
    if ( !CCLayerColor::initWithColor(ccc4(255,255,255,255)) )
    {
        return false;
    }

    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    CCMenuItemImage *send = CCMenuItemImage::create(
                                "send.png",
                                "connect.png",
                                this,
                                menu_selector(CurlTest::send));
    CCMenuItemImage *recv = CCMenuItemImage::create(
                                "recv.png",
                                "wait.png",
                                this,
                                menu_selector(CurlTest::recv));

    CCMenu* pMenu = CCMenu::create();
    pMenu->addChild(send);
    pMenu->addChild(recv);
    pMenu->setPosition(ccp(origin.x + visibleSize.width/2 ,
                           origin.y + recv->getContentSize().height));
    pMenu->alignItemsHorizontally();

    notify = "";
    pLabel = CCLabelTTF::create(notify, "Arial", TITLE_FONT_SIZE);
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height/2));

    pTextField = CCTextFieldTTF::textFieldWithPlaceHolder("<enter your friend's IP>",
                 "Arial",
                 TITLE_FONT_SIZE);
    pTextField->setPosition(ccp(origin.x + visibleSize.width/2,
                                origin.y + visibleSize.height - 2*pTextField->getContentSize().height));

    this->addChild(pMenu);
    this->addChild(pLabel);
    this->addChild(pTextField);
    this->setTouchEnabled(true);

    peer = NULL;
    playLayer = NULL;
    viewLayer = NULL;
    initServer();
    return true;
}
////////////////////////////////////////////////////////
//
// NodeChildrenMainScene
//
////////////////////////////////////////////////////////
void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
{
    //srand(time());
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    // Title
    CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
    addChild(label, 1);
    label->setPosition(ccp(s.width/2, s.height-32));
    label->setColor(ccc3(255,255,40));

    // Subtitle
    std::string strSubTitle = subtitle();
    if(strSubTitle.length())
    {
        CCLabelTTF *l = CCLabelTTF::create(strSubTitle.c_str(), "Thonburi", 16);
        addChild(l, 1);
        l->setPosition(ccp(s.width/2, s.height-80));
    }

    lastRenderedCount = 0;
    currentQuantityOfNodes = 0;
    quantityOfNodes = nNodes;

    CCMenuItemFont::setFontSize(65);
    CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(NodeChildrenMainScene::onDecrease));
    decrease->setColor(ccc3(0,200,20));
    CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(NodeChildrenMainScene::onIncrease));
    increase->setColor(ccc3(0,200,20));

    CCMenu *menu = CCMenu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(ccp(s.width/2, s.height/2+15));
    addChild(menu, 1);

    CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
    infoLabel->setColor(ccc3(0,200,20));
    infoLabel->setPosition(ccp(s.width/2, s.height/2-15));
    addChild(infoLabel, 1, kTagInfoLayer);

    NodeChildrenMenuLayer* pMenu = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase);
    addChild(pMenu);
    pMenu->release();

    updateQuantityLabel();
    updateQuantityOfNodes();
}
Ejemplo n.º 8
0
void HUDLayer::initHUD()
{
		//Create pause menu sprite
		CCMenuItemFont* pauseItem = CCMenuItemFont::create("Pause", this, 
			menu_selector(PauseMenu::onPause));

		// combine to form a menu and allign Vertically
		CCMenu* menu = CCMenu::create(pauseItem, NULL);
		menu->alignItemsHorizontally();

		// set menu position
		menu->setPosition(SCREEN_WIDTH - 50, SCREEN_HEIGHT - 20);

		this->addChild(menu, 3);

		
}
Ejemplo n.º 9
0
bool WelcomeLayer::init()
{

	if (!CCLayer::init()) {
		return false;
	}




	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();


	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("login.plist", "login.png");


	CCSprite* QQeButton = CCSprite::createWithSpriteFrameName(
		"qq.png");
	CCSprite* WeixinButton = CCSprite::createWithSpriteFrameName(
		"weixin.png");
	CCSprite* playQQ = CCSprite::createWithSpriteFrameName("23.png");
	QQeButton->setScaleX(1.5f);
	QQeButton->setScaleY(0.5f);
	WeixinButton->setScaleX(1.5f);
	WeixinButton->setScaleY(0.5f);
	SEL_MenuHandler QQselect= (SEL_MenuHandler)menu_selector(WelcomeLayer::toGame);
	SEL_MenuHandler Weixinselect= (SEL_MenuHandler)menu_selector(WelcomeLayer::toGame);
	CCMenuItemSprite* QQMenu = CCMenuItemSprite::create(QQeButton,
		QQeButton, QQeButton, this,
		QQselect );
	CCMenuItemSprite* WeixinMenu = CCMenuItemSprite::create(WeixinButton,
		WeixinButton, WeixinButton, this,
		Weixinselect );
	CCMenu* menu = CCMenu::create(QQMenu, WeixinMenu,
		NULL);
	menu->alignItemsHorizontally();
	this->addChild(menu, 1);
	menu->setPosition(ccp(origin.x + visibleSize.width/2,
		origin.y + visibleSize.height/2));
	return true;
}
Ejemplo n.º 10
0
bool SP_Main::createMenu()
{
	bool bRet = false;

	do
	{
		s = CCDirector::sharedDirector()->getWinSize();

		// 뒤로가기 버튼
		CCMenuItemImage* pBackItem = CCMenuItemImage::create("common/back_btn_2.png", "common/back_pressed_btn_2.png", this, menu_selector(SP_Main::menuClickCallback));
		pBackItem->setTag(1);

		// 다시하기 버튼
		CCMenuItemImage* pRetryItem = CCMenuItemImage::create("common/again_btn_2.png", "common/again_pressed_btn_2.png", this, menu_selector(SP_Main::menuClickCallback));
		pRetryItem->setTag(2);

		CCMenu* pMenu = CCMenu::create();
		pMenu->addChild(pBackItem);
		pMenu->addChild(pRetryItem);
		pMenu->setPosition(ccp(19 + pBackItem->getContentSize().width , s.height - 40));
		pMenu->alignItemsHorizontally();
		this->addChild(pMenu, 100);


		// 숫자, 알파벳 보기
		m_pShowNItem = CCMenuItemImage::create("common/game/sliding/number_btn.png", "common/game/sliding/number_btn_pressed.png", this, menu_selector(SP_Main::menuShow));
		m_pShowAItem = CCMenuItemImage::create("common/game/sliding/alphabet_btn.png", "common/game/sliding/alphabet_btn_pressed.png", this, menu_selector(SP_Main::menuShow));
		m_pShowNItem->setTag(0);
		m_pShowAItem->setTag(1);	

		CCMenu* pMenuShow = CCMenu::create();
		pMenuShow->addChild(m_pShowNItem);
		pMenuShow->addChild(m_pShowAItem);
		pMenuShow->alignItemsHorizontallyWithPadding(5);
		pMenuShow->setPosition(SHOWMENU_XY);
		this->addChild(pMenuShow, 1);

		bRet = true;
	} while(0);

	return bRet;
}
Ejemplo n.º 11
0
void TestPerformance::onEnter()
{
    ArmatureTestLayer::onEnter();

    CCMenuItemFont::setFontSize(65);
    CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(TestPerformance::onDecrease));
    decrease->setColor(ccc3(0,200,20));
    CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(TestPerformance::onIncrease));
    increase->setColor(ccc3(0,200,20));

    CCMenu *menu = CCMenu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(ccp(VisibleRect::getVisibleRect().size.width/2, VisibleRect::getVisibleRect().size.height-100));
    addChild(menu, 10000);

    armatureCount = frames = times = lastTimes = 0;
    generated = false;

    scheduleUpdate();

    addArmature(100);
}
Ejemplo n.º 12
0
//------------------------------------------------------------------
//
// TextureMemoryAlloc
//
//------------------------------------------------------------------
void TextureMemoryAlloc::onEnter()
{
    TextureDemo::onEnter();
    m_pBackground = NULL;
    
    CCMenuItemFont::setFontSize(24);
    
    CCMenuItem *item1 = CCMenuItemFont::create("PNG", this, menu_selector(TextureMemoryAlloc::updateImage));
    item1->setTag(0);
    
    CCMenuItem *item2 = CCMenuItemFont::create("RGBA8", this, menu_selector(TextureMemoryAlloc::updateImage));
    item2->setTag(1);
    
    CCMenuItem *item3 = CCMenuItemFont::create("RGB8", this, menu_selector(TextureMemoryAlloc::updateImage));
    item3->setTag(2);
    
    CCMenuItem *item4 = CCMenuItemFont::create("RGBA4", this, menu_selector(TextureMemoryAlloc::updateImage));
    item4->setTag(3);
    
    CCMenuItem *item5 = CCMenuItemFont::create("A8", this, menu_selector(TextureMemoryAlloc::updateImage));
    item5->setTag(4);
    
    CCMenu *menu = CCMenu::create(item1, item2, item3, item4, item5, NULL);
    menu->alignItemsHorizontally();
    
    addChild(menu);
    
    CCMenuItemFont *warmup = CCMenuItemFont::create("warm up texture", this, menu_selector(TextureMemoryAlloc::changeBackgroundVisible));
    
    CCMenu *menu2 = CCMenu::create(warmup, NULL);

    menu2->alignItemsHorizontally();
    
    addChild(menu2);
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    menu2->setPosition(ccp(s.width/2, s.height/4));
}
Ejemplo n.º 13
0
void MenuLayer2::alignMenusH()
{
	for(int i=0;i<2;i++) 
	{
		CCMenu *menu = (CCMenu*)getChildByTag(100+i);
		menu->setPosition( m_centeredMenu );
		if(i==0) 
		{
			// TIP: if no padding, padding = 5
			menu->alignItemsHorizontally();			
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpAdd(p, CGPointMake(0,30)) );
			
		} 
		else 
		{
			// TIP: but padding is configurable
			menu->alignItemsHorizontallyWithPadding(40);
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpSub(p, CGPointMake(0,30)) );
		}		
	}
}
Ejemplo n.º 14
0
KDbool Controller::init ( KDvoid )
{
	g_pController = this;

	CCLayer::init ( );

	const CCSize&  tSize = CCDirector::sharedDirector ( )->getWinSize ( );	

	CCMenu*  pMenu = CCMenu::create
	(
		CCMenuItemImage::create 
        (
            "image/btn_prev_0.png"	 , 
            "image/btn_prev_1.png"	 ,
            this, menu_selector ( Controller::onPrev ) 
        ),
		CCMenuItemImage::create 
        ( 
            "image/btn_restart_0.png", 
            "image/btn_restart_1.png", 
            this, menu_selector ( Controller::onRestart )
        ),
		CCMenuItemImage::create 
        (
            "image/btn_next_0.png"	 , 
            "image/btn_next_1.png"	 , 
            this, menu_selector ( Controller::onNext ) 
        ),				
		KD_NULL
	);
	do
	{
		CC_BREAK_IF ( !pMenu );

		pMenu->setPosition ( ccp ( tSize.cx / 2, 35 ) );
		pMenu->alignItemsHorizontally ( 50 );

		this->addChild ( pMenu );

	} while ( 0 );	

	m_pTitle = CCLabelTTF::create ( "", "font/Schwarzwald Regular.ttf", 34, CCSize ( tSize.cx - 20.f, 0 ), kCCTextAlignmentCenter );
	do
	{
		CC_BREAK_IF ( !m_pTitle );

		m_pTitle->setPosition ( ccp ( tSize.cx / 2, tSize.cy - 50 ) );
		m_pTitle->setColor ( ccGREEN );

		this->addChild ( m_pTitle );
		
	} while ( 0 );	

	m_pSubTitle = CCLabelTTF::create ( "", "font/arial.ttf", 26, CCSize ( tSize.cx - 20.f, 0 ), kCCTextAlignmentCenter );
	do
	{
		CC_BREAK_IF ( !m_pSubTitle );

		m_pSubTitle->setPosition ( ccp ( tSize.cx / 2, tSize.cy - 100 ) );
		m_pSubTitle->setColor ( ccYELLOW );

		this->addChild ( m_pSubTitle );

	} while ( 0 );	

	m_pMessage = CCLabelTTF::create ( "", "font/arial.ttf", 14, CCSize ( tSize.cx - 20.f, 190 ), kCCTextAlignmentLeft );
	do
	{
		CC_BREAK_IF ( !m_pMessage );

		m_pMessage->setAnchorPoint ( ccp ( 0, 0 ) );
		m_pMessage->setPosition ( ccp ( 10.f, 60.f ) );
		m_pMessage->setColor ( ccRED );

		this->addChild ( m_pMessage );
		
	} while ( 0 );	

    setShaderProgram ( CCShaderCache::sharedShaderCache ( )->programForKey ( kCCShader_PositionTexture ) );
    
	glGenTextures     ( 1, &m_uTexture );
	ccGLBindTexture2D ( m_uTexture );
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );	

	m_nIndex    = 0;
	m_pDrawFunc = KD_NULL;
	m_pExitFunc = KD_NULL;

	setExample ( 0 );

	return KD_TRUE;
}
bool CSettingCharacterLayer::init()
{
	if ( !CCLayer::init() )
	{
		return false;
	}

	// Get Window Size
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); 

	// CCMenu
	// 조심해! 일단 init에 넣고 모듈화는 좀 있다가..
	CCMenu *CharacterSelectTable = CCMenu::createWithItems(NULL, NULL);

	// make Image Buttons
	CCMenuItemImage *pCharacter1 = CCMenuItemImage::create(
		"image/PLAYER_1_face.png",
		"image/PLAYER_1_selected_face.png",
		this,
		menu_selector(CSettingCharacterLayer::SelectCharacterCallBack)
		);

	CCMenuItemImage *pCharacter2 = CCMenuItemImage::create(
		"image/PLAYER_2_face.png",
		"image/PLAYER_2_selected_face.png",
		this,
		menu_selector(CSettingCharacterLayer::SelectCharacterCallBack)
		);

	CCMenuItemImage *pCharacter3 = CCMenuItemImage::create(
		"image/PLAYER_3_face.png",
		"image/PLAYER_3_selected_face.png",
		this,
		menu_selector(CSettingCharacterLayer::SelectCharacterCallBack)
		);

	CCMenuItemImage *pCharacter4 = CCMenuItemImage::create(
		"image/PLAYER_4_face.png",
		"image/PLAYER_4_selected_face.png",
		this,
		menu_selector(CSettingCharacterLayer::SelectCharacterCallBack)
		);

	// set Tag : 어떤 캐릭터가 선택됐는지 확인해야 하므로
	pCharacter1->setTag(0);
	pCharacter2->setTag(1);
	pCharacter3->setTag(2);
	pCharacter4->setTag(3);

	// add Child
	CharacterSelectTable->addChild(pCharacter1, 2);
	CharacterSelectTable->addChild(pCharacter2, 2);
	CharacterSelectTable->addChild(pCharacter3, 2);
	CharacterSelectTable->addChild(pCharacter4, 2);

	// set Position
	CharacterSelectTable->setPosition(visibleSize.width / 2, visibleSize.height / 2);
	CharacterSelectTable->alignItemsHorizontally();

	// add to class Character Select menu
	this->addChild(CharacterSelectTable);

	return true;
}
Ejemplo n.º 16
0
////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
    //srandom(0);

    subtestNumber = asubtest;
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    lastRenderedCount = 0;
    quantityParticles = particles;

    CCMenuItemFont::setFontSize(65);
    CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(ParticleMainScene::onDecrease));
    decrease->setColor(ccc3(0,200,20));
    CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(ParticleMainScene::onIncrease));
    increase->setColor(ccc3(0,200,20));

    CCMenu *menu = CCMenu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(ccp(s.width/2, s.height/2+15));
    addChild(menu, 1);

    CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
    infoLabel->setColor(ccc3(0,200,20));
    infoLabel->setPosition(ccp(s.width/2, s.height - 90));
    addChild(infoLabel, 1, kTagInfoLayer);

    // particles on stage
    CCLabelAtlas *labelAtlas = CCLabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
    addChild(labelAtlas, 0, kTagLabelAtlas);
    labelAtlas->setPosition(ccp(s.width-66,50));

    // Next Prev Test
    ParticleMenuLayer* pMenu = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
    addChild(pMenu, 1, kTagMenuLayer);
    pMenu->release();

    // Sub Tests
    CCMenuItemFont::setFontSize(40);
    CCMenu* pSubMenu = CCMenu::create();
    for (int i = 1; i <= 6; ++i)
    {
        char str[10] = {0};
        sprintf(str, "%d ", i);
        CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(ParticleMainScene::testNCallback));
        itemFont->setTag(i);
        pSubMenu->addChild(itemFont, 10);

        if (i <= 3)
        {
            itemFont->setColor(ccc3(200,20,20));
        }
        else
        {
            itemFont->setColor(ccc3(0,200,20));
        }
    }
    pSubMenu->alignItemsHorizontally();
    pSubMenu->setPosition(ccp(s.width/2, 80));
    addChild(pSubMenu, 2);

    CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
    addChild(label, 1);
    label->setPosition(ccp(s.width/2, s.height-32));
    label->setColor(ccc3(255,255,40));

    updateQuantityLabel();
    createParticleSystem();

    schedule(schedule_selector(ParticleMainScene::step));
}
Ejemplo n.º 17
0
////////////////////////////////////////////////////////
//
// SpriteMainScene
//
////////////////////////////////////////////////////////
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
{
    //srandom(0);

    subtestNumber = asubtest;
    m_pSubTest = new SubTest;
    m_pSubTest->initWithSubTest(asubtest, this);

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

    lastRenderedCount = 0;
    quantityNodes = 0;

    CCMenuItemFont::setFontSize(65);
    CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(SpriteMainScene::onDecrease));
    decrease->setColor(ccc3(0,200,20));
    CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(SpriteMainScene::onIncrease));
    increase->setColor(ccc3(0,200,20));

    CCMenu *menu = CCMenu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(ccp(s.width/2, s.height-65));
    addChild(menu, 1);

    CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
    infoLabel->setColor(ccc3(0,200,20));
    infoLabel->setPosition(ccp(s.width/2, s.height-90));
    addChild(infoLabel, 1, kTagInfoLayer);

    // add menu
    SpriteMenuLayer* pMenu = new SpriteMenuLayer(true, TEST_COUNT, s_nSpriteCurCase);
    addChild(pMenu, 1, kTagMenuLayer);
    pMenu->release();

    // Sub Tests
    CCMenuItemFont::setFontSize(32);
    CCMenu* pSubMenu = CCMenu::create();
    for (int i = 1; i <= 9; ++i)
    {
        char str[10] = {0};
        sprintf(str, "%d ", i);
        CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(SpriteMainScene::testNCallback));
        itemFont->setTag(i);
        pSubMenu->addChild(itemFont, 10);

        if( i<= 3)
            itemFont->setColor(ccc3(200,20,20));
        else if(i <= 6)
            itemFont->setColor(ccc3(0,200,20));
        else
            itemFont->setColor(ccc3(0,20,200));
    }

    pSubMenu->alignItemsHorizontally();
    pSubMenu->setPosition(ccp(s.width/2, 80));
    addChild(pSubMenu, 2);

    // add title label
    CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
    addChild(label, 1);
    label->setPosition(ccp(s.width/2, s.height-32));
    label->setColor(ccc3(255,255,40));

    while(quantityNodes < nNodes)
        onIncrease(this);
}
Ejemplo n.º 18
0
void LayerLogin::zhenping(){
    
    
    pSpriteDialogLogin = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_input.png"));//CCSprite::create("login_bg_en.png");
    pSpriteDialogLogin->setPosition(ccp(winSize.width*0.5,winSize.height *0.5-100));
    this->addChild(pSpriteDialogLogin);
    
    
      
    
    
    CCMenuItemImage* btn_login = CCMenuItemImage::create();
    btn_login->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_login_1.png"));
    btn_login->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_login_2.png"));
    btn_login->setTarget(this, SEL_MenuHandler(&LayerLogin::menuItemCallbackLogin));
    
    CCMenu *pMenu = CCMenu::create();
    pMenu->alignItemsHorizontally();
    pMenu->addChild(btn_login);
    //pMenu->setPosition(pSpriteDialogLogin->getContentSize().width-75,pSpriteDialogLogin->getContentSize().height/2-10);
    pMenu->setPosition(ccp(winSize.width/2-30, winSize.height/2-460));
    pMenu->setTouchPriority(1);
    pSpriteDialogLogin->addChild(pMenu);
    
    
    CCScale9Sprite* editbkg = CCScale9Sprite::create();
    
    editBoxUsername = CCEditBox::create(CCSizeMake(210,50),editbkg);
    editBoxUsername->setReturnType(kKeyboardReturnTypeDone);
    //editBoxUsername->setFontSize(12);
    editBoxUsername->setText("");
    editBoxUsername->setFontColor(ccc3(158, 122, 83));
    editBoxUsername->setMaxLength(8);
    editBoxUsername->setPosition(ccp(winSize.width/2-10,96));//160,100
    pSpriteDialogLogin->addChild(editBoxUsername,2);
    
    CCScale9Sprite* editbkg1 = CCScale9Sprite::create();
    editBoxPassword = CCEditBox::create(CCSizeMake(185, 50),editbkg1);
    editBoxPassword->setReturnType(kKeyboardReturnTypeDone);
    editBoxPassword->setInputFlag(kEditBoxInputFlagPassword);
    editBoxPassword->setFontColor(ccc3(158, 122, 83));
    editBoxPassword->setMaxLength(8);
  //  editBoxPassword->setFontSize(12);
    editBoxPassword->setText("");
    editBoxPassword->setPosition(ccp(winSize.width/2-17,45));//160,60
    
    pSpriteDialogLogin->addChild(editBoxPassword,2);
    
//    CCSprite* bs = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("login_bs.png"));
//    bs->setPosition(ccp(pSpriteDialogLogin->getContentSize().width, 0));
//    pSpriteDialogLogin->addChild(bs);
//    logo->setAtlasIndex(0);
//    CCScene * f = CCDirector::sharedDirector()->getRunningScene();
//    CCPoint size =ccp(308, 756);
//    CCActionInterval * left1 = CCMoveTo::create(0.05,ccp(size.x+5,size.y));
//    CCActionInterval * right1 = CCMoveTo::create(0.05,ccp(size.x-5,size.y));
//    CCActionInterval * top1 = CCMoveTo::create(0.05,ccp(size.x,size.y+5));
//    CCActionInterval * rom1 = CCMoveTo::create(0.05,ccp(size.x,size.y-5));
//    CCFiniteTimeAction* action3 = CCSequence::create(left1,right1,top1,rom1,NULL);
//    f->getChildByTag(2807)->getChildByTag(9021)->runAction(CCRepeat::create(action3, 1));
}
Ejemplo n.º 19
0
void BaseScene::buildHeader(int highlightIndex, const char* title, const char* description)
{
    _currentMenuIndex = highlightIndex;
    
    CCMenuItemImage* homeButton = CCMenuItemImage::create();
    homeButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_nrl"));
    homeButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
    homeButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
    homeButton->setTarget(this, menu_selector(BaseScene::loadHomeScene));
    homeButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    CCMenuItemImage* fbActionButton = CCMenuItemImage::create();
    fbActionButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_nrl"));
    fbActionButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_prd"));
    fbActionButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_dis"));
    fbActionButton->setTarget(this, menu_selector(BaseScene::loadFBActionScene));
    fbActionButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    if (EziSocialObject::sharedObject()->isFacebookSessionActive() == false)
    {
        fbActionButton->setEnabled(false);
    }
    
    CCMenuItemImage* helpButton = CCMenuItemImage::create();
    helpButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_nrl"));
    helpButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
    helpButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
    helpButton->setTarget(this, menu_selector(BaseScene::loadHelpScene));
    
    helpButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    switch (highlightIndex)
    {
        case 0:
            homeButton->setEnabled(false);
            break;
            
        case 1:
            fbActionButton->setEnabled(false);
            break;
            
        case 2:
            helpButton->setEnabled(false);
            break;
            
        default:
            break;
    }
    
    
    CCMenu* homeMenu = CCMenu::create(homeButton, fbActionButton, helpButton, NULL);
    homeMenu->alignItemsHorizontally();
    
    this->addChild(homeMenu);
    PlaceNode(homeMenu, 0.88, 0.98);
    
    // Add a line.
    CCLayerColor* lineLayer = CCLayerColor::create(ccc4(204, 204, 204, 204),
                                                   CCDirector::sharedDirector()->getVisibleSize().width,
                                                   1.0 * AppDelegate::SCREEN_SCALE_FACTOR);
    
    this->addChild(lineLayer);
    PlaceNode(lineLayer, 0.0, 0.8);
    lineLayer->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height - (7 * AppDelegate::SCREEN_SCALE_FACTOR));
    
    // Add Title
    CCLabelTTF* titleLabel = CCLabelTTF::create(title, "Arial", 50.0 * AppDelegate::SCREEN_SCALE_FACTOR);
    this->addChild(titleLabel);
    titleLabel->setAnchorPoint(ccp(0.0f, 0.0f));
    //PlaceNode(titleLabel, 0.02, 0.98);
    
    CCLabelTTF* descriptionLabel = CCLabelTTF::create(description,
                                                      "Arial", SCALED_VALUE(22.0f));
    this->addChild(descriptionLabel);
    descriptionLabel->setAnchorPoint(ccp(0.0f, 0.0f));
    PlaceNode(descriptionLabel, 0.02, 0.98);
    descriptionLabel->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height);
    descriptionLabel->setColor(ccc3(204, 204, 204));
    
    titleLabel->cocos2d::CCNode::setPosition(descriptionLabel->getPositionX(),
                                             descriptionLabel->getPositionY() + descriptionLabel->getContentSize().height - 2.0f);
    
}