Ejemplo n.º 1
0
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 );
}
Ejemplo n.º 2
0
void ChallengeAgainLayer::onShow(int round, int need)
{
	float totalWidth = 0.0;
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCSprite *app1 = CCSprite::create(g_sRelifeBGImage);
	app1->setAnchorPoint(ccp(0,0));
	app1->setPositionX(30);
	app1->setPositionY(s.height*0.5);
	this->addChild(app1);
	totalWidth += app1->getContentSize().width;

	NumberSprite * roundTip = NumberSprite::create("green60",round);
	roundTip->setAnchorPoint(ccp(0,0));
	roundTip->setPositionX(app1->getPositionX()+app1->getContentSize().width+4);
	roundTip->setPositionY(app1->getPositionY());
	this->addChild(roundTip);
	totalWidth += 4;
	totalWidth += roundTip->realWidth;

	CCSprite *app2 = CCSprite::create(g_sGuanBGImage);
	app2->setAnchorPoint(ccp(0,0));
	app2->setPositionX(roundTip->getPositionX()+roundTip->realWidth+4);
	app2->setPositionY(roundTip->getPositionY());
	this->addChild(app2);
	totalWidth += 4;
	totalWidth += app2->getContentSize().width;

	float bx = (s.width - totalWidth)*0.5;
	app1->setPositionX(bx);
	roundTip->setPositionX(app1->getPositionX()+app1->getContentSize().width+4);
	app2->setPositionX(roundTip->getPositionX()+roundTip->realWidth+4);

	CCSprite *app3 = CCSprite::create(g_sLifeNeedBGImage);
	app3->setAnchorPoint(ccp(0,0));
	app3->setPositionX(app1->getPositionX());
	app3->setPositionY(app2->getPositionY()-app2->getContentSize().height-20);
	this->addChild(app3);

	NumberSprite * needTip = NumberSprite::create("green60",need);
	needTip->setAnchorPoint(ccp(0,0));
	needTip->setPositionX(app3->getPositionX()+app3->getContentSize().width+4);
	needTip->setPositionY(app3->getPositionY());
	this->addChild(needTip);

	CCSprite *app4 = CCSprite::create(g_sLifeValueBGImage);
	app4->setAnchorPoint(ccp(0,0));
	app4->setPositionX(needTip->getPositionX()+needTip->realWidth+4);
	app4->setPositionY(needTip->getPositionY());
	this->addChild(app4);

	CCMenuItemImage* pSureMenu = CCMenuItemImage::create(
                                                g_sSureBGImage, 
                                                g_sSureBGImage, 
                                                this, 
                                                menu_selector(ChallengeAgainLayer::onCommandSure));
	pSureMenu->setAnchorPoint(ccp(0,0));
	CCMenu* pMenu = CCMenu::create(pSureMenu, NULL);
    this->addChild(pMenu);
	pMenu->setTouchPriority(-1000);
	pMenu->setAnchorPoint(ccp(0,0));
	pMenu->setPositionY(app4->getPositionY()-app4->getTextureRect().size.height-40);
	pMenu->setPositionX(100);


	CCSprite * img = CCSprite::create(g_sReturnBGImage);
	CCMenuItemImage* pReturnMenu = CCMenuItemImage::create(
                                                g_sReturnBGImage, 
                                                g_sReturnBGImage, 
                                                this, 
                                                menu_selector(ChallengeAgainLayer::onCommandReturn));
	pReturnMenu->setAnchorPoint(ccp(0,0));
	CCMenu* pMenu2 = CCMenu::create(pReturnMenu, NULL);
    this->addChild(pMenu2);
	pMenu2->setTouchPriority(-1000);
	pMenu2->setAnchorPoint(ccp(0,0));
	pMenu2->setPositionY(pMenu->getPositionY());
	pMenu2->setPositionX(s.width-img->getTextureRect().size.width-100);
}
Ejemplo n.º 3
0
// on "init" you need to initialize your instance
bool TestAircraft::init()
{
	if ( !CCLayer::init() )
	{
		return false;
	}

	// ------------
	// init input manager
	// ---------------
	InputManager* input = InputManager::sharedInstance();
	CCDirector::sharedDirector()->getKeypadDispatcher()->addDelegate(input);

	// -------------
	// init physics
	// -----------
	PhysicsManager::sharedInstance()->enableDebugDraw(true);
	GB2ShapeCache::sharedGB2ShapeCache()->addShapesWithFile("png/physics.plist");

	// step
	schedule(schedule_selector(TestAircraft::stepForPhysicsManager));

	// -----------------
	// Init Audio
	// ------------
	SimpleAudioEngine::sharedEngine()->preloadEffect("wav/exploStd.wav");

	// ------------
	// Hero Aircraft
	// -----------
	Aircraft* hero = Aircraft::createHeroAircraft();
	addChild(hero);

	CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
	hero->setPosition(screenSize.width/2, screenSize.height/2);

	GameController::sharedInstance()->setPlayerAircraft(hero);

	// ------------
	// create menu
	// -------------
	CCMenu* menu = CCMenu::create();

	// straight menu item
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("straight", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// omni 
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("omni", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// ray gun 
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("ray gun", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// tank
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("tank", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// boss00
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("boss00", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// boss01
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("boss01", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// hero
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("hero", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	menu->alignItemsVertically();
	addChild(menu);

	menu->setPositionX(menu->getPositionX() + 200);



	return true;
}
Ejemplo n.º 4
0
bool DailyDaysCompletePopup::init(uint32_t days, uint32_t reward)
{
    if (!CCLayer::init()) return false;
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    
    CCSprite* back = CCSprite::create("Interfeiss/challenges/complete_popup/dont_leave.png");
    back->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
    addChild(back);
    
    
    CCMenuItemImage* closeBt = CCMenuItemImage::create("Interfeiss/level_end/level_up_popup/x_btn0001.png",
                                                       "Interfeiss/level_end/level_up_popup/x_btn0002.png",
                                                       this, menu_selector(DailyDaysCompletePopup::close));
    
    CCMenu* closeMenu = CCMenu::create(closeBt, NULL);
    closeMenu->setPosition(ccp(730, 530));
    addChild(closeMenu);
    
    CCMenuItemImage* shareBt =
    CCMenuItemImage::create("Interfeiss/challenges/complete_popup/share_btn_still0001.png",
                            "Interfeiss/challenges/complete_popup/share_btn_still0002.png",
                            this, menu_selector(DailyDaysCompletePopup::share));
    CCMenu* shareMenu = CCMenu::create(shareBt, NULL);
    shareMenu->setPositionY(200);
    shareMenu->setPositionX(visibleSize.width / 2 + 0);
    addChild(shareMenu);
    
    
    CCLabelTTF* titleTxt = CCLabelTTF::create(("Daily challenge completed " + toString(days) + " days in a row!").c_str(),
                                              FONT_SKRANJI_BOLD,
                                              TITLE_FONT_SIZE*0.6, CCSize(320, 180),
                                              kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop);
    titleTxt->setColor(ccc3(0x3E, 0x16, 0x04));
    titleTxt->setRotation(-2);
    titleTxt->setPosition(ccp(visibleSize.width / 2+80, visibleSize.height / 2 + 70));
    addChild(titleTxt);
    
    // title
    CCLabelTTF* levelTxt = CCLabelTTF::create("reward", FONT_SKRANJI_BOLD,
                                              TITLE_FONT_SIZE*0.6, CCSize(130, 120),
                                              kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop);
    levelTxt->setColor(ccc3(0x4F, 0x98, 0x8B));
    levelTxt->setRotation(-6);
    levelTxt->setPosition(ccp(visibleSize.width / 2 + 40, visibleSize.height / 2 - 70));
    addChild(levelTxt);
    
    // reward
    CCLabelTTF* rewardSh = CCLabelTTF::create(toString(reward).c_str(), FONT_SKRANJI_BOLD, TITLE_FONT_SIZE*1,
                                              CCSize(100, 55), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
    rewardSh->setAnchorPoint(ccp(0,0));
    rewardSh->cocos2d::CCNode::setPosition(ccp(580, 2));
    rewardSh->setColor(ccc3(0xff, 0xff, 0xff));
    rewardSh->enableShadow(CCSize(3,3), 0.5, 3, true);
    rewardSh->setRotation(-6);
    rewardSh->setPosition(ccp(visibleSize.width / 2 - 70, 245));
    addChild(rewardSh);
    
    CCLabelTTF* rewardT = CCLabelTTF::create(toString(reward).c_str(), FONT_SKRANJI_BOLD, TITLE_FONT_SIZE*1,
                                             CCSize(100, 55), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
	rewardT->setAnchorPoint(ccp(0,0));
	rewardT->setColor(ccc3(0xff, 0xff, 0xff));
	rewardT->cocos2d::CCNode::setPosition(ccp(580, 2));
    rewardT->setRotation(-6);
	rewardT->setPosition(ccp(visibleSize.width / 2 - 70, 245));
    addChild(rewardT);
    
    // animation
    TimedSpriteAnimation* check = TimedSpriteAnimation::create("Interfeiss/challenges/ingame_pop_up/check.plist", 3);
    check->setAnchorPoint(ccp(0, 1));
    check->setPosition(ccp(visibleSize.width / 2 + 190, 460));
    addChild(check);
    
    // icon
    char rewardStr[10];
    std::string iconStr;
    sprintf(rewardStr, "+%d", reward);
    
    iconStr = "Interfeiss/challenges/award_diamond.png";
    
    rewardSh->setString(rewardStr);
    rewardT->setString(rewardStr);
    
    // icon
	CCSprite* icon = CCSprite::create(iconStr.c_str());
	icon->setAnchorPoint(ccp(0.5,0.5));
    icon->setScale(0.8);
	icon->setPosition(ccp(visibleSize.width / 2 + 80, 280));
	addChild(icon);
    
    return true;
}
Ejemplo n.º 5
0
bool SelectLevel::init()

{
    if(!SceneStyle::init())
        return false;

    ADSoundManager::playMusic(InfoStyles::MENU_MUSIC);

    //Get curren collection
    const Collection* current_collection;
    current_collection =LevelSaves::getInstance().getCollectionById(
                _collection_id);

    //Get the screen start of cordinates
    const CCPoint ORIGIN = ADScreen::getOrigin();
    const CCSize VISIBLE_SIZE = ADScreen::getVisibleSize();
    const float SCALE = ADScreen::getScaleFactor();
    float x_middle_of_sheet = (VISIBLE_SIZE.width-133/SCALE)/2 + ORIGIN.x;
    float padding = 25/SCALE;
    showBackground(BackgroundType::Dark);

    showButtonBack();
    //window title
    cocos2d::CCLabelTTF* title_select_collection;


    title_select_collection = CCLabelTTF::create(current_collection->getName().c_str(),
                                                 ADLanguage::getFontName(),
                                                 InfoStyles::SIZE_MENU_TITLE);
    title_select_collection->setPositionX(x_middle_of_sheet+padding*2);

    title_select_collection->setPositionY(ORIGIN.y +
                                          + VISIBLE_SIZE.height-padding*0.25f -
                                          title_select_collection->getContentSize().height*0.5f);

    title_select_collection->setColor(InfoStyles::COLOR_WHITE);
    this->addChild(title_select_collection);

    //menu
    CCMenu* menu =CCMenu::create();
    float position_menu_y = VISIBLE_SIZE.height -padding*0.25f -
            title_select_collection->getContentSize().height*0.5f;


    float collection_width = 0;
    float card_height = 0;
    float card_width = 0;
    int current_dificult;
    current_dificult = 0;
    for(unsigned int j = 0; j < 3; ++j)
    {
        current_dificult = j;
        Card* card;
        if (j == 0)
        {
            int star_number = SaveStarsManager::getInstance()->getStars(
                        _collection_id, j);

            card = Card::create(CCSprite::create(current_collection->getCollectionPartEasy().getImage().c_str()),
                                _("select_level.easy"),
                                star_number,CardType::WithBorder);

        }
        else if (j == 1)
        {
            int star_number = SaveStarsManager::getInstance()->getStars(
                        _collection_id, j);

            card = Card::create(CCSprite::create(current_collection->getCollectionPartMiddle().getImage().c_str()),
                                _("select_level.middle"),
                                star_number,CardType::WithBorder);

        }
        else if (j == 2)
        {
            int star_number = SaveStarsManager::getInstance()->getStars(
                        _collection_id, j);

            card = Card::create(CCSprite::create(current_collection->getCollectionPartDifficult().getImage().c_str()),
                                _("select_level.difficult"),
                                star_number,CardType::WithBorder);

        }

        ADMenuItem* button_card = ADMenuItem::create(card);
        button_card->setAnchorPoint(ccp(0.5f,0.5f));
        float one_card_width = 340/SCALE;
        collection_width += one_card_width;
        card_height = button_card->getContentSize().height;
        card_width = button_card->getContentSize().width;
        button_card->setPositionY(ORIGIN.y+button_card->getContentSize().height*0.5f);
        button_card->setPositionX(one_card_width*j + button_card->getContentSize().width*0.5f);
        CollectionID id = current_collection->getID();
        button_card->setClickAction([id,current_dificult](){
            CCDirector::sharedDirector()->replaceScene(LevelScene::scene(id,current_dificult));

        });
        menu->addChild(button_card);

        card->setCardColor(LevelSaves::getInstance().getColor(_collection_id));
        card->setTitleColor(InfoStyles::COLOR_WHITE);
        if (j == 0)
        {
            card->setBorderType(BorderType::Easy);
        }
        else if (j == 1)
        {
            card->setBorderType(BorderType::Middle);
        }
        else if (j == 2)
        {
            card->setBorderType(BorderType::Difficult);
        }
    }

    menu->setAnchorPoint(ccp(0,0));
    float position_menu_x = VISIBLE_SIZE.width -collection_width ;
    menu->setPositionX(ORIGIN.x +position_menu_x*0.5f);
    menu->setPositionY((position_menu_y-card_height)*0.5f);
    this->addChild(menu);
    return true;

}