Exemple #1
0
bool GameUI::initWithController(GameScene* controller, int chapter, int level) {
  {
    CCMenu* gameplay = CCMenu::node();
        
    {
      CCSprite* up = CCSprite::spriteWithSpriteFrameName("reset_button.png");
      CCSprite* down = CCSprite::spriteWithSpriteFrameName("reset_button_pressed.png");
      CCMenuItemSprite* restartButton = CCMenuItemSprite::itemFromNormalSprite(up, down, controller, menu_selector(GameScene::restartGame));    
      gameplay->addChild(restartButton, 0);
    }
    
    {
      CCSprite* up = CCSprite::spriteWithSpriteFrameName("pause_button.png");
      CCSprite* down = CCSprite::spriteWithSpriteFrameName("pause_button_pressed.png");
      CCMenuItemSprite* pauseButton = CCMenuItemSprite::itemFromNormalSprite(up, down, controller, menu_selector(GameScene::pauseGame));    
      gameplay->addChild(pauseButton, 0);
    }
    
    {
      BoostBar* boostBar = BoostBar::node();
      CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
      boostBar->setPosition(ccp(110, screenSize.height - 20));
      this->addChild(boostBar, boostBar->getZOrder(), TAG_BOOST);
    }
    
    {
      CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
      
      String levelString = String::withFormat("%d - %d", chapter + 1, level + 1);
      CCLabelBNFont* levelLabel = CCLabelBNFont::labelWithString(levelString.c_str(), "soupofjustice_24_white.fnt");
      levelLabel->setPosition(ccp(screenSize.width - 30, -10));
      addChild(levelLabel);
      
      CCDelayTime* delayIn = CCDelayTime::actionWithDuration(2);
      CCMoveBy* moveUp = CCMoveBy::actionWithDuration(0.4, ccp(0, 25));
      CCEaseBackOut* moveUpEase = CCEaseBackOut::actionWithAction(moveUp);
      
      CCFiniteTimeAction* sequence = CCSequence::actions(delayIn, moveUpEase, 0);
      levelLabel->runAction(sequence);
    }
    
    {
      CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
      gameplay->setPosition(ccp(screenSize.width - 50, screenSize.height - 20));
      gameplay->alignItemsHorizontallyWithPadding(-10);
      this->addChild(gameplay);
    }
  }
  
  return true;
}
Exemple #2
0
void MarketScene::initButton()
{
	CCMenuItemImage *pMenuItem = CCMenuItemImage::create(s_pMenuItemBack.charMapFile, s_pMenuItemBack.charMapFilePress, this, menu_selector(MarketScene::buttonCallback));
	if (NULL != pMenuItem)
	{
		pMenuItem->setAnchorPoint(ccp(1,1));
		pMenuItem->setPosition(SCREEN);
		pMenuItem->setTag(BTN_CLOSE);
	}
	CCMenu *pMenu = CCMenu::create(pMenuItem, NULL);
	if (NULL != pMenu)
	{
		pMenu->setPosition(CCPointZero);
		addChild(pMenu);
		pMenu->setTag(TAG_MENU);
	}

	pMenuItem = CCMenuItemImage::create(s_pMenuItemBuy.charMapFile, s_pMenuItemBuy.charMapFilePress, s_pBuyDisable, this, menu_selector(MarketScene::buttonCallback));
	pMenuItem->setAnchorPoint(ccp(0.5f, 0.5f));
	pMenuItem->setPosition(ccp(CENTER.x, 120));
	pMenuItem->setTag(BTN_BUY);
	pMenu->addChild(pMenuItem);

	char szFileName[32] = { 0 };
	char szFileName2[32] = { 0 };
	char szFileName3[32] = { 0 };
	for (int i = 0; i < CARD_COUNT; i++)
	{
		sprintf(szFileName, s_pathCard.charMapFile, i);
		sprintf(szFileName2, s_pathCard.charMapFilePress, i);
		sprintf(szFileName3, s_pathCardDisable, i);

		CCMenuItemImage *pItem0 = CCMenuItemImage::create(szFileName, szFileName2, szFileName3);
		CCMenuItemImage *pItem1 = CCMenuItemImage::create(szFileName2, szFileName);
		CCMenuItemToggle *pToggle = CCMenuItemToggle::createWithTarget(this, menu_selector(MarketScene::buttonCallback), pItem0, pItem1, NULL);
		pToggle->setPosition(ccp(120 * i + s_pathCard.m_Position.x, s_pathCard.m_Position.y));
		pToggle->setTag(BTN_CARD + i);

		if (g_Control.cards[i] > 0)
		{
			CCSprite *sprite = CCSprite::create(s_pathCardbuy.m_strPath);
			sprite->setPosition(s_pathCardbuy.m_Position);
			pToggle->addChild(sprite, TAG_CARD_BUY, TAG_CARD_BUY);
		}

		pMenu->addChild(pToggle);
	}
	checkCard(BTN_CARD);
}
//-------------------------------------------------------------------------
// 其他逻辑初始化
void CShopTestScene::onLoadScene()
{
	setAutoRemoveUnusedTexture( true );

	// 根窗口,用来挂载显示物件
	{
		m_pRootWindow = FKCW_UIWidget_WidgetWindow::create();
		m_pRootWindow->setMultiTouchEnabled(true);
		this->addChild(m_pRootWindow);
	}
	
	// 返回按钮
	{
		CCMenu *pMenu = CCMenu::create();
		pMenu->setPosition(CCPointZero);
		addChild(pMenu);
		CCMenuItemImage* pBtn = CCMenuItemImage::create();
		CCSpriteFrame* pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("back_button_normal_e.png"); 
		pBtn->setNormalSpriteFrame(pFrame);
		pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("back_button_touch_e.png"); 
		pBtn->setSelectedSpriteFrame(pFrame);
		pBtn->setTarget(this, menu_selector(CShopTestScene::onClick));
		pBtn->setPosition(SCREEN_CENTER_POS + ccp(0,400));
		pMenu->addChild(pBtn);
	}
}
Exemple #4
0
bool testEffect::init(){
    if ( !CCLayer::init() ){return false;}
    
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("0.GeneralPart.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("MikuFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("SheldonFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("IronManFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LichKingFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("BladeMasterFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("FightGeneral.plist");
    
    ASBotFightLayer* aaa = ASBotFightLayer::createAsFightLayer(2, 4,true,1000,1,10000,6,10000,10);
    aaa->setPosition(CCPointZero);
    addChild(aaa,9999,9999);
    
    CCMenu* menu = CCMenu::create();
    for (int i = 1; i < 7 ; i++) {
        string tmp = "card_" + int2string(i) + ".png";
        CCSprite* repeatSprite = CCSprite::createWithSpriteFrameName(tmp.c_str());
        CCMenuItemSprite* repeat = CCMenuItemSprite::create(repeatSprite,repeatSprite,this,menu_selector(testEffect::Repeat));
        repeat->setScale(0.45);
        repeat->setPosition(ccp(size.width/7 + size.width*(i-1)/7,size.height/8));
        repeat->setTag(i);
        menu->addChild(repeat);
    }
    menu->setPosition(CCPointZero);
    addChild(menu,10000);

    return true;
}
// on "init" you need to initialize your instance
bool MissionLayer::init() {
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() ) {
        return false;
    }

    this->setKeypadEnabled(true);

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

    CCLabelTTF* title = CCLabelTTF::create("Mission", "Arial", 24);
	title->setPosition( ccp(size.width / 2, size.height - 20));
	this->addChild(title, 1);

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "b1.png",
                                        "b2.png",
                                        this,
                                        menu_selector(MissionLayer::menuBackCallback) );
    pCloseItem->setPosition( ccp(pCloseItem->getContentSize().width / 2 , 20) );

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);
    
    // add next menu
    CCMenuItemImage *pNextItem = CCMenuItemImage::create(
                                                          "f1.png",
                                                          "f2.png",
                                                          this,
                                                          menu_selector(MissionLayer::menuNextCallback) );
    pNextItem->setPosition( ccp(size.width - pNextItem->getContentSize().width / 2, 20) );
    
    // create menu, it's an autorelease object
    CCMenu* pNextMenu = CCMenu::create(pNextItem, NULL);
    pNextMenu->setPosition( CCPointZero );
    this->addChild(pNextMenu, 1);

    float step = 35;
    float yPos = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
        char buf[64];
		sprintf(buf, s_EventMenuItem[i].id.c_str(), missionid);
        
        CCLabelTTF* label = CCLabelTTF::create(buf, "Arial", 24);
        CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MissionLayer::eventMenuCallback));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
        yPos = size.height - step*i - 100;
        pMenuItem->setPosition( ccp(size.width / 2, yPos));
    }

    return true;
}
Exemple #6
0
bool BoxMenu::init()
{
    if(!CCLayer::init())
    {
        return false;
    }
	CCMenu *teamMenu;
	CCMenuItemFont::setFontName("΢ÈíÑźÚ");
	CCMenuItemFont::setFontSize(20);
	teamMenu = getBoxMenu();

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();	
	string gameTitle = GameTitleString;
	GBKToUTF8(gameTitle,"gbk","utf-8");
	CCMenuItemFont::setFontSize(26);
	CCMenuItemFont *titleItem = CCMenuItemFont::create(gameTitle.c_str(), this, menu_selector(BoxMenu::scoreSort));
	titleItem->setColor(ccc3(0xc3, 0xa8, 0x91));
	titleItem->setPosition(CCPointMake(0, winSize.height/2 - 30));
	teamMenu->addChild(titleItem);

	CCSprite *backgroudSprite = CCSprite::create(mainBackgroudFile);
	backgroudSprite->setPosition(CCPointMake(winSize.width/2, winSize.height/2));

	addChild(teamMenu, 0);
	addChild(backgroudSprite, -2);

    return true;
}
CCTableViewCell* MainLayerZhuangBeiBody::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCString *string = CCString::createWithFormat("%d", idx);
	CCTableViewCell *cell = NULL;  //table->dequeueCell();
	if (cell == NULL) 
	{
		cell = new CCTableViewCell();
		cell->autorelease();
	}
	else
	{
		cell->removeAllChildren();
	}
	//
	CCMenuItemImage *itemImage = CCMenuItemImage::create(
		itemFiles[idx].c_str()
		,itemFiles_select[idx].c_str()
		, this, SEL_MenuHandler(&MainLayerZhuangBeiBody::menuItemClicked));
	CCMenu* menu = CCMenu::create();
	cell->addChild(menu, 0, TAG_MENU);
	menu->setPosition(CCPointZero);
	menu->addChild(itemImage, 0, idx);
	itemImage->setPosition(ccp(itemImage->getContentSize().width/2, itemImage->getContentSize().height/2));


	return cell;
}
void NewsScene::createListView()
{
//    CCSize size = CCSize(750, 400);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
  
    CCLayerColor * fundo =  CCLayerColor::create(ccc4(255, 255, 255, 255), size.width, size.height);
    fundo->setAnchorPoint(ccp(0,0));
    fundo->setPosition(ccp(0, 0));
    this->addChild(fundo,10);
//    CCLayerColor * header =  CCLayerColor::create(ccc4(200, 200, 200, 255), size.width, 80);
//    header->setAnchorPoint(ccp(0,0));
//    header->setPosition(ccp(0, size.height -80));
//    fundo->addChild(header);
    
    CCSprite *sprHeader;
    sprHeader = CCSprite::create("Header_Blue.png");
    
    sprHeader->setAnchorPoint(ccp(0,0));
    sprHeader->setScale(1);
    sprHeader->setPosition(ccp(0, size.height -90));
    this->addChild(sprHeader,100);
    CCSprite *sprTitle;
    sprTitle = CCSprite::create("tit_informacoes.png");
    
    sprTitle->setAnchorPoint(ccp(0,0));
    sprTitle->setScale(1);
    sprTitle->setPosition(ccp(110, size.height -50));
    this->addChild(sprTitle,101);
    
    CCMenu* menu = CCMenu::create();
    
    CCSprite *spriteDefault = CCSprite::create("Seta1.png");
    CCSprite *spriteSelected = CCSprite::create("Seta2.png");
    CCMenuItemSprite *item = CCMenuItemSprite::create(spriteDefault, spriteSelected, this,  menu_selector(NewsScene::btnBack));
    item->setAnchorPoint(ccp(0, 0));
    item->setPosition(ccp(0, size.height -90));
    menu->addChild(item, 0, 100);
    menu->setPosition(ccp(10,30));
    menu->setAnchorPoint(ccp(0,0));
    this->addChild(menu,102);
    
    list = CCListView::create(CCListViewModeVertical);
    list = cocos2d::extension::CCListView::create(CCListViewModeVertical);
    list->setDelegate(this);
    list->setContentSize(CCSize(size.width, size.height-70));
    list->setAnchorPoint(ccp(0,0));
    list->setPosition(ccp(0, 0));
    list->setColor(ccc3(50, 50, 50));
    list->setSeparatorStyle(CCListViewCellSeparatorStyleNone);
    
    fundo->addChild(list);
    this->loading = new AnimatedSprite("loader_einstein1.png");
	this->loading->addAnimation(AnimatedSprite::animationWithFile("loader_einstein", 24, 0.030f), "anim");//frame_count
    
    this->addChild(this->loading,999);
    this->loading->runAnimation("anim",true, true);
	this->loading->setAnchorPoint(ccp(0.5f, 0.5f));
	this->loading->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height/2 - 30));
    this->loading->setVisible(true);
}
Exemple #9
0
LayerLevels::LayerLevels()
{
	CCPoint* offset = new CCPoint(180, 180);
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			CCMenuItemSprite* level = CCMenuItemSprite::create(
				CCSprite::createWithSpriteFrameName("btn_level1.png"), 
				CCSprite::createWithSpriteFrameName("btn_level2.png"), 
				this, menu_selector(LayerLevels::click_level));
			CCMenu* menu = CCMenu::createWithItem(level);
			menu->setPosition(CCDirector::sharedDirector()->convertToUI(
				ccp(offset->x + 200* i, offset->y + 85 * j)));
			this->addChild(menu);


			char str[64] = {0};
			sprintf(str, "%d", (j * 4 + i + 1));
			CCMenuItem* menuitem = new CCMenuItem();
			CCLabelTTF* text = CCLabelTTF::create(
				str, "Arial", 22);
			
			text->setColor(ccBLACK);
			menuitem->addChild(text);
			menu->addChild(menuitem);
		}
	}
}
Exemple #10
0
HttpClientTest::HttpClientTest() 
: m_labelStatusCode(NULL)
{
#if 0
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF *label = CCLabelTTF::create("Http Request Test", "Arial", 28);
    label->setPosition(ccp(winSize.width / 2, winSize.height - 50));
    addChild(label, 0);
    
    CCMenu *menuRequest = CCMenu::create();
    menuRequest->setPosition(CCPointZero);
    addChild(menuRequest);
    
    // Get 
    CCLabelTTF *labelGet = CCLabelTTF::create("Test Get", "Arial", 22);
    CCMenuItemLabel *itemGet = CCMenuItemLabel::create(labelGet, this, menu_selector(HttpClientTest::onMenuGetTestClicked));
    itemGet->setPosition(ccp(winSize.width / 2, winSize.height - 100));
    menuRequest->addChild(itemGet);
    
    // Post
    CCLabelTTF *labelPost = CCLabelTTF::create("Test Post", "Arial", 22);
    CCMenuItemLabel *itemPost = CCMenuItemLabel::create(labelPost, this, menu_selector(HttpClientTest::onMenuPostTestClicked));
    itemPost->setPosition(ccp(winSize.width / 2, winSize.height - 150));
    menuRequest->addChild(itemPost);
    
    // Post Binary
    CCLabelTTF *labelPostBinary = CCLabelTTF::create("Test Post Binary", "Arial", 22);
    CCMenuItemLabel *itemPostBinary = CCMenuItemLabel::create(labelPostBinary, this, menu_selector(HttpClientTest::onMenuPostBinaryTestClicked));
    itemPostBinary->setPosition(ccp(winSize.width / 2, winSize.height - 200));
    menuRequest->addChild(itemPostBinary);
    
    // Response Code Label
    m_labelStatusCode = CCLabelTTF::create("HTTP Status Code", "Marker Felt", 20);
    m_labelStatusCode->setPosition(ccp(winSize.width / 2,  winSize.height - 250));
    addChild(m_labelStatusCode);
    

    // Back Menu
    CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(HttpClientTest::toExtensionsMainLayer));
    itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
    CCMenu *menuBack = CCMenu::create(itemBack, NULL);
    menuBack->setPosition(CCPointZero);
    addChild(menuBack);
