Ejemplo n.º 1
0
void MyBuildingCard::displayDetail(cocos2d::CCNode *psender){
    MyBuildingCard* card = (MyBuildingCard*)psender->getParent()->getParent();
    activeCard = card;
    oriPosition = card->getPosition();
    card->runAction(CCEaseInOut::create(CCMoveTo::create(0.2, ccp(200-card->getParent()->getPosition().x,320)),2));
    card->runAction(CCEaseInOut::create(CCScaleTo::create(0.2, 1.2),2));
    card->isEnabled = false;
    ((GXScrollView*)(card->getParent()))->setEnabled(false);
    card->getParent()->reorderChild(card, 100000);
    CCMenuItemSprite* gray = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("dialoggray.png"), CCSprite::createWithSpriteFrameName("dialoggray.png"));
    MyPriorityMenu* grayMenu = MyPriorityMenu::create(-503,gray,NULL);
    grayMenu->setTag(grayTag);
    card->getParent()->addChild(grayMenu,99999);
    gray->setScaleX(960/gray->getContentSize().width);
    gray->setScaleY(540/gray->getContentSize().height);
    grayMenu->setPosition(ccp(480-card->getParent()->getPosition().x,320));
//    gray->setPosition(ccp(0,0));
    
    CCSprite* detailBack = CCSprite::createWithSpriteFrameName("creatoruidetail.jpg");    detailBack->setPosition(ccp(634-card->getParent()->getPosition().x,-detailBack->getContentSize().height/2-100));
    detailBack->setScale(1.2);
    detailBack->setTag(detailBackTag);
    card->getParent()->addChild(detailBack,100000);
    detailBack->runAction(CCSequence::create(CCDelayTime::create(0.2),CCEaseInOut::create(CCMoveTo::create(0.2, ccp(634-card->getParent()->getPosition().x,320)),2), NULL));
    CCMenuItemFont::setFontSize(24);
    CCMenuItemFont* back = CCMenuItemFont::create("返回",this,menu_selector(MyBuildingCard::cancelDetail));
    back->setColor(ccc3(114,66,45));
    MyPriorityMenu* backMenu = MyPriorityMenu::create(-503,back,NULL);
    backMenu->setPosition(ccp(detailBack->getContentSize().width-44,44));
    detailBack->addChild(backMenu,NULL);
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
// on "init" you need to initialize your instance
bool InGameTopMenuLayer::init() {
	if (!CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)))
		return false;
	float scaleMult = Model::getInstance()->getGUIElementScaleMultiplicator();
	float button_length = 66 * scaleMult;
	float button_heigth = 66 * scaleMult;
	float padding = 10 * scaleMult;
	_soundOnString = "on";
	_soundOffString = "off";

	CCMenuItemSprite *shutdown = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("shutdown0.png"),
			CCSprite::createWithSpriteFrameName("shutdown1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::shutdownTouched));
	shutdown->setScaleX(button_length / shutdown->getContentSize().width);
	shutdown->setScaleY(button_heigth / shutdown->getContentSize().height);

	CCMenuItemSprite *autoCam = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("autoCam0.png"),
			CCSprite::createWithSpriteFrameName("autoCam1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::autoCamTouched));
	autoCam->setScaleX(button_length / autoCam->getContentSize().width);
	autoCam->setScaleY(button_heigth / autoCam->getContentSize().height);

	float scale = button_heigth / autoCam->getContentSize().height;
	_autCamOnOffLabel = CCLabelTTF::create("auto", FONT_NAME, PRICE_LABEL_FONT_SIZE / scale * scaleMult,
			CCSize(autoCam->getContentSize().width, PRICE_LABEL_HEIGTH / scale * scaleMult), kCCTextAlignmentCenter);
	autoCam->addChild(_autCamOnOffLabel);
	_autCamOnOffLabel->setColor(Model::getInstance()->getInGameGameLayer()->getAutoCam() ? ccc3(0, 255, 0) : ccc3(255, 0, 0));
	_autCamOnOffLabel->setPosition(CCPoint(autoCam->getContentSize().width / 2, PRICE_LABEL_BOTTOM_SPACE / scale * scaleMult));
	_autCamOnOffLabel->enableStroke(PRICE_LABEL_COLOR_STROKE, PRICE_LABEL_STROKE_SIZE / scale * scaleMult, true);

	CCMenuItemSprite *autoCamSwitch = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("autoCamSwitch0.png"),
			CCSprite::createWithSpriteFrameName("autoCamSwitch1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::flipThisPlayerForCamTouched));
	autoCamSwitch->setScaleX(button_length / autoCamSwitch->getContentSize().width);
	autoCamSwitch->setScaleY(button_heigth / autoCamSwitch->getContentSize().height);

	CCMenuItemSprite *pause = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("pause1.png"), CCSprite::createWithSpriteFrameName("pause2.png"),
			(CCObject*) this, menu_selector(InGameTopMenuLayer::pauseTouched));
	pause->setScaleX(button_length / pause->getContentSize().width);
	pause->setScaleY(button_heigth / pause->getContentSize().height);

	CCMenuItemSprite *zoomIn = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ZoomIn1.png"), CCSprite::createWithSpriteFrameName("ZoomIn2.png"),
			(CCObject*) this, menu_selector(InGameTopMenuLayer::zoomInTouched));
	zoomIn->setScaleX(button_length / zoomIn->getContentSize().width);
	zoomIn->setScaleY(button_heigth / zoomIn->getContentSize().height);

	CCMenuItemSprite *zoomOut = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ZoomOut1.png"),
			CCSprite::createWithSpriteFrameName("ZoomOut2.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::zoomOutTouched));
	zoomOut->setScaleX(button_length / zoomOut->getContentSize().width);
	zoomOut->setScaleY(button_heigth / zoomOut->getContentSize().height);

	CCMenuItemSprite *toggleGUI = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("toggleGUI1.png"),
			CCSprite::createWithSpriteFrameName("toggleGUI2.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::toggleGUITouched));
	toggleGUI->setScaleX(button_length / toggleGUI->getContentSize().width);
	toggleGUI->setScaleY(button_heigth / toggleGUI->getContentSize().height);

	CCMenuItemSprite *enableSound = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("soundEnable0.png"),
			CCSprite::createWithSpriteFrameName("soundEnable1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::enableSoundTouched));
	enableSound->setScaleX(button_length / enableSound->getContentSize().width);
	enableSound->setScaleY(button_heigth / enableSound->getContentSize().height);

	scale = button_heigth / enableSound->getContentSize().height;
	_enableSoundLabel = CCLabelTTF::create(SoundHandler::getInstance()->isSoundEnabled() ? _soundOnString.c_str() : _soundOffString.c_str(), FONT_NAME,
			PRICE_LABEL_FONT_SIZE / scale * scaleMult, CCSize(enableSound->getContentSize().width, PRICE_LABEL_HEIGTH / scale * scaleMult),
			kCCTextAlignmentCenter);
	enableSound->addChild(_enableSoundLabel);
	_enableSoundLabel->setColor(SoundHandler::getInstance()->isSoundEnabled() ? ccc3(0, 255, 0) : ccc3(255, 0, 0));
	_enableSoundLabel->setPosition(CCPoint(enableSound->getContentSize().width / 2, PRICE_LABEL_BOTTOM_SPACE / scale * scaleMult));
	_enableSoundLabel->enableStroke(PRICE_LABEL_COLOR_STROKE, PRICE_LABEL_STROKE_SIZE / scale * scaleMult, true);

	CCMenu* menu = CCMenu::create();
	int x = 0;
	int y = 1;
	ViewTools::addToMenu(menu, zoomIn, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, zoomOut, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, autoCamSwitch, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, autoCam, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, toggleGUI, button_length, button_heigth, x++, y, padding);

	if (Model::getInstance()->getGameMode() != NETWORK)
		ViewTools::addToMenu(menu, pause, button_length, button_heigth, x++, y, padding);

	ViewTools::addToMenu(menu, shutdown, button_length, button_heigth, x, y, padding);
	ViewTools::addToMenu(menu, enableSound, button_length, button_heigth, x, y - 1, padding);

	// resizing this layer to the menu and place the menu correct
	float width = (x + 1) * button_length + x * padding;

	float height = button_heigth * 2 + padding;
	setContentSize(CCSize(width, height));
	menu->setPosition(0, 0);
	addChild(menu);

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	setPosition(winSize.width - width - (UNITS_INFO_OVERLAY_WIDTH * scaleMult), winSize.height - height);
	setOpacity(0); // 0- total transparent, 255 not
	return true;
}