#endif
}
Exemple #11
0
bool GameReviveLayer::init()
{
	if(!CCLayer::init())
		return false;

	CCSize size = ToolsFun::sharedTools()->getSceneSize();
	CCSprite *bkgSprite = CCSprite::create("DayReward/bkg.png");
	this->addChild(bkgSprite, 3);
	bkgSprite->setPosition(size / 2);

	CCMenu *menu = CCMenu::create();
	menu->setPosition(CCPointZero);
	bkgSprite->addChild(menu, 1);

	CCSprite *closeNor = CCSprite::create("ui/shared/closeTipNml.png");
	CCSprite *closeSel = CCSprite::create("ui/shared/closeTipNml.png");
	closeSel->setColor(ccc3(80, 80, 80));
	CCMenuItemSprite *closeItem = CCMenuItemSprite::create(closeNor, closeSel, this, menu_selector(GameReviveLayer::close));
	closeItem->setPosition(ccp(bkgSprite->getContentSize().width * 5 / 6, bkgSprite->getContentSize().height * 6 / 7));
	menu->addChild(closeItem, 144);

	CCSprite *getNor = CCSprite::create("ui/shared/continueGame.png");
	CCSprite *getSel = CCSprite::create("ui/shared/continueGame.png");
	getSel->setColor(ccc3(80, 80, 80));
	CCMenuItemSprite *getItem = CCMenuItemSprite::create(getNor, getSel, this, menu_selector(GameReviveLayer::purchase));
	getItem->setPosition(ccp(bkgSprite->getContentSize().width / 2, 10*gScaleY));
	menu->addChild(getItem, 144);
	

	CCSprite *tip1 = CCSprite::create("DayReward/advanced.png");
	bkgSprite->addChild(tip1);
	tip1->setPosition(ccp(bkgSprite->getContentSize().width/2,bkgSprite->getContentSize().height/2-50*gScaleY));

	/*
	char buf[32];
	sprintf(buf,"%d",6);
	CCLabelTTF *label = CCLabelTTF::create(buf,"΢ÈíÑźÚ",38);
	getItem->addChild(label);
	label->setScale(0.6f);
	label->setColor(ccc3(220 ,220 ,220));
	label->setPosition(ccp(bkgSprite->getPositionX()/2,bkgSprite->getPositionY()/2 ));*/

	registerNDK();

	return true;
}
Exemple #12
0
void GameScene::gameOver(){
	removeChild(getChildByTag(99),true);
	unschedule(schedule_selector(GameScene::bgMove));
	CCLayerColor* ol = CCLayerColor::create(ccc4(0,0,0,150));
	addChild(ol,20);

	CCSprite* overBg = CCSprite::create("over_bg.png");
	SETANCHPOS(overBg,425,240,0.5,0.5);
	addChild(overBg,21);

	CCMenu* menu = CCMenu::create();
	SETANCHPOS(menu,425,240,0.5,0.5);
	addChild(menu,21);

	CCMenuItemSprite* retry = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("retry.png"),
		CCSprite::createWithSpriteFrameName("retry.png"),this,menu_selector(GameScene::btnCallback));
	SETANCHPOS(retry,-180,-110,0,0);
	retry->setTag(3);
	menu->addChild(retry);

	CCMenuItemSprite* play = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("play.png"),
		CCSprite::createWithSpriteFrameName("play.png"),this,menu_selector(GameScene::btnCallback));
	SETANCHPOS(play,80,-110,0,0);
	play->setTag(4);
	menu->addChild(play);

	CCSprite* dis = CCSprite::createWithSpriteFrameName("distance.png");
	SETANCHPOS(dis,350,300,0.5,0.5);
	addChild(dis,21);

	char v[20];
	sprintf(v,"%d",GameData::getDistance());
	CCLabelAtlas* disText =CCLabelAtlas::create(v,"num/num_yellow.png",28,40,'0');
	SETANCHPOS(disText,430,280,0,0);
	addChild(disText,21);

	CCSprite* best = CCSprite::createWithSpriteFrameName("best.png");
	SETANCHPOS(best,350,250,0.5,0.5);
	addChild(best,21);

	sprintf(v,"%d",GameData::getBest() > GameData::getDistance() ? GameData::getBest() : GameData::getDistance());
	CCLabelAtlas* bestText =CCLabelAtlas::create(v,"num/num_red.png",28,40,'0');
	SETANCHPOS(bestText,410,230,0,0);
	addChild(bestText,21);

}
Exemple #13
0
// on "init" you need to initialize your instance
bool AchievementLayer::init() {
	if (!CCLayerColor::initWithColor(ccc4(100, 255, 255, 255)))
		return false;
	_achievementAchievementsLayer = NULL;

	//adding the background
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	cocos2d::CCSprite* backgroundArt = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("menuBackground.png"));

	float bgScale = winSize.height / backgroundArt->getContentSize().height;
	backgroundArt->setScale(bgScale);

	float diff = winSize.width - backgroundArt->getContentSize().width * bgScale;
	float x = backgroundArt->getContentSize().width / 2 * bgScale + diff / 2;
	float y = backgroundArt->getContentSize().height / 2 * bgScale;
	backgroundArt->setPosition(ccp(x, y));
	addChild(backgroundArt);

	float scaleMult = Model::getInstance()->getGUIElementScaleMultiplicator();
	//back button
	int buttonHeight = 66 * scaleMult;
	int buttonLength = 66 * scaleMult;
	CCMenu* backButtonmenu = CCMenu::create();
	CCMenuItemSprite *backButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("return0.png"),
			CCSprite::createWithSpriteFrameName("return1.png"), (CCObject*) this, menu_selector(AchievementLayer::backTouched));
	backButton->setScaleX(buttonLength / backButton->getContentSize().width);
	backButton->setScaleY(buttonHeight / backButton->getContentSize().height);
	backButtonmenu->addChild(backButton);

	CCMenuItemSprite *toggleModeButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("toggleGUI1.png"),
			CCSprite::createWithSpriteFrameName("toggleGUI2.png"), (CCObject*) this, menu_selector(AchievementLayer::toggleModeTouched));
	toggleModeButton->setScaleX(buttonLength / toggleModeButton->getContentSize().width);
	toggleModeButton->setScaleY(buttonHeight / toggleModeButton->getContentSize().height);
	backButtonmenu->addChild(toggleModeButton);

	float padding = 10 * scaleMult;
	backButtonmenu->alignItemsVerticallyWithPadding(padding);
	addChild(backButtonmenu);
	backButtonmenu->setPosition(CCPoint(winSize.width - buttonLength / 2, winSize.height - (buttonHeight * 2.0f + padding) / 2));

	float offsetDown = ViewTools::addVersionAndCreditInfo(this, scaleMult);
	ViewTools::addIdleUnitTo(this, offsetDown);

	return true;
}
NotificationCenterTest::NotificationCenterTest()
: m_bShowImage(false)
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
        menu_selector(NotificationCenterTest::toExtensionsMainLayer));
    pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
    CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
    pBackMenu->setPosition( CCPointZero );
    addChild(pBackMenu);

    CCLabelTTF *label1 = CCLabelTTF::create("switch off", "Marker Felt", 26);
    CCLabelTTF *label2 = CCLabelTTF::create("switch on", "Marker Felt", 26);
    CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
    CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
    CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL);
    // turn on
    item->setSelectedIndex(1);
    CCMenu *menu = CCMenu::create(item, NULL);
    menu->setPosition(ccp(s.width/2+100, s.height/2));
    addChild(menu);

    CCMenu *menuConnect = CCMenu::create();
    menuConnect->setPosition(CCPointZero);
    addChild(menuConnect);

    for (int i = 1; i <= 3; i++)
    {
        Light* light = Light::lightWithFile("Images/Pea.png");
        light->setTag(kTagLight+i);
        light->setPosition(ccp(100, s.height/4*i));
        addChild(light);

        CCLabelTTF *label1 = CCLabelTTF::create("not connected", "Marker Felt", 26);
        CCLabelTTF *label2 = CCLabelTTF::create("connected", "Marker Felt", 26);
        CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
        CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
        CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL);
        item->setTag(kTagConnect+i);
        item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50));
        menuConnect->addChild(item, 0);
        if (i == 2)
        {
            item->setSelectedIndex(1);
        }
        bool bConnected = item->getSelectedIndex() == 1 ? true : false;
        light->setIsConnectToSwitch(bConnected);
    }

    CCNotificationCenter::sharedNotificationCenter()->postNotification(MSG_SWITCH_STATE, (CCObject*)(intptr_t)item->getSelectedIndex());

    /* for testing removeAllObservers */
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer1", NULL);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer2", NULL);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(NotificationCenterTest::doNothing), "random-observer3", NULL);
}
Exemple #15
0
bool MainScene::init()
{
	CCSize winSize = Director::getInstance()->getVisibleSize();
	if (!CCLayer::init())
	{
		return false;
	}
	auto BackGround = Sprite::create("backg.png");
	BackGround->setPosition(ccp(winSize.width / 2, winSize.height / 2)); //위치지정
	this->addChild(BackGround);

	CCMenu *MenuMain = CCMenu::create(NULL); //메뉴생성
	CCMenu *MenuMain1 = CCMenu::create(NULL); //메뉴생성
	CCMenu *MenuMain2 = CCMenu::create(NULL); //메뉴생성

	//메뉴아이템 추가
	CCMenuItem *item1 = CCMenuItemImage::create("start.png",
		"start.png",
		this,
		menu_selector(MainScene::menuCloseCallback));
	CCMenuItem *item2 = CCMenuItemImage::create("rank.png",
		"rank.png",
		this,
		menu_selector(MainScene::RankCloseCallback));

	CCMenuItem *item3 = CCMenuItemImage::create("create.png",
		"create.png",
		this,
		menu_selector(MainScene::CreaterMenuCallback));


	MenuMain->addChild(item1, 1); //메뉴에 아이템 붙이기
	MenuMain1->addChild(item2, 2);
	MenuMain2->addChild(item3, 3);

	MenuMain->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 20));
	MenuMain1->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 90));
	MenuMain2->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 160));

	this->addChild(MenuMain, 1);
	this->addChild(MenuMain1, 2);
	this->addChild(MenuMain2, 3);//메뉴를 레이어에 추가

	CCUserDefault* user = CCUserDefault::sharedUserDefault();
	int SaveSw = CCUserDefault::sharedUserDefault()->getIntegerForKey("SaveMake");
	if (SaveSw == 0){
		user->setIntegerForKey("SaveMake", 1);
		user->setIntegerForKey("Rank1", 0);
		user->setIntegerForKey("Rank2", 0);
		user->setIntegerForKey("Rank3", 0);
		user->setIntegerForKey("Rank4", 0);
		user->setIntegerForKey("Rank5", 0);
	}

	return true;
}
void GameLayer::configureGame(GameLevel gameLevel)
{
    
    _gameLevel = gameLevel;
    
    _accelVelocity = CCPointZero;
    
    CCPoint visOrigin = CCDirector::sharedDirector()->getVisibleOrigin();
    CCSize visSize = CCDirector::sharedDirector()->getVisibleSize();
    
    _menuPause = CCMenuItemImage::create("pause_off.png", "pause.png", this, menu_selector(GameLayer::pauseGame));
    _menuPause->setVisible(false);
    _menuPause->setPositionX(visOrigin.x + _menuPause->getContentSize().width * 0.9f);
    _menuPause->setPositionY(visOrigin.y + visSize.height - _menuPause->getContentSize().width * 0.6f);
    
    CCMenu* menu = CCMenu::create();
    menu->setAnchorPoint(ccp(0, 0));
    menu->setPosition(CCPointZero);
    menu->addChild(_menuPause);
    addChild(menu, kDeepPauseLayer);
    
    setTouchEnabled(true);
    
     _worldSpeed = START_WORLD_SPEED;
    _minDistanceObstaclesX = MIN_DISTANCE_OBSTACLES;
    
    if(_gameLevel == kGameLevelEasy)
    {
        _minDistanceObstaclesX *= 2.0f; // 1.0
        _worldSpeed *= 1.0f; // 0.9
        _vectorMap.insert(_vectorMap.begin(), easyMap, easyMap + sizeof(easyMap) / sizeof(int));
    }
    else if(_gameLevel == kGameLevelNormal)
    {
        _minDistanceObstaclesX *= 1.3f; // 0.9
        _worldSpeed *= 1.7f; // 1.8
        _vectorMap.insert(_vectorMap.begin(), normalMap, normalMap + sizeof(normalMap) / sizeof(int));
    }
    else if(_gameLevel == kGameLevelHard)
    {
        _minDistanceObstaclesX *= 1.0f; // 0.7
        _worldSpeed *= 2.2f; // 2.4
        _vectorMap.insert(_vectorMap.begin(), hardMap, hardMap + sizeof(hardMap) / sizeof(int));
    }
    
    _itemMap = 0;
    
    _gameState = kGameStarting;
    
    _pause = false;
    _gameOver = false;
    
    _createPlayer();
    _initElements();
    
}
Exemple #17
0
void GameLayer::createPauseLayer() {
	Context *context = Context::sharedContext();
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	/* 半透明层 */
	CCLayerColor* pauseLayer = CCLayerColor::create();
	pauseLayer->setContentSize(CCSizeMake(s.width, s.height));
	pauseLayer->setColor(ccc3(0, 0, 0));
	pauseLayer->setOpacity(150);
	CCMenu *menu = CCMenu::create();
//回到游戏
	CCMenuItemImage *resumebg = CCMenuItemImage::create(("btn_big.png"),
			("btn_big.png"));
	resumebg->setTarget(this, menu_selector(GameLayer::onResumeItem));
	CCMenuItemFont *resumetxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_resume")->getCString());
	resumebg->setAnchorPoint(ccp(0.5, 0.5));
	resumebg->setPosition(ccpp(0, 0));
	resumetxt->setPosition(
			ccp(resumebg->getContentSize().width / 2,
					resumebg->getContentSize().height / 2));
	resumetxt->setAnchorPoint(ccp(0.5, 0.5));
	resumetxt->setColor(context->getFontColor());
	resumebg->addChild(resumetxt);
	menu->addChild(resumebg);

//回到菜单
	CCMenuItemImage *backbg = CCMenuItemImage::create(("btn_big.png"),
			("btn_big.png"));
	backbg->setTarget(this, menu_selector(GameLayer::onBackItem));
	CCMenuItemFont *backtxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_back")->getCString());
	backbg->setAnchorPoint(ccp(0.5, 0.5));
	backbg->setPosition(ccpp(0, -0.12));
	backtxt->setPosition(
			ccp(backbg->getContentSize().width / 2,
					backbg->getContentSize().height / 2));
	backtxt->setAnchorPoint(ccp(0.5, 0.5));
	backtxt->setColor(context->getFontColor());
	backbg->addChild(backtxt);
	menu->addChild(backbg);

	pauseLayer->addChild(menu);
	CCDirector::sharedDirector()->getRunningScene()->addChild(pauseLayer, 0,
	TAG_LAYER_PAUSE);
}
Exemple #18
0
void GameScene::showPauseLayer(bool show){
	if(show){
		if(!pauseLayer){
			pauseLayer = CCLayer::create();
			CCSprite* bg = CCSprite::create("dlg_long.png");
			SETANCHPOS(bg,0,0,0,0);
			pauseLayer->addChild(bg);

			CCMenu* menu = CCMenu::create();
			SETANCHPOS(menu,0,0,0,0);
			pauseLayer->addChild(menu);

			CCMenuItemSprite* play = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("play.png"),
				CCSprite::createWithSpriteFrameName("play.png"),this,menu_selector(GameScene::btnCallback));
			play->setTag(2);
			SETANCHPOS(play,200,25,0,0);
			menu->addChild(play);

			CCMenuItemSprite* retry = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("retry.png"),
				CCSprite::createWithSpriteFrameName("retry.png"),this,menu_selector(GameScene::btnCallback));
			SETANCHPOS(retry,350,25,0,0);
			retry->setTag(3);
			menu->addChild(retry);

			CCMenuItemSprite* back = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("back.png"),
				CCSprite::createWithSpriteFrameName("back.png"),this,menu_selector(GameScene::btnCallback));
			SETANCHPOS(back,500,25,0,0);
			back->setTag(4);
			menu->addChild(back);

			CCMenuItemSprite* main = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("menu.png"),
				CCSprite::createWithSpriteFrameName("menu.png"),this,menu_selector(GameScene::btnCallback));
			SETANCHPOS(main,650,25,0,0);
			main->setTag(5);
			menu->addChild(main);

			addChild(pauseLayer,15);
		}
	}else{
		removeChild(pauseLayer,true);
		pauseLayer = NULL;
	}
}
Exemple #19
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;
}
Exemple #20
0
void PrepareLayer::showFullUpgrade(int type)
{
	CCSize size = ToolsFun::sharedTools()->getSceneSize();
	CCSprite *bkg = CCSprite::create("DayReward/bkg.png");
	this->addChild(bkg,200,12313133);
	bkg->setPosition(ccp(size.width/2,size.height/2));

	CCSprite *tip1 = CCSprite::create("DayReward/fullUpgrade.png");
	bkg->addChild(tip1);
	tip1->setPosition(ccp(bkg->getContentSize().width/2,bkg->getContentSize().height/2-50*gScaleY));

	CCMenu *menu = CCMenu::create();
	bkg->addChild(menu);
	menu->setPosition(CCPointZero);

	CCSprite *closeNml = CCSprite::create("ui/backUI/close0.png");
	CCSprite *closeSel = CCSprite::create("ui/backUI/close0.png");
	closeSel->setColor(ccc3(80,80,80));

	CCMenuItemSprite *itemClose  = NULL;

	if(type ==1)
	{
		itemClose = CCMenuItemSprite::create(closeNml,closeSel,NULL,this,menu_selector(PrepareLayer::openBuyCoin));
	}
	else
	{
		itemClose = CCMenuItemSprite::create(closeNml,closeSel,NULL,this,menu_selector(PrepareLayer::showFullUpgradeClose));
	}
	itemClose->setPosition(ccp(bkg->getContentSize().width-40*gScaleX ,bkg->getContentSize().height-60*gScaleY));
	menu->addChild(itemClose);

	CCSprite *spNml = CCSprite::create("DayReward/button.png");
	CCSprite *spSel = CCSprite::create("DayReward/button.png");
	spSel->setColor(ccc3(80,80,80));
	CCMenuItemSprite *itemSp = CCMenuItemSprite::create(spNml,spSel,this,menu_selector(PrepareLayer::showFullUpgradeSure));
	itemSp->setPosition(ccp(bkg->getContentSize().width/2 ,35*gScaleY));
	menu->addChild(itemSp);
	m_menu->setEnabled(false);
}
NotificationCenterTest::NotificationCenterTest()
: m_bShowImage(false)
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCMenuItemFont* pBackItem = CCMenuItemFont::itemFromString("Back", this,
        menu_selector(NotificationCenterTest::toExtensionsMainLayer));
    pBackItem->setPosition(ccp(s.width - 50, 25));
    CCMenu* pBackMenu = CCMenu::menuWithItems(pBackItem, NULL);
    pBackMenu->setPosition( CCPointZero );
    addChild(pBackMenu);

    CCLabelTTF *label1 = CCLabelTTF::labelWithString("switch off", "Marker Felt", 26);
    CCLabelTTF *label2 = CCLabelTTF::labelWithString("switch on", "Marker Felt", 26);
    CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1);
    CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2);
    CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL);
    // turn on
    item->setSelectedIndex(1);
    CCMenu *menu = CCMenu::menuWithItems(item, NULL);
    menu->setPosition(ccp(s.width/2+100, s.height/2));
    addChild(menu);

    CCMenu *menuConnect = CCMenu::menuWithItems(NULL);
    menuConnect->setPosition(CCPointZero);
    addChild(menuConnect);

    for (int i = 1; i <= 3; i++)
    {
        Light* light = Light::lightWithFile("Images/Pea.png");
        light->setTag(kTagLight+i);
        light->setPosition(ccp(100, s.height/4*i));
        addChild(light);

        CCLabelTTF *label1 = CCLabelTTF::labelWithString("not connected", "Marker Felt", 26);
        CCLabelTTF *label2 = CCLabelTTF::labelWithString("connected", "Marker Felt", 26);
        CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1);
        CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2);
        CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL);
        item->setTag(kTagConnect+i);
        item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50));
        menuConnect->addChild(item, 0);
        if (i == 2)
        {
            item->setSelectedIndex(1);
        }
        bool bConnected = item->getSelectedIndex() == 1 ? true : false;
        light->setIsConnectToSwitch(bConnected);
    }

    CCNotificationCenter::sharedNotifCenter()->postNotification(MSG_SWITCH_STATE, (CCObject*)item->getSelectedIndex());
}
void ZhuangbeiXilianUI::clickXilianJingHua(CCObject *obj)
{
	if (m_dInfoDialog)
	{
		m_dInfoDialog->removeFromParent();
		m_dInfoDialog = NULL;
	}
	string tishiStr = LFStrings::getValue("XilianJingHuaShuoMing");
	string cailiaoFileStr = "daoju_youlanzhiye.png";

	//弹框背景
	BaseSprite* dialog = BaseSprite::create("gongjiang_duanzao_cailiaobuzu_tanchukuang.png");
	dialog->setPosition(ccp(mWinSize.width/2, mWinSize.height/2 + 50));
	//提示
	{
		BaseSprite *cailiaoBg = BaseSprite::create("daoju_kuang_bg.png");
		dialog->addChild(cailiaoBg);
		cailiaoBg->setPosition(ccp(cailiaoBg->getContentSize().width/2 + 10, dialog->getContentSize().height/2));
		BaseSprite *cailiaoImg = BaseSprite::create(cailiaoFileStr);
		cailiaoBg->addChild(cailiaoImg);
		cailiaoImg->setPosition(ccp(cailiaoBg->getContentSize().width/2, cailiaoBg->getContentSize().height/2));

		CCLabelTTF* lable = CCLabelTTF::create(tishiStr.c_str(), fontStr_kaiti,20,CCSize(240, 0), kCCTextAlignmentLeft);
		dialog->addChild(lable);
		lable->setAnchorPoint(ccp(0,0.5));
		lable->setPosition(ccp(cailiaoBg->getPositionX()+cailiaoBg->getContentSize().width/2 , dialog->getContentSize().height/2));
	}
	//按键
	CCMenu* menu = CCMenu::create();
	{
		CCMenuItemImage* item = CCMenuItemImage::create(
			"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
			"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
			this, menu_selector(ZhuangbeiXilianUI::clickCiaoliaoShuoMing));
		menu->addChild(item);
		item->setPosition(ccp(dialog->getContentSize().width/2, dialog->getContentSize().height/2));
		item->setOpacity(0);
		item->setScaleX(mWinSize.width / dialog->getContentSize().width);
		item->setScaleY(mWinSize.height / dialog->getContentSize().height);
		// 		item->setScaleX(mWinSize.width / item->getContentSize().width);
		// 		item->setScaleY(mWinSize.height / item->getContentSize().height);
	}
	//弹框
	{

		LFAlert* lfAlert = new LFAlert();
		lfAlert->setBaseContainer(dialog,menu);
		CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128);
		lfAlert->release();
		m_dInfoDialog = lfAlert;
	}
}
Exemple #23
0
CCMenuItemImage* HelloWorld::createBlock(int posX, int posY, float sizeY, int tag)
{
	CCMenu* menu = CCMenu::create();
	CCMenuItemImage* block = CCMenuItemImage::create("/block.png","/block.png",this,menu_selector(HelloWorld::selectBlock));
	block->setScale(float(0.3));
	block->setPosition(ccp(posX,posY));
	block->setScaleX(sizeY);
	block->setTag(tag);
	menu->setTag(tag);
	menu->addChild(block);
	this->addChild(menu);
	return block;
}
Exemple #24
0
void GameStartLayer::addCtrlPanel()
{
	CCMenu * menu = CCMenu::create();
	addChild(menu);

	CCMenuItemImage *regretItem = CCMenuItemImage::create("regret.jpg",
														  "regret.jpg", this, menu_selector(GameStartLayer::regret));
	menu->addChild(regretItem);

	moveNode(regretItem, ccp(160, 60));


}
void ParkingViewScene::LoadParkingId()
{
    CCNode* node = this->getChildByTag(250);
    char s[20] ;

    sprintf(s, "%d.png", this->wayPointID);
    
    CCSprite *sprtEstabelecimento = CCSprite::create(s);
    if( sprtEstabelecimento == 0)
        sprtEstabelecimento = CCSprite::create("ModeloWayPointFoto.png");
    
    sprtEstabelecimento->setAnchorPoint(ccp(0,0));
    sprtEstabelecimento->setPosition(ccp(0,217));
    node->addChild(sprtEstabelecimento);

    
    //Waypoints do estacionamentos sao referidos como retirada de veiculos, de acordo
    //com o id, aqui o texto é alterado.
    switch(wayPointID)
    {
        case 19:
            insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco A1", node, 16);
            break;
        case 51:
            insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco B", node, 16);
            break;
        case 89:
            insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco D/E", node, 16);
            break;
    }
 

    //Cria um label ( aqui vira descricao do estacionamento)
    insertLabel(ccc3(72, 72, 72), ccp(20, 160), false, "Auditorio Moise Safra", node, 12);
    
    CCSprite *btnHorarioSelected = CCSprite::create("btnShowRotaEstacionmanto.png"); // botao pressionado
    CCSprite *btnHorarioUnSelected = CCSprite::create("btnShowRotaEstacionmanto.png");//botao nao pressionado
    CCMenuItemSprite *itembtnHorario = CCMenuItemSprite::create(btnHorarioSelected, btnHorarioUnSelected, btnHorarioSelected, menu_selector(ParkingViewScene::btnRotaCallBack));
	itembtnHorario->setAnchorPoint(ccp(0, 0));
    itembtnHorario->setPosition(ccp(40, 0));
    
    CCMenu* options = CCMenu::create();
    options->addChild(itembtnHorario,0,wayPointID);
    options->setPosition(ccp(230, 171) );
    node->addChild(options);
    
    CCSprite *sprtFundoEstabelecimento = CCSprite::create("SombraMagica.png");
    sprtFundoEstabelecimento->setAnchorPoint(ccp(0,0));
    sprtFundoEstabelecimento->setPosition(ccp(72, 200));
    node->addChild(sprtFundoEstabelecimento);
}
Exemple #26
0
bool CMenuLayer::init()
{
	
	if(!CCLayer::init())
	{
		return false;
	}

	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCMenuItemImage *pContinueItem = CCMenuItemImage::create(
		"Button\\button_play_down.png",
		"Button\\button_home_up.png",
		this,
		menu_selector(CMenuLayer::menuContinueCallback));
	pContinueItem->setPosition( ccp(size.width/2 , size.height/2 + size.height*120/HEIGHT_SCREEN_STANDARD));

	// create menu, it's an autorelease object
	CCMenu* pMenu = CCMenu::create(pContinueItem, NULL);
	pMenu->setPosition( CCPointZero );

	CCMenuItemImage *pMainMenu = CCMenuItemImage::create(
		"Button\\button_return_down.png",
		"Button\\button_return_up.png",
		this,
		menu_selector(CMenuLayer::menuSkillUpgradeCallback));
	pMainMenu->setPosition(ccp(size.width/2, size.height/2 + size.height*40/HEIGHT_SCREEN_STANDARD));
	pMenu->addChild(pMainMenu);

	CCMenuItemImage *pMuteMenu = CCMenuItemImage::create(
		"Button\\button_home_down.png",
		"Button\\button_home_up.png",
		this,
		menu_selector(CMenuLayer::menuMainMenuCallback));
	pMuteMenu->setPosition(ccp(size.width/2, size.height/2 - size.height*40/HEIGHT_SCREEN_STANDARD));
	pMenu->addChild(pMuteMenu);
	this->addChild(pMenu);	
	return true;
}
void HelloWorld::addBackButton(CCScene *s){
//    CCScene *currentScene = CCDirector::sharedDirector()->getRunningScene();
    CCSize size  = CCDirector::sharedDirector()->getWinSize();
    
    //布置菜单的layer
    CCMenu *menu = CCMenu::create();
    menu->setPosition(CCPointZero);//菜单锚点被设为0.5 0.5了,改回来
    s->addChild(menu);
    
    CCMenuItemImage *item = CCMenuItemImage::create("home.png", "home.png");
    item->setPosition(ccp(size.width-50, size.height-50));
    menu->addChild(item);
    item->setTarget(this, menu_selector(HelloWorld::returnCallback));
}
Exemple #28
0
void ADAds::fillBanner(Banner* banner)
{
#if defined(_DEBUG) && CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
    CCRenderTexture* texture = CCRenderTexture::create(100, 100);
    texture->beginWithClear(0.5f, 0.5f, 0.5f, 1);

    texture->end();

    CCSprite* s = CCSprite::createWithTexture(texture->getSprite()->getTexture());

    s->setScaleX(banner->getContentSize().width/s->getContentSize().width);
    s->setScaleY(banner->getContentSize().height/s->getContentSize().width);
    banner->addChild(s);
    s->setAnchorPoint(ccp(0,0));
    s->setPosition(ccp(0,0));
#endif

    if(_home_banners.size())
    {
        //std::random_shuffle(_home_banners.begin(), _home_banners.end());
        CustomBanner* home_ads = getCustomBanner();

        CCMenuItem* item = CCMenuItem::create(
                               home_ads, menu_selector(CustomBanner::onClick));


        CCMenu* menu = CCMenu::create();
        menu->addChild(item);

        banner->addChild(menu, 0, HOME_ADS_NODE_TAG);
        menu->setAnchorPoint(ccp(0,0));

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

        CCNode* banner_content = home_ads->getBanner();
        CCSize content_size = banner_content->getContentSize();
        CCSize zone_size = banner->getContentSize();

        float scale = MIN(zone_size.width/content_size.width,
                          zone_size.height/content_size.height);
        banner_content->setScale(scale);
        banner_content->setAnchorPoint(ccp(0, 0));
        banner_content->setPosition(ccp(0,0));

        item->setContentSize(content_size*scale);
        item->setAnchorPoint(ccp(0.5f,0.5f));
        item->setPosition(zone_size*0.5f);
        item->addChild(banner_content);
    }
}
Exemple #29
0
CCMenuItemImage* HelloWorld::createPillar(int posX, int tag)
{
	CCMenu* menu = CCMenu::create();
	CCMenuItemImage* pillar = CCMenuItemImage::create("/pillar.png","/pillar.png",this,menu_selector(HelloWorld::selectPillar));
	pillar->setScaleX(float(0.2));
	pillar->setScaleY(float(0.4));
	pillar->setPosition(ccp(posX,-75));
	pillar->setTag(tag);
	pillar->setEnabled(false);
	menu->setTag(tag);
	menu->addChild(pillar);
	this->addChild(menu);
	return pillar;
}
Exemple #30
0
void Popup::initPopup(float w,
             float h,
             std::vector<std::string>  buttonsImages,
             std::vector<std::shared_ptr<Delegate>> callbacks,
             const std::string message,
             const int textSize,
             const std::string images
                      )
{
    if (buttonsImages.size() != callbacks.size())
    {
        std::cout << "Error for popup initialisation : number of buttons not equal to number of callbacks" << std::endl;
        return;
    }
    
    this->onquitCallback = 0;
    
    this->nbButtons = buttonsImages.size();
    
    this->width = w;
    
    this->height = h;
    
    this->createBackGround();

    //->create the buttons
    
    CCMenu* pMenu ;
    for (int i = 0; i< buttonsImages.size() ; i++)
    {
        if (i==0)
            pMenu= CCMenu::create( this->createButton( buttonsImages[i], callbacks [i], i) , NULL);
        else
            pMenu->addChild(this->createButton( buttonsImages[i], callbacks [i], i));
        
    }
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu);
    pMenu->setTouchPriority(-201);
    
    //-> add the text
    CCLabelTTF* pLabel = CCLabelTTF::create(message.c_str(), "Arial", textSize);
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(0,this->height/4));
    
    // add the label as a child to this layer
    this->addChild(pLabel, 1);

}