Beispiel #1
0
void GameLayer::themeButtonClick(CCObject *sender){
	if (bPaused) {
		return;
	}

	bPaused = true;
	CCLayer *layer2 = new CCLayer();

	CCSprite* dialog_bk = ThemeManager::sharedInstance()->spriteWithImageFile("chs_theme.png");
	dialog_bk->setScaleX(SCREEN_WIDTH/dialog_bk->getContentSize().width);
	dialog_bk->setScaleY(SCREEN_WIDTH/dialog_bk->getContentSize().width);
	dialog_bk->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
	layer2->addChild(dialog_bk,11);

	CCSprite* theme1useNormal = ThemeManager::sharedInstance()->spriteWithImageFile("btn_chs.png");
	CCSprite* theme1useSelected = ThemeManager::sharedInstance()->spriteWithImageFile("btn_chs.png");
	CCMenuItemSprite* ptheme1useItemSprite = CCMenuItemSprite::itemWithNormalSprite(theme1useNormal, theme1useSelected, this, menu_selector(GameLayer::theme1useButtonClick));
	ptheme1useItemSprite->setScale(0.6*LL_SCREEN_SCALE_VALUE);
	CCMenu* ptheme1useMenu = CCMenu::menuWithItems(ptheme1useItemSprite,NULL);
	ptheme1useMenu->setPosition(ccp(SCREEN_WIDTH*0.65, SCREEN_HEIGHT*0.65));

	
	CCSprite* theme2useNormal = ThemeManager::sharedInstance()->spriteWithImageFile("btn_chs.png");
	CCSprite* theme2useSelected = ThemeManager::sharedInstance()->spriteWithImageFile("btn_chs.png");
	CCMenuItemSprite* ptheme2useItemSprite = CCMenuItemSprite::itemWithNormalSprite(theme2useNormal, theme2useSelected, this, menu_selector(GameLayer::theme2useButtonClick));
	ptheme2useItemSprite->setScale(0.6*LL_SCREEN_SCALE_VALUE);
	CCMenu* ptheme2useMenu = CCMenu::menuWithItems(ptheme2useItemSprite,NULL);
	ptheme2useMenu->setPosition(ccp(SCREEN_WIDTH*0.65, SCREEN_HEIGHT*0.4));

	layer2->addChild(ptheme1useMenu, 12);
	layer2->addChild(ptheme2useMenu, 12);
	layer2->setTag(1000);
	CCActionInterval* largeto = CCScaleBy::create(0.2, 2);
	layer2->setScale(0.5);
	layer2->runAction(largeto);
	this->addChild(layer2, 10);
	/*
		if(ThemeManager::sharedInstance()->getTheme()==themeCandy){
		ThemeManager::sharedInstance()->setTheme(themePlain);
		CCDirector::sharedDirector()->replaceScene(CCTransitionSlideInL::transitionWithDuration(0.5,GameLayer::scene()));
	}else{ ThemeManager::sharedInstance()->setTheme(themeCandy);

	CCDirector::sharedDirector()->replaceScene(CCTransitionSlideInR::transitionWithDuration(0.5,GameLayer::scene()));
	}
	*/
}
bool RPGMapItemsMenuLayer::init(cocos2d::CCDictionary *stringList, CppSQLite3DB *db, float width, float height)
{
    if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
    {
        this->m_stringList = stringList;
        this->m_stringList->retain();
        
        this->m_db = db;
        
        this->m_itemsList = new CCArray();
        this->m_itemsList->init();
        
        CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
        mainBg->setPosition(CCPointZero);
        mainBg->setTag(kRPGMapItemsMenuLayerTagBg);
        this->addChild(mainBg);
        
        CCMenu *mainMenu = CCMenu::create();
        mainMenu->setTag(kRPGMapItemsMenuLayerTagMainMenu);
        mainMenu->setAnchorPoint(CCPointZero);
        mainMenu->setPosition(CCPointZero);
        this->addChild(mainMenu);
        
        CCMenuItemSprite *menuBack = (CCMenuItemSprite*)mainMenu->getChildByTag(kRPGMapItemsMenuLayerTagMainMenuBack);
        if(!menuBack)
        {
            menuBack = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapItemsMenuLayer::onMenu));
            menuBack->setPosition(ccp(40, 600));
            menuBack->setTag(kRPGMapItemsMenuLayerTagMainMenuBack);
            menuBack->setScale(0.5);
            mainMenu->addChild(menuBack);
        }
        
        CCTableView *tableView = CCTableView::create(this, CCSizeMake(900, 570));
        tableView->setDirection(kCCScrollViewDirectionVertical);
        tableView->setPosition(ccp(80, 30));
        tableView->setDelegate(this);
        tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
        tableView->setTag(kRPGMapItemsMenuLayerTagItemListTable);
        this->addChild(tableView);
        
        this->loadItemsData();
        
        return true;
    }
    return false;
}
void EaseSpriteDemo::onEnter()
{
	CCLayer::onEnter();

	// Example:
	// You can create a sprite using a Texture2D
	CCTexture2D* tex = new CCTexture2D();
	UIImage* pImage = new UIImage();
	
	if(pImage->initWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(s_pPathGrossini)))
	{
		tex->initWithImage(pImage);
		m_grossini = CCSprite::spriteWithTexture(tex); 
		m_grossini->retain();

	}

	tex->release();
	delete pImage;
	
	// Example:
	// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
	m_tamara = CCSprite::spriteWithFile(s_pPathSister1); m_tamara->retain();
	m_kathia = CCSprite::spriteWithFile(s_pPathSister2); m_kathia->retain();
	
	addChild( m_grossini, 3);
	addChild( m_kathia, 2);
	addChild( m_tamara, 1);

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

	m_grossini->setPosition( CGPointMake(60, 50) );
	m_kathia->setPosition( CGPointMake(60, 150) );
	m_tamara->setPosition( CGPointMake(60, 250) );

	CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
	addChild(label);
	label->setPosition( CGPointMake(s.width/2, s.height-50) );

	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) );
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) );
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(EaseSpriteDemo::nextCallback) );

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

	menu->setPosition( CGPointZero );
	item1->setPosition( CGPointMake( s.width/2 - 100,30) );
	item2->setPosition( CGPointMake( s.width/2, 30) );
	item3->setPosition( CGPointMake( s.width/2 + 100,30) );
	
	addChild(menu, 1);	
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);

    /////////////////////////////
    // 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(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

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

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(pLabel, 1);

    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::create("PIC_BJ_BGJSW.png");

    // position the sprite on the center of the screen
    pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);

	m_sp = S2CSprite::create("1.png", "2.png", 1.f);
	m_sp->setPosition(ccp(640, 400));
	this->addChild(m_sp);

	
    
    return true;
}
Beispiel #5
0
//------------------------------------------------------------------
//
// SchedulerTestLayer
//
//------------------------------------------------------------------
void SchedulerTestLayer::onEnter()
{
    CCLayer::onEnter();

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

    CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
    addChild(label);
    label->setPosition(ccp(s.width/2, s.height-50));

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

    CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(SchedulerTestLayer::backCallback));
    CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(SchedulerTestLayer::restartCallback) );
    CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(SchedulerTestLayer::nextCallback) );

    CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
    menu->setPosition(CCPointZero);
    item1->setPosition(ccp( s.width/2 - 100,30));
    item2->setPosition(ccp( s.width/2, 30));
    item3->setPosition(ccp( s.width/2 + 100,30));

    addChild(menu, 1);
}
void MainView::showMainView(){
    
    
    matchLogo = CCSprite::create("[email protected]");
    matchLogo->setScaleY(matchLogo->getScaleY()* dScaleFactorY);
    matchLogo->setScaleX(matchLogo->getScaleX()* dScaleFactorX);
    matchLogo->setPosition(ccp(size.width / 2, 850* dScaleFactorY));
    addChild(matchLogo);
    
    //Primary
    primaryButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::maintoLevels));
    primaryButton->setPosition(ccp(size.width / 2,670* dScaleFactorY));
    primaryButton->setScaleY(primaryButton->getScaleY()* dScaleFactorY);
    primaryButton->setScaleX(primaryButton->getScaleX()* dScaleFactorX);
    
    // Action
    actionButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::maintoTime));
    actionButton->setPosition(ccp(size.width / 2-20*dScaleFactorX, 570*dScaleFactorY));
    actionButton->setScaleY(actionButton->getScaleY()* dScaleFactorY);
    actionButton->setScaleX(actionButton->getScaleX()* dScaleFactorX);
    // Endless
    infinityButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::maintoEndless));
    infinityButton->setPosition(ccp(size.width / 2, 470*dScaleFactorY));
    infinityButton->setScaleY(infinityButton->getScaleY()* dScaleFactorY);
    infinityButton->setScaleX(infinityButton->getScaleX()* dScaleFactorX);
   
    // Store
    StoreButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::onStore));
    StoreButton->setPosition(ccp(size.width / 2-60*dScaleFactorX, 370*dScaleFactorY));
    StoreButton->setScaleX(StoreButton->getScaleX()* dScaleFactorX);
    StoreButton->setScaleY(StoreButton->getScaleY()* dScaleFactorY);
    
    // Get a Free App
    getFreeAppButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::getFreeApp));
    getFreeAppButton->setPosition(ccp(size.width / 2, 270*dScaleFactorY));
    getFreeAppButton->setScaleY(getFreeAppButton->getScaleY()* dScaleFactorY);
    getFreeAppButton->setScaleX(getFreeAppButton->getScaleX()* dScaleFactorX);
    // More
    moreButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::maintoMore));
    moreButton->setPosition(ccp(size.width / 2 + 250*dScaleFactorX, 170*dScaleFactorY));
    moreButton->setScaleY(moreButton->getScaleY()* dScaleFactorY);
    moreButton->setScaleX(moreButton->getScaleX()* dScaleFactorX);
    //How to play
    howToButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::howToPlay));
    howToButton->setPosition(ccp(size.width / 2 - 200*dScaleFactorX, 170*dScaleFactorY));
    howToButton->setScaleX(howToButton->getScaleX()*dScaleFactorX);
    howToButton->setScaleY(howToButton->getScaleY()*dScaleFactorY);
    // Choose Backgroun Button
    engageButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::maintomoreBackgrounds));
    engageButton->setPosition(ccp(size.width / 2+ 280*dScaleFactorX, 570*dScaleFactorY));
    engageButton->setScaleX(engageButton->getScaleX()*dScaleFactorX);
    engageButton->setScaleY(engageButton->getScaleY()*dScaleFactorY*0.9);
    
    
    //    PHNotificationView *notifView=[[[PHNotificationView alloc] initWithApp:kPlayHavenID
    //                                                                    secret:kPlayHeavenSecret
    //                                                                 placement:@"more_games"] autorelease];
    //    [moreButton addSubview:notifView];
    //    notifView.center=CGPointMake(16, 16);
    //    notifView.tag=playhavenNotificationViewTag;
    //    [notifView refresh];
    
    
    
    
    // Zookeeper Image
    zookeeperImage = CCSprite::create("[email protected]");
    zookeeperImage->setScaleX(zookeeperImage->getScaleX()*dScaleFactorX);
    zookeeperImage->setScaleY(zookeeperImage->getScaleY()*dScaleFactorY);
    zookeeperImage->setPosition(ccp(90 * dScaleFactorX, 370* dScaleFactorY));
    addChild(zookeeperImage);
    
    
    
    
    CCMenu* menu = CCMenu::create(primaryButton,actionButton,howToButton,StoreButton,engageButton,infinityButton,getFreeAppButton,moreButton,NULL);
    menu->setPosition(CCPointZero);
    addChild(menu);
    
}
Beispiel #7
0
BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
{
    this->setTouchEnabled(true);

    // ask director the the window size
    CCSize size = CCDirector::sharedDirector()->getWinSize();

    // create and initialize a Label
    this->m_pLabelShouldRetain = CCLabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter);
    this->m_pLabelShouldRetain->retain();

    this->m_pArrowsBarShouldRetain = CCSprite::create("Images/arrowsBar.png");
    this->m_pArrowsBarShouldRetain->retain();
    this->m_pArrowsShouldRetain = CCSprite::create("Images/arrows.png");
    this->m_pArrowsShouldRetain->retain();

    CCMenuItemFont::setFontSize(20);
    CCMenuItemFont *longSentences = CCMenuItemFont::create("Long Flowing Sentences", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
    CCMenuItemFont *lineBreaks = CCMenuItemFont::create("Short Sentences With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
    CCMenuItemFont *mixed = CCMenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
    CCMenu *stringMenu = CCMenu::create(longSentences, lineBreaks, mixed, NULL);
    stringMenu->alignItemsVertically();

    longSentences->setColor(ccRED);
    m_pLastSentenceItem = longSentences;
    longSentences->setTag(LongSentences);
    lineBreaks->setTag(LineBreaks);
    mixed->setTag(Mixed);

    CCMenuItemFont::setFontSize(30);

    CCMenuItemFont *left = CCMenuItemFont::create("Left", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
    CCMenuItemFont *center = CCMenuItemFont::create("Center", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
    CCMenuItemFont *right = CCMenuItemFont::create("Right", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
    CCMenu *alignmentMenu = CCMenu::create(left, center, right, NULL);
    alignmentMenu->alignItemsHorizontallyWithPadding(alignmentItemPadding);

    center->setColor(ccRED);
    m_pLastAlignmentItem = center;
    left->setTag(LeftAlign);
    center->setTag(CenterAlign);
    right->setTag(RightAlign);

    // position the label on the center of the screen
    this->m_pLabelShouldRetain->setPosition(ccp(size.width/2, size.height/2));

    this->m_pArrowsBarShouldRetain->setVisible(false);

    float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width;
    this->m_pArrowsBarShouldRetain->setScaleX(arrowsWidth / this->m_pArrowsBarShouldRetain->getContentSize().width);
    this->m_pArrowsBarShouldRetain->setPosition(ccp(((ArrowsMax + ArrowsMin) / 2) * size.width, this->m_pLabelShouldRetain->getPosition().y));

    this->snapArrowsToEdge();

    stringMenu->setPosition(ccp(size.width/2, size.height - menuItemPaddingCenter));
    alignmentMenu->setPosition(ccp(size.width/2, menuItemPaddingCenter+15));

    this->addChild(this->m_pLabelShouldRetain);
    this->addChild(this->m_pArrowsBarShouldRetain);
    this->addChild(this->m_pArrowsShouldRetain);
    this->addChild(stringMenu);
    this->addChild(alignmentMenu);
}
Beispiel #8
0
bool GameOver::init(){
    if(!CCLayerColor::initWithColor(ccc4(0, 0, 0, 150))){
        return false;
    }
    setTouchEnabled(true);
   
    
   CCSize size= CCDirector::sharedDirector()->getWinSize();
    label1=CCLabelTTF::create("+10", "黑体", 35);
    label1->setPosition(ccp(size.width/2, size.height/2-25));
    this->addChild(label1,2);
    CCSprite *bg= CCSprite::create("over_bg.png");
    bg->setPosition(ccp(size.width/2, size.height/2));
    this->addChild(bg,0);
    CCMenuItemImage * item=CCMenuItemImage::create("back_up.png", "back_down.png", this, menu_selector(GameOver::goback));
    item->setPosition(ccp(0, -200));
    menu=CCMenu::create(item,NULL);
    this->addChild(menu,1);
    
    return true;
    
}
Beispiel #9
0
void SGShowAllLayer::initView()
{
    ResourceManager::sharedInstance()->bindTexture("sgstrenglayer/sgstrenglayer.plist", RES_TYPE_LAYER_UI, sg_showAllLayer, LIM_PNG_AS_PNG);
    ResourceManager::sharedInstance()->bindTexture("sgmainlayer/sgmainlayer.plist", RES_TYPE_LAYER_UI, sg_showAllLayer, LIM_PNG_AS_PNG);
    ResourceManager::sharedInstance()->bindTexture("sgembattlelayer/sgembattlelayer.plist", RES_TYPE_LAYER_UI, sg_showAllLayer, LIM_PNG_AS_PNG);

    float h = SGMainManager::shareMain()->getHeadHeight();
    float b = SGMainManager::shareMain()->getBottomHeight();
    CCSize s= CCDirector::sharedDirector()->getWinSize();
        
    CCSprite *titleBg = CCSprite::createWithSpriteFrameName("barrack_title_bg.png");
    this->addChild(titleBg);
    titleBg->setAnchorPoint(ccp(0.5, 1));
    titleBg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, - h )));
    
    SGButton *backBtn = SGButton::create("redbtn_jiao.png",
                                         "public_font_back.png",
                                         this,
                                         menu_selector(SGShowAllLayer::backHandler),
                                         ccp(-18, 0),
                                         false,
                                         true);
    this->addBtn(backBtn);
    backBtn->setAnchorPoint(ccp(0, 0.5));
    backBtn->setPosition(ccp(0, titleBg->getPosition().y-titleBg->getContentSize().height/2));
    
    SGButton *sortBtn = SGButton::create("redbtn_jiao.png",
                                         "public_range.png",
                                         this,
                                         menu_selector(SGShowAllLayer::sortHandler),
                                         ccp(18, 0),
                                         true,
                                         true);
    this->addBtn(sortBtn);
    sortBtn->setAnchorPoint(ccp(1, 1));
    sortBtn->setPosition(ccpAdd(SGLayout::getPoint(kBottomRight),ccp(0, titleBg->getPosition().y)));
    
    CCSprite *font2 = CCSprite::createWithSpriteFrameName("font_szwjscsx.png");
    font2->setPosition(ccp(s.width/2, titleBg->getPosition().y - titleBg->getContentSize().height/2));
    this->addChild(font2);
    
    scrollView = SNSScrollView::create(CCRectMake(0, 280, s.width, s.height - h - b  - titleBg->getContentSize().height-10));
    scrollView->setPosition(ccpAdd(SGLayout::getPoint(kBottomLeft), ccp(0, b)));
    this->addChild(scrollView);
    scrollView->setHorizontal(false);
    scrollView->setVertical(true);
    
//    CCArray *cards = SGPlayerInfo::sharePlayerInfo()->getShowOfficerCards();
    int id = SGTeamgroup::shareTeamgroupInfo()->getiscurrent();
    CCArray *cards = SGTeamgroup::shareTeamgroupInfo()->getEmbattleOfficers(id);
    int bagSize = SGPlayerInfo::sharePlayerInfo()->getPlayerBagSize();
    CCLOG("bagSize:%d",bagSize);
    bagSize = 52;
    float row = (float)bagSize/5;
    int allrow = ceilf(row);
    float itemWidth = 0;
    float itemHeight = 0;
    
    for (int i = 0; i<bagSize; i++)
    {
        SGOfficerCard *card = NULL;
        SGEmbattleItem *item = NULL;
        if (i<cards->count())
        {
            card = (SGOfficerCard *)cards->objectAtIndex(i);
            
        }
        if (card)
        {
            item = SGEmbattleItem::create(this, card,SGTeamgroup::shareTeamgroupInfo()->getiscurrent());
        }
        else
        {
            item = SGEmbattleItem::create(this,(i+1),SGTeamgroup::shareTeamgroupInfo()->getiscurrent());
        }
        
        cardArray->addObject(item);
        scrollView->m_body->addChild(item);
        itemWidth = item->getWidth();
        itemHeight = item->getHeight();
        
        CCSize s = CCDirector::sharedDirector()->getWinSize();
        float wid = s.width - itemWidth*5 ;
        item->setPosition(ccp(i%5*(itemWidth + 20)+10 + wid/2, (item->getHeight() + 20)*allrow - item->getHeight() * .5 - (i/5) * (itemHeight + 20)));
    }
    
    scrollView->setBodySize(CCSizeMake((itemWidth + 20) *5 , (itemHeight + 20)*allrow));
    
    scrollviewRect = CCRectMake(0, b, s.width, s.height - h - b - titleBg->getContentSize().height-10);
    
}
/*
* 首先通过create函数创建一个节点anode,把anode作为子节点使用addChild函数加入
* BackScreen场景类对象中;然后把本来作为子节点加
* 入BackScreen场景类对象中的对象,使用addChild
* 函数作为子节点加入anode中。这些对象包括菜单类
* 对象、标签类对象、人物精灵类对象。这些对象的类
* 都是CCNode类的子类。
*/
bool BackScreen::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayer::init() )
	{
		return false;
	}

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


	/// 定义一个节点
	CCNode *anode = CCNode::create();
	/// 将节点作为子节点加入场景类中;
	this->addChild(anode, 0);

	CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
		"CloseNormal.png",
		"CloseSelected.png",
		this,
		menu_selector(BackScreen::menuCloseCallback));

	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
		origin.y + pCloseItem->getContentSize().height/2));

	// create menu, it's an autorelease object
	CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
	pMenu->setPosition(CCPointZero);
	/// 将菜单作为子节点加入anode节点中; 
	anode->addChild(pMenu, 1);

	CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);

	// position the label on the center of the screen
	pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
		origin.y + visibleSize.height - pLabel->getContentSize().height));

	// add the label as a child to this layer
	anode->addChild(pLabel, 1);

	// add "HelloWorld" splash screen"
	CCSprite* pSprite = CCSprite::create("PIC_BJ_ZCJ_XH1.png");

	// position the sprite on the center of the screen
	pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

	/// 将菜单作为子节点加入anode节点中;
	anode->addChild(pSprite, 0);
	
	/// 设置节点位置
	anode->setPosition(ccp(50, 50));

	/// 设置缩放
	anode->setScale(0.5);

	/// 设置旋转
	
	anode->setRotation(90.0);

	return true;
}
Beispiel #11
0
////////////////////////////////////
//
// HiResDemo
//
///////////////////////////////////
void HiResDemo::onEnter()
{
    CCLayer::onEnter();

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

    CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
    label->setPosition(ccp(s.width/2, s.height-50));
    addChild(label, 1);

    std::string sSubTitle = subtitle();
    if (sSubTitle.length())
    {
        CCLabelTTF *subLabel = CCLabelTTF::labelWithString(sSubTitle.c_str(), "Thonburi", 16);
        subLabel->setPosition(ccp(s.width/2, s.height-80));
        addChild(subLabel, 1);
    }
    
    CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(HiResDemo::backCallback) );
    CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(HiResDemo::restartCallback) );
    CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(HiResDemo::nextCallback) );

    CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

    menu->setPosition( CCPointZero );
    item1->setPosition( CCPointMake( s.width/2 - 100,30) );
    item2->setPosition( CCPointMake( s.width/2, 30) );
    item3->setPosition( CCPointMake( s.width/2 + 100,30) );

    addChild(menu, 1);
}
Beispiel #12
0
// 初始化底部Bar
void HelpView::initBottomBar(CCSize winSize) 
{
	/////////////////////////////////////////// 底部条 ////////////////////////////////////////
	
	this->footerBarNode = CCNode::create() ;
	this->footerBarNode->setAnchorPoint(ccp(0, 0)) ;
	this->footerBarNode->setPosition(ccp(0, -5)) ;	
	this->addChild(this->footerBarNode) ;

	/////////////////////////////////////// 定义背景 /////////////////////////////////////////
	// 背景
	CCSprite* bottomBarBg = CCSprite::create("bg_bottom_bar.png") ;
	bottomBarBg->setAnchorPoint(ccp(0.5, 0)) ;
	bottomBarBg->setPosition(ccp(winSize.width/2, 0)) ;
	this->footerBarNode->addChild(bottomBarBg, 1) ;

	// 定义底部条高度
	const float footerBarNode_height = bottomBarBg->getContentSize().height ;
	// 设置底部条的高和宽
	this->footerBarNode->setContentSize(CCSizeMake(winSize.width, footerBarNode_height)) ;

	// 背景遮罩层
	CCSprite* bottomBg = CCSprite::create("bg_bottom.png") ;
	bottomBg->setAnchorPoint(ccp(0, 1)) ;
	bottomBg->setPosition(ccp(0, footerBarNode_height)) ;
	this->footerBarNode->addChild(bottomBg, 0) ;


	CCSpriteBatchNode* bottomIcon = CCSpriteBatchNode::create("bg_bottom_icon.png") ;

	// 左边的icon
	CCSprite* leftIcon = CCSprite::createWithTexture(bottomIcon->getTexture()) ;
	leftIcon->setAnchorPoint(ccp(0, 0)) ;
	leftIcon->setPosition(ccp(0, 0)) ;
	this->footerBarNode->addChild(leftIcon, 1) ;

	// 右边的icon
	CCSprite* rightIcon = CCSprite::createWithTexture(bottomIcon->getTexture()) ;
	rightIcon->setAnchorPoint(ccp(1, 0)) ;
	rightIcon->setPosition(ccp(winSize.width, 0)) ;
	rightIcon->setFlipX(true) ; // 水平翻转
	this->footerBarNode->addChild(rightIcon, 1) ;

	const float menuItem_margin = 50.0f ;		// 距离中间位置的距离
	const float menuItem_padding = 100.0f ;		// menuItem之间的间隔

	// 底部菜单
	CCMenu* footerMenu = CCMenu::create() ;
	footerMenu->setContentSize(CCSizeMake(winSize.width, footerBarNode_height) ) ;
	footerMenu->setAnchorPoint(ccp(0, 0)) ;
	footerMenu->setPosition(ccp(0, 0)) ;
	this->footerBarNode->addChild(footerMenu, 2) ;

	// 活动菜单
	CCMenuItemImage* activityMenuItem = CCMenuItemImage::create("menu_activity_n.png", "menu_activity_s.png", 
																this, menu_selector(HelpView::menuActivityClickCallback)) ;
	activityMenuItem->setAnchorPoint(ccp(1, 1)) ;
	activityMenuItem->setPosition(ccp(winSize.width/2-menuItem_margin, footerBarNode_height-3)) ;
	footerMenu->addChild(activityMenuItem) ;

	// 获取menuItem宽度
	const float menuItem_width = activityMenuItem->getContentSize().width ;


	// 信息菜单	
	CCMenuItemImage* infoMenuItem = CCMenuItemImage::create("menu_message_n.png", "menu_message_s.png", 
															this, menu_selector(HelpView::menuInfoClickCallback)) ;
	infoMenuItem->setAnchorPoint(ccp(1, 1)) ;
	infoMenuItem->setPosition(ccp(winSize.width/2-menuItem_margin-menuItem_width-menuItem_padding, footerBarNode_height-3)) ;
	footerMenu->addChild(infoMenuItem) ;

	// 商城菜单
	CCMenuItemImage* shopMenuItem = CCMenuItemImage::create("menu_shop_n.png", "menu_shop_s.png", 
															this, menu_selector(HelpView::menuShopClickCallback)) ;
	shopMenuItem->setAnchorPoint(ccp(0, 1)) ;
	shopMenuItem->setPosition(ccp(winSize.width/2+menuItem_margin, footerBarNode_height-3)) ;
	footerMenu->addChild(shopMenuItem) ;

	// 菜单菜单
	CCMenuItemImage* moreMenuItem = CCMenuItemImage::create("menu_more_n.png", "menu_more_s.png" , 
															this, menu_selector(HelpView::menuMoreClickCallback)) ;
	moreMenuItem->setAnchorPoint(ccp(0, 1)) ;
	moreMenuItem->setPosition(ccp(winSize.width/2+menuItem_margin+menuItem_width+menuItem_padding, footerBarNode_height-3)) ;
	footerMenu->addChild(moreMenuItem) ;
	
	// 更多菜单背景
	CCSprite* moreMenuBg = CCSprite::create("bg_more_menu.png") ;
	moreMenuBg->setAnchorPoint(ccp(0,0)) ;
	moreMenuBg->setPosition(ccp(0, 0)) ;

	const float moreMenu_width = moreMenuBg->getContentSize().width ;
	const float moreMenu_height = moreMenuBg->getContentSize().height ;

	// 更多菜单节点
	moreMenuNode = CCNode::create() ;
	moreMenuNode->setContentSize(moreMenuBg->getContentSize()) ;		// 设置moreMenuNode的尺寸
	moreMenuNode->setAnchorPoint(ccp(1, 0)) ;
	moreMenuNode->setPosition(ccp(winSize.width-80, 80)) ;
	moreMenuNode->retain() ;
	// this->addChild(moreMenuNode, 5, MORE_MENU_NODE_TAG) ;

	moreMenuNode->addChild(moreMenuBg, 0) ;	// 将背景加入到更多菜单中		

	// 更多菜单
	CCMenu* moreMenu = CCMenu::create() ;
	moreMenu->setAnchorPoint(ccp(0, 0)) ;
	moreMenu->setPosition(ccp(0, 0)) ;
	moreMenuNode->addChild(moreMenu, 1, MORE_MENU_TAG) ;


	// 排行榜菜单项
	CCMenuItemImage* rankingMenuItem = CCMenuItemImage::create("menu_ranking_n.png", "menu_ranking_s.png" , 
															this, menu_selector(GameMenuView::menuRankingClickCallback)) ;
	rankingMenuItem->setAnchorPoint(ccp(0, 1)) ;
	rankingMenuItem->setPosition(ccp(10, moreMenu_height-10)) ;
	moreMenu->addChild(rankingMenuItem) ;

	// 任务菜单
	CCMenuItemImage* taskMenuItem = CCMenuItemImage::create("menu_task_n.png", "menu_task_s.png" , 
															this, menu_selector(GameMenuView::menuTaskClickCallback)) ;
	taskMenuItem->setAnchorPoint(ccp(1, 1)) ;
	taskMenuItem->setPosition(ccp(moreMenu_width-10, moreMenu_height-10)) ;
	moreMenu->addChild(taskMenuItem) ;

	// 好友菜单
	CCMenuItemImage* friendMenuItem = CCMenuItemImage::create("menu_friend_n.png", "menu_friend_s.png", 
															this, menu_selector(GameMenuView::menuFriendClickCallback)) ;	
	friendMenuItem->setAnchorPoint(ccp(0, 0)) ;
	friendMenuItem->setPosition(ccp(10, 5)) ;
	moreMenu->addChild(friendMenuItem) ;

	// 客服菜单
	CCMenuItemImage* customserviceMenuItem = CCMenuItemImage::create("menu_cs_n.png", "menu_cs_s.png", 
																this, menu_selector(GameMenuView::menuSettingClickCallback)) ;
	customserviceMenuItem->setAnchorPoint(ccp(1, 0)) ;
	customserviceMenuItem->setPosition(ccp(moreMenu_width-10, 5)) ;
	moreMenu->addChild(customserviceMenuItem) ;
	
}
Beispiel #13
0
// 初始化顶部bar
void HelpView::initTopBar(CCSize winSize) 
{
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// topBarNode 背景
	CCSprite* topBarBg = CCSprite::create("bg_nav_top.png") ;
	topBarBg->setAnchorPoint(ccp(0.5, 0)) ;
	topBarBg->setPosition(ccp(winSize.width/2, 0)) ;

	const float topBar_height = topBarBg->getContentSize().height ; 

	

	// 顶部条信息 //////////////////////////////////////////////////////////////////////////////////////
	this->topBarNode = CCNode::create() ;
	this->topBarNode->setContentSize(CCSizeMake(winSize.width, topBar_height)) ;
	this->topBarNode->setAnchorPoint(ccp(0, 0)) ;
	this->topBarNode->setPosition(ccp(0, winSize.height - topBar_height)) ;
	this->addChild(this->topBarNode, 0, 1) ;

	// 将topBarNode背景加入到topBarNode
	this->topBarNode->addChild(topBarBg, 0 ) ;


	///////////////////////////// 左侧布局 //////////////////////////
	CCNode* leftNode = CCNode::create() ;
	leftNode->setContentSize(CCSizeMake(300, topBar_height)) ;
	leftNode->setAnchorPoint(ccp(0, 0.5)) ;
	leftNode->setPosition(ccp(30, topBar_height/2)) ;
	this->topBarNode->addChild(leftNode, 1) ;

	// 头像
	CCSprite* headPortraitSprite = CCSprite::create("user/head_default_f2.png") ;
	headPortraitSprite->setAnchorPoint(ccp(0, 0)) ;
	headPortraitSprite->setPosition(ccp(0, 10)) ;
	headPortraitSprite->setScale(0.8) ;
	leftNode->addChild(headPortraitSprite) ;

	// 昵称
	CCLabelTTF* nikeNameLabel = CCLabelTTF::create("昵称:我是主角", "font01.ttf", 22.0f) ;
	// nikeNameLabel->setColor(ccc3(191, 173, 111)) ;
	nikeNameLabel->setAnchorPoint(ccp(0, 0)) ;
	nikeNameLabel->setPosition(ccp(70, topBar_height/2+2)) ;
	nikeNameLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; 			// 水平对齐方式
	nikeNameLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; 	// 垂直对齐方式
	leftNode->addChild(nikeNameLabel) ;

	// 金币
	CCLabelTTF* goldCoinLabel = CCLabelTTF::create("金币:10000", "font01.ttf", 22.0f) ;
	goldCoinLabel->setAnchorPoint(ccp(0, 1)) ;
	goldCoinLabel->setPosition(ccp(70, topBar_height/2)) ;
	goldCoinLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; 			// 水平对齐方式
	goldCoinLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; 	// 垂直对齐方式
	leftNode->addChild(goldCoinLabel) ;


	// 信息
	CCSprite* titleMsg = CCSprite::create("icon_title_help.png") ;
	titleMsg->setAnchorPoint(ccp(0.5, 0.5)) ;
	titleMsg->setPosition(ccp(winSize.width/2, topBar_height/2)) ;
	this->topBarNode->addChild(titleMsg, 1) ;

	// 分割线
	CCSprite* spliteLineLeft = CCSprite::create("icon_top_nav_splite.png") ;
	spliteLineLeft->setAnchorPoint(ccp(0, 1)) ;
	spliteLineLeft->setPosition(ccp(winSize.width/3+10, topBar_height)) ;
	this->topBarNode->addChild(spliteLineLeft, 1) ;


	// 分割线
	CCSprite* spliteLineRight = CCSprite::create("icon_top_nav_splite.png") ;
	spliteLineRight->setAnchorPoint(ccp(0, 1)) ;
	spliteLineRight->setPosition(ccp(winSize.width*2/3-20, topBar_height)) ;
	this->topBarNode->addChild(spliteLineRight, 1) ;


	/////////////////////////////////////////////////////////////////////////////////////////////////
	/****************************** 菜单选项 ********************************************************/
	// 右侧menu
	const float right_width = 200 ;
	const float item_width = 55 ;

	
	// 礼物
	CCMenuItemImage* menuGifts = CCMenuItemImage::create("menu_gifts_n.png", "menu_gifts_s.png", this,
															menu_selector(HelpView::menuGiftsClickCallback)) ;
	// menuBack->setContentSize(CCSizeMake(67, 68)) ;
	menuGifts->setAnchorPoint(ccp(0, 0.5)) ;
	menuGifts->setPosition(ccp(0, topBar_height/2)) ;
	//menuGifts->setPosition(ccp(right_width-2*item_width, topBar_height/2)) ;
	//rightMenu->addChild(menuGifts) ;

	// 返回大厅
	CCMenuItemImage* menuBack = CCMenuItemImage::create("menu_back_n.png", "menu_back_s.png", this,
															menu_selector(MessageView::menuBackClickCallback)) ;
	menuBack->setAnchorPoint(ccp(0, 0.5)) ;
	menuBack->setPosition(ccp(2*(item_width+10), topBar_height/2)) ;
	//menuBack->setPosition(ccp(right_width, topBar_height/2)) ;
	//rightMenu->addChild(menuBack) ;

	// 设置
	CCMenuItemImage* menuSetting = CCMenuItemImage::create("menu_setting_n.png", "menu_setting_s.png", this,
															menu_selector(MessageView::menuSettingClickCallback)) ;
	// menuBack->setContentSize(CCSizeMake(67, 68)) ;
	
	menuSetting->setAnchorPoint(ccp(0, 0.5)) ;
	menuSetting->setPosition(ccp(item_width+10, topBar_height/2)) ;
	//menuSetting->setPosition(ccp(right_width-item_width, topBar_height/2)) ;


	//rightMenu->addChild(menuSetting) ;
	CCMenu* rightMenu = CCMenu::create(menuGifts, menuBack, menuSetting, NULL) ;
	rightMenu->setContentSize(CCSizeMake(winSize.width/4, topBar_height)) ;
	rightMenu->setAnchorPoint(ccp(0, 0)) ;
	rightMenu->setPosition(ccp(winSize.width*3/4-10, 0)) ;	
	this->topBarNode->addChild(rightMenu, 1) ;
}
Beispiel #14
0
// on "init" you need to initialize your instance
bool GameLayer::init()
{
	if (!CCLayer::init())
		return false;

	SCREEN_WIDTH = CCDirector::sharedDirector()->getWinSize().width;
	SCREEN_HEIGHT = CCDirector::sharedDirector()->getWinSize().height;
	bPaused = false;
	//Jerry--LB
	receiveRank();

	CCSprite* sprite = ThemeManager::sharedInstance()->spriteWithImageFile("background.png");//ThemeManager::sharedInstance()->spriteWithImageFile("background.png");
	sprite->setScaleX(SCREEN_WIDTH/sprite->getContentSize().width);
	sprite->setScaleY(SCREEN_HEIGHT/sprite->getContentSize().height);
	sprite->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
	this->addChild(sprite,1);

	float iMenuWidthOffset = 0.55;
	CCSprite* startNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_start.png");
	CCSprite* startSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_start.png");
	CCMenuItemSprite* pStartItemSprite = CCMenuItemSprite::itemWithNormalSprite(startNormal, startSelected, this, menu_selector(GameLayer::startButtonClick));

	CCMenu* pStartMenu = CCMenu::menuWithItems(pStartItemSprite,NULL);
	pStartMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.6));
	pStartItemSprite->setScale(LL_BUTTON_SCALE_VALUE);

	//Jerry--Action
	CCScaleTo* large=CCScaleTo::actionWithDuration(0.5,0.7*LL_SCREEN_SCALE_VALUE);
	CCScaleTo* small=CCScaleTo::actionWithDuration(0.5,LL_BUTTON_SCALE_VALUE);
	CCDelayTime *waiting=CCDelayTime::actionWithDuration(1.0f);
	CCFiniteTimeAction* action= CCSequence::actions(waiting,large,small,waiting,NULL);
	CCActionInterval* actionShake=CCRepeatForever::actionWithAction((CCActionInterval*)action);
	pStartItemSprite->stopAllActions();  
	pStartItemSprite->runAction(actionShake); 

	this->addChild(pStartMenu, 3);

	/*CCSprite* leaderboardNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
	CCSprite* leaderboardSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
	CCSprite* leaderboardDisabled = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
	CCMenuItemSprite* pleaderboardItemSprite = CCMenuItemSprite::itemWithNormalSprite(leaderboardNormal, leaderboardSelected, leaderboardDisabled, this, menu_selector(GameLayer::levelButtonClick));
	pleaderboardItemSprite->setScale(0.8);
	CCMenu* pleaderboardMenu = CCMenu::menuWithItems(pleaderboardItemSprite,NULL);
	pleaderboardMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.4));

	this->addChild(pleaderboardMenu, 3);*/

	CCSprite* instructionNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_instruction.png");
	CCSprite* instructionSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_instruction.png");
	CCMenuItemSprite* pinstructionItemSprite = CCMenuItemSprite::itemWithNormalSprite(instructionNormal, instructionSelected,this, menu_selector(GameLayer::instructionButtonClick));
	pinstructionItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
	CCMenu* pinstructionMenu = CCMenu::menuWithItems(pinstructionItemSprite,NULL);
	pinstructionMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.5));

	this->addChild(pinstructionMenu, 3);

	CCSprite* quitNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_quit.png");
	CCSprite* quitSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_quit.png");
	quitSelected->setScale(1.1);
	CCMenuItemSprite* pquitItemSprite = CCMenuItemSprite::itemWithNormalSprite(quitNormal, quitSelected, this, menu_selector(GameLayer::finishButtonClick));
	pquitItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
	CCMenu* pquitMenu = CCMenu::menuWithItems(pquitItemSprite,NULL);
	pquitMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.2));

	this->addChild(pquitMenu, 3);
	//Jerry--Code
	CCSprite* lbNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
	CCSprite* lbSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
	lbSelected->setScale(1.1);
	CCMenuItemSprite* plbItemSprite = CCMenuItemSprite::itemWithNormalSprite(lbNormal, lbSelected,  this, menu_selector(GameLayer::leaderboardButtonClick));
	plbItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
	CCMenu* plbMenu = CCMenu::menuWithItems(plbItemSprite,NULL);
	plbMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.4));

	this->addChild(plbMenu, 3);

	//Jerry--Code
	CCSprite* thNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_theme.png");
	CCSprite* thSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_theme.png");
	thSelected->setScale(1.1);
	CCMenuItemSprite* pthItemSprite = CCMenuItemSprite::itemWithNormalSprite(thNormal, thSelected, this, menu_selector(GameLayer::themeButtonClick));
	pthItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
	CCMenu* pthMenu = CCMenu::menuWithItems(pthItemSprite,NULL);
	pthMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.3));

	this->addChild(pthMenu, 3);

	if(getFlags("INPUT_NICKNAME_FLAG") == 0) {
		updateNickname(NULL);
		setFlags("INPUT_NICKNAME_FLAG", 1);
	}

	//InitBdAd();
	//showDoSplash();

	PlatformManager::sharedInstance()->showBanner();
	PlatformManager::sharedInstance()->showInter();
	//showDoBanner();
	return true;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	
	float visibleW = visibleSize.width;
	float visibleH = visibleSize.height;
    /////////////////////////////
    // 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(
                               "CloseNormal.png",
                               "CloseSelected.png",
                               this,
                               menu_selector(HelloWorld::menuCloseCallback));
    CCMenuItemImage *pPlayItem = CCMenuItemImage::create(
								"btn-play-normal.png",
								"btn-play-selected.png",
								this,
								menu_selector(HelloWorld::menuPlayCallback));
	float closeItemW = pCloseItem->getContentSize().width;
	float closeItemH = pCloseItem->getContentSize().height;
	
	pCloseItem->setPosition(ccp(closeItemW/2 , visibleH+origin.y - closeItemH/2));
	
	float playItemW = pPlayItem->getContentSize().width;
	float playItemH = pPlayItem->getContentSize().height;
	pPlayItem->setScale(0.7f);
	pPlayItem->setPosition(ccp(visibleW-playItemW*0.5, origin.y+playItemH*0.6));
    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, pPlayItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);
    
    pLabelTime = CCLabelTTF::create("Time:0", "Arial", 15);
	pLabelScore = CCLabelTTF::create("Score:0", "Arial", 15);

    // position the label on the center of the screen
    pLabelTime->setPosition(ccp(origin.x + visibleW/2,
		origin.y+ visibleH - pLabelTime->getContentSize().height));
	
	pLabelScore->setPosition(ccp(visibleW-playItemW*0.5,
		origin.y+visibleH/2));

    // add the label as a child to this layer
    this->addChild(pLabelTime, 1);
	this->addChild(pLabelScore, 1);


	int a = visibleW>visibleH?visibleH:visibleW;
	CCSize squreSize(a*0.8, a*0.8);
	
	dw = squreSize.width/8;
	dh = squreSize.height/8;
	float startX = origin.x + visibleW/2 - squreSize.width/2;
	float startY = origin.y + visibleH/2 - squreSize.height/2;
	diamondRect = CCRect(startX, startY, squreSize.width, squreSize.height);
	char str[30];
	
	srand(time(NULL));
	for(int i = 0; i < 64; i ++){
		base[i] = getDiamond(str);
		CCSprite* pSprite = CCSprite::create(str);
		diamonds.push_back(pSprite);
		//fprintf(file, "%s %d\n", str, base[i]);
	}
	//fclose(file);
	for(int i = 0; i < 8; i ++){
		for(int j = 0; j < 8; j ++){
			CCSprite *pSprite =  diamonds[j*8+i];
			float scaleX = dw/pSprite->getContentSize().width;
			float scaleY = dh/pSprite->getContentSize().height;
			pSprite->setScaleX(scaleX);
			pSprite->setScaleY(scaleY);
			pSprite->setPosition(ccp(startX+i*dw+dw/2, startY+(7-j)*dh+dh/2));
			this->addChild(pSprite, i*8+j);
		}
	}
	m_score = -1;
	this->setTouchEnabled(true);
	
    return true;
}
bool PoptipLayer::addButton(const char *normalImage, const char *selectedImage, const char *title, int tag){
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCPoint pCenter = ccp(winSize.width / 2, winSize.height / 2);

	// 创建图片菜单按钮
	CCMenuItemImage* menuImage = CCMenuItemImage::create(normalImage, selectedImage, this, menu_selector(PoptipLayer::buttonCallback));
	menuImage->setTag(tag);
	menuImage->setPosition(pCenter);

	CCSize imenu = menuImage->getContentSize();
	CCLabelTTF* ttf = CCLabelTTF::create(title, "", 20);
	ttf->setColor(ccc3(0, 0, 0));
	ttf->setPosition(ccp(imenu.width / 2, imenu.height / 2));
	menuImage->addChild(ttf);

	getMenuButton()->addChild(menuImage);
	return true;
}
Beispiel #17
0
void LogInScene::LogInTableDraw(int _index){
    
    CCMenu* popUpMenu = (CCMenu*)popUpMenuLayer->getChildByTag(998);
    CCMenu* beginMenu = (CCMenu*)this->getChildByTag(997);
    popUpMenu->setTouchEnabled(false);
    if (beginMenu!=NULL)
        beginMenu->setTouchEnabled(false);
    
    //1.基本层
    AccountLayer = CCLayer::create();
    AccountLayer->setPosition(CCPointZero);
    addChild(AccountLayer,10);
    
    //2.黑色遮罩:不在该移动层上
    CCLayerColor* black = CCLayerColor::create(ccc4(0, 0, 0, 155));
    black->setPosition(CCPointZero);
    AccountLayer->addChild(black,0);
    
    //3.木板
    CCSprite* LogInTable = CCSprite::createWithSpriteFrameName("LogInTable.png");
    LogInTable->setPosition(ccp(size.width/2, size.height/2+winDif*2));
    AccountLayer->addChild(LogInTable,1);
    
    //3.edit box - user name
    CCScale9Sprite *UserNameTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
    CCEditBox *UserNameBox=CCEditBox::create(CCSizeMake(195, 44), UserNameTexture);
    UserNameBox->setPosition(ccp(size.width*8/15, size.height*0.561+winDif*2));
    UserNameBox->setFontName("Arial Rounded MT bold");
    UserNameBox->setMaxLength(20);
    UserNameBox->setInputMode(kEditBoxInputModeAny);
    UserNameBox->setInputFlag(kEditBoxInputFlagSensitive);
    UserNameBox->setReturnType(kKeyboardReturnTypeDone);
    UserNameBox->setDelegate(this);
    AccountLayer->addChild(UserNameBox,2,10);
    
    //4.edit box - password
    CCScale9Sprite *PasswordTexture = CCScale9Sprite::createWithSpriteFrameName("textTable.png");
    CCEditBox *PasswordBox = CCEditBox::create(CCSizeMake(195, 44), PasswordTexture);
    PasswordBox->setPosition(ccp(size.width*8/15, size.height*0.486+winDif*2));
    PasswordBox->setFontName("Arial Rounded MT bold");
    PasswordBox->setMaxLength(50);
    PasswordBox->setInputMode(kEditBoxInputModeAny);
    PasswordBox->setInputFlag(kEditBoxInputFlagPassword);
    PasswordBox->setReturnType(kKeyboardReturnTypeDone);
    PasswordBox->setDelegate(this);
    AccountLayer->addChild(PasswordBox,2,11);
    
    //5.登录注册按钮
    CCMenuItemSprite* Item1;
    if (_index == 0){
        CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("signUpButtonGreen.png");
        CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("signUpButtonGreen-s.png");
        Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::SignUpHTTP));
    }
    else if (_index == 1){
        CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("binding.png");
        CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("binding-s.png");
        Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::bindUserAccountHTTP));
    }
    else if (_index == 2){
        CCSprite* item1Sprite = CCSprite::createWithSpriteFrameName("LogInButton.png");
        CCSprite* item1Sprite_s = CCSprite::createWithSpriteFrameName("LogInButton-s.png");
        Item1 = CCMenuItemSprite::create(item1Sprite,item1Sprite_s,this,menu_selector(LogInScene::LogInHTTP));
    }
    CCSprite* item2Sprite = CCSprite::createWithSpriteFrameName("cancelButton.png");
    CCSprite* item2Sprite_s = CCSprite::createWithSpriteFrameName("cancelButton-s.png");
    CCMenuItemSprite* Item2 = CCMenuItemSprite::create(item2Sprite,item2Sprite_s,this,menu_selector(LogInScene::closeThisLayer));
    Item1->setPosition(ccp(winSize.width*11.5/30,size.height*0.42+winDif*2));
    Item2->setPosition(ccp(winSize.width*18.5/30,size.height*0.42+winDif*2));
    CCMenu* LogInMenu = CCMenu::create(Item1,Item2,NULL);
    LogInMenu->setPosition(CCPointZero);
    AccountLayer->addChild(LogInMenu,3);
}
void SGAnnouncementLayer::initScrollView()
{
	//ResourceManager::sharedInstance()->bindTexture("sgannouncementlayer/sgannouncementlayer2.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
    m_scrollview->getContainer()->removeAllChildrenWithCleanup(true);
    int positionY = 0;// Y轴纵向偏移,
	int border_shift = 20;//内容窗口偏移
	
    int text_wid_expand = 40;//文本区宽度扩展
	if (CCEGLView::sharedOpenGLView()->getFrameSize().width == ipadResource.size.width
        ||CCEGLView::sharedOpenGLView()->getFrameSize().width == ipadhdResource.size.width)
	{
		text_wid_expand = 28;
	}
	
	//记录上一个内容窗口的底线位置
	float lastWindowBorderPos = 0.0f;
    for(int i = 0; i < m_arrayAnn->count(); i++)
	//for (int i = 0; i < 6; i++)
    {
		
		//=======================获取数据================================
		SGAnnouncementDataModel *ann = (SGAnnouncementDataModel *)m_arrayAnn->objectAtIndex(i);
		CCString *title = ann->getTitle();
		CCString *content = ann->getContent();

		int viewId = ann->getViewId();//跳转至哪个页面
		//=======================获取数据================================
		
        CCLayer *layer = (CCLayer*)m_scrollview->getContainer();//获取scrollview的容器

        CCLayerColor* contentWindow = initContentWindow(content, viewId > 0);
        contentWindow->setAnchorPoint(ccp(0.5, 0));
        contentWindow->ignoreAnchorPointForPosition(false);
        
        CCSize cwSize = contentWindow->getContentSize();
        
        CCSprite * sprite = CCSprite::createWithSpriteFrameName("Tips.png");
        sprite->setScaleX(cwSize.width / 584.0);
        sprite->setScaleY(cwSize.height / 522.0);
        sprite->setPosition(ccp(cwSize.width * 0.5, cwSize.height * 0.5));
        contentWindow->addChild(sprite, 2);
        
		//根据上一个内容窗口的位置计算下一个窗口的位置
		contentWindow->setPosition(ccp(layer->getContentSize().width * 0.5,
									   lastWindowBorderPos + border_shift));
		
        /* tips.png图片拉长的倍数 */
        float pngScale = cwSize.height / 522 ;
//        CCLOG("*******************>>>");
//        CCLOG("i = %d" , i);
//        CCLOG("title = %s" , title->getCString());
//        CCLOG("content = %s" , content->getCString());
//        CCLOG("pos: x=%f , y = %f" , contentWindow->getPositionX() , contentWindow->getPositionY());
//        CCLOG("cwSize: width=%f, height=%f", cwSize.width, cwSize.height);
//        CCLOG("lastWindowBorderPos = %f" , lastWindowBorderPos);
//        CCLOG("<<<********************");
        lastWindowBorderPos = contentWindow->getPositionY() + cwSize.height;

		//公告title
        CCLabelTTF *label = CCLabelTTF::create(title->getCString(), FONT_PANGWA, 35);
        label->setColor(COLOR_RED);
        label->setAnchorPoint(ccp(0.5 , 1));
		label->setPosition(ccp(cwSize.width *0.5f, cwSize.height - pngScale * 20));
		contentWindow->addChild(label, 100);
		//公告内容
//        CCSize maybeTextSize = stringInLabelRect(content->getCString());
//		CCLabelTTF *label_content=CCLabelTTF::create(content->getCString(), FONT_PENGYOU, 24,CCSizeMake(maybeTextSize.width + text_wid_expand * 4,maybeTextSize.height + text_hei_expand),kCCTextAlignmentLeft);
        CCLabelTTF *label_content=CCLabelTTF::create(content->getCString(), FONT_PENGYOU, 24,CCSizeMake(cwSize.width - 40 * widthFactor, cwSize.height - label->getContentSize().height),kCCTextAlignmentLeft);
		label_content->setAnchorPoint(ccp(0.5, 1));//内容顶线对齐
        label_content->setColor(ccBLACK);
		label_content->setPosition(ccp(label->getPositionX(), label->getPositionY() - label->getContentSize().height));
		label_content->setZOrder(102);
        contentWindow->addChild(label_content);
		
		//点击前往按钮
        if (viewId > 0) {
            SGButton *goButton = SGButton::create("box_btnbg.png", NULL, this, menu_selector(SGAnnouncementLayer::AnnounceButton),CCPointZero,false,true);
            
            CCString *go = CCString::createWithFormat(str_Hit_goto);
            SGCCLabelTTF *go_label = SGCCLabelTTF::create(go->getCString(), FONT_PANGWA, 30);
            
            goButton->addChild(go_label);
            goButton->setTag(viewId);//跳转到某个视图界面
            go_label->setPosition(ccp(goButton->getContentSize().width / 2, goButton->getContentSize().height / 2));
            
            //立即前往Button
            CCMenu *menu = CCMenu::create(goButton, NULL);
            menu->setTouchPriority(0);
            menu->setPosition(CCPointZero);
            goButton->setScale(0.7);
            goButton->setZOrder(200);
            //goButton->setPosition(ccp(label->getPositionX(), goButton->getContentSize().height / 1.5));
            goButton->setAnchorPoint(ccp(0.5, 0));
            goButton->setPosition(ccp(label->getPositionX(), pngScale * 18));
            menu->setZOrder(200);
            contentWindow->addChild(menu);
        }

		layer->addChild(contentWindow);
        //每次加对应的contentWindow的大小,为之后计算scrollview的内容体偏移
        positionY += (cwSize.height + border_shift);

    }
	//layer->setContentSize(CCSizeMake(504, m_scrollview->getContentSize().height));
	//控制是否可以滑动
	iscanmove = (positionY)>791?true:false;//@note:591是m_scrollview的可视区域高度
	

	m_scrollview->setContentOffset(ccp(0, -positionY + m_scrollview->getContentSize().height - 30));//20是顶部窗口的起始位置偏移,不减去会有一小部分遮挡
    m_scrollview->setContentSize(CCSizeMake(m_scrollview->getContentSize().width, positionY));//scrollview的真正大小
    m_scrollview->getContainer()->setContentSize(CCSizeMake(m_scrollview->getContentSize().width, positionY + 10));//滚动重置时的container位置
}
bool MainView::init(){
    
    if (!CCLayer::init()) {
        return false;
    }
    size = CCDirector::sharedDirector()->getWinSize();
//    dScaleFactorX = size.width / 768, dScaleFactorY = size.height / 1024;
//    FirstGame = false;
    
//    gameSettings = GameSettings::sharedGameSettings();
   
    
    // ChartBoost SDK Integration
    
//    ChartboostX::sharedChartboostX()->setDelegate(this);
//    this->ShowChartBoost();
//    
//    
//    int first =  CCUserDefault::sharedUserDefault()->getIntegerForKey("first");
//    if (first == 1) {
//       
//        FirstGame = false;
//        
//    }else{
//        FirstGame = true;
//        CCUserDefault::sharedUserDefault()->setIntegerForKey("first", 1);
//        CCUserDefault::sharedUserDefault()->setBoolForKey("effectSound", true);
//        CCUserDefault::sharedUserDefault()->setBoolForKey("backgroundSound" , true);
//        gameSettings->setBackGround(1);
//        gameSettings->setBackGroundMusic(1);
//        gameSettings->setCurrentStatus(kTagNonStatus);
//        gameSettings->setPlayed(false);
//   
//    }
//    
//    setBackGroundView(gameSettings->getBackground());
//
//    int nType = gameSettings->getBackgroundMusic();
// 
//    if (!gameSettings->isPlayed()) {
//        gameSettings->playBackGround(nType);
//    }
//    
//    showMainView();
    
    CCSprite* backgroundView = CCSprite::create("[email protected]");
    backgroundView->setPosition(ccp(size.width / 2, size.height / 2));
    float scale_x = size.width / backgroundView->getContentSize().width;
    float scale_y = size.height / backgroundView->getContentSize().height;
    backgroundView->setScaleX(scale_x);
    backgroundView->setScaleY(scale_y);
    addChild(backgroundView);

    CCSprite* spCharacter = CCSprite::create("[email protected]");
    spCharacter->setPosition(ccp(size.width / 2, size.height / 2));
    spCharacter->setScaleX(scale_x);
    spCharacter->setScaleY(scale_y);
    addChild(spCharacter);

    CCSprite* spLogo = CCSprite::create("[email protected]");
    spLogo->setPosition(ccp(size.width / 2 , getY(size.height, 304, 71) * scale_y));
    spLogo->setScaleX(scale_x);
    spLogo->setScaleY(scale_y);
    addChild(spLogo);

    CCSprite* spAdBanner = CCSprite::create("[email protected]");
    spAdBanner->setPosition(ccp(size.width / 2 , getY(size.height, 50, 910) * scale_y));
    spAdBanner->setScaleX(scale_x);
    spAdBanner->setScaleY(scale_y);
    addChild(spAdBanner);

    
    CCMenuItemImage *facebookButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::onClickFacebookButton));
    facebookButton->setPosition(ccp(size.width / 2, getY(size.height, 132, 596)));
    facebookButton->setScaleX(scale_x);
    facebookButton->setScaleY(scale_y);

    CCMenuItemImage *guestButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::onClickGuestButton));
    guestButton->setPosition(ccp(size.width / 2, getY(size.height, 132, 756)));
    guestButton->setScaleX(scale_x);
    guestButton->setScaleY(scale_y);
    
    CCMenu* menu = CCMenu::create(facebookButton,guestButton,NULL);
    menu->setPosition(CCPointZero);
    addChild(menu);

    return true;
}
void SGAnnouncementLayer::viewDidLoad(main::AnnouncementResponse &response)//cgp come
{
    this->setTouchEnabled(true);
    
    this->setTag(box_announcementLayer);

    ResourceManager::sharedInstance()->bindTexture("sgannouncementlayer/sgannouncementlayer.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
	ResourceManager::sharedInstance()->bindTexture("sgannouncementlayer/sgannouncementlayer2.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
	ResourceManager::sharedInstance()->bindTexture("sglandingreward/sglandingreward.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
    ResourceManager::sharedInstance()->bindTexture("sanguobigpic/Tips.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
	
    m_arrayAnn = CCArray::create();
    m_arrayAnn->retain();
    
    //CCPoint center = SGLayout::getPoint(kMiddleCenter);
    
    //加个半透明黑背景
    CCLayerColor *blackLayer = CCLayerColor::create(ccc4(0, 0, 0, 150), SGLayout::getSkewing(380), SGLayout::getSkewingY(520));
	 blackLayer->setPosition(ccpAdd(ccp(0, 0), ccp(-385, -570)));
    addChild(blackLayer);
    
    //大个背景
//    CCSprite *sprite_background = CCSprite::create("gonggao/gonggao_bj.png");
    CCSprite *sprite_background = CCSprite::createWithSpriteFrameName("bg.png");
    addChild(sprite_background);
    
	
    //cgp useful
    //按钮
   	buttonOK = SGButton::create("gonggao_an.png", "public_font_queding.png", this, menu_selector(SGAnnouncementLayer::buttonClickOK),CCPointZero,false,true);
    buttonOK->setPosition(ccp(sprite_background->getContentSize().width * 0.5 - 5, sprite_background->getContentSize().height * 0.05));
//    addBtn(buttonOK);
	
	//遮挡住按钮穿透,临时做法
	SGButton *mask = SGButton::create("gonggao_an.png", NULL, this, menu_selector(SGAnnouncementLayer::pressMask), CCPointZero, false, true);
	mask->setScaleY(0.3);
	mask->setOpacity(0);
	mask->setPosition(ccp(buttonOK->getPositionX(), buttonOK->getPositionY() + 40));
	
    
    menu = CCMenu::create(buttonOK, mask, NULL);
	menu->setTag(254);
    menu->setPosition(CCPointZero);
    sprite_background->addChild(menu);
	
	

	//CCScrollView
    m_scrollview = CCScrollView::create(CCSizeMake(574, 761));
    CCLayer *container = CCLayer::create();
	
    container->setContentSize(CCSizeMake(574, 770));
	
    m_scrollview->setContainer(container);
	
    CCSize backgroundSize = sprite_background->getContentSize();
	m_scrollview->setPosition(ccpAdd(ccp(0, 0), ccp(-287, -382)));//设置scrollview位置
    m_scrollview->setDirection(kCCScrollViewDirectionVertical);
    addChild(m_scrollview);

    //解析接收到的数据
    int modelSize = response.announcementmodel_size();
    for(int i = 0;i < modelSize;i++)
    {
        main::AnnouncementModel model = response.announcementmodel(i);
        
        SGAnnouncementDataModel *ann = new SGAnnouncementDataModel();
        //ann->setTimeStamp(model.timestamp());
        ann->setTitle(CCString::create(model.title()));
        ann->setContent(CCString::create(model.content()));
		ann->setViewId(model.viewid());
		if (model.url() != "")//如果url不为空才设置对应的url
		{
			ann->setUrl(CCString::create(model.url()));
		}
        m_arrayAnn->addObject(ann);
        ann->autorelease();
    }
    
    //constructScrollView();
    initScrollView();
    //removed by cgp
	//this->flowerEffect();//花瓣效果
   // buttonClickOK();

}
Beispiel #21
0
void COxCJ4UILayer::InitMenu()
{
	m_MenuArray.clear();
	//CCPoint mPoint = m_pRootNode->getPosition();
	CCSize size = this->getContentSize();
	CCPoint mPoint = ccp(size.width / 2, size.height / 2);
	float fMenuY = mPoint.y - 100.0f;

	m_pBtnStart = createMenuItemSpriteByResID(Ox_Bt_Zhun_Bei_N, Ox_Bt_Zhun_Bei_C);
	if (m_pBtnStart)
	{
		m_pBtnStart->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchStart));
		m_pBtnStart->setPosition(ccp(mPoint.x, fMenuY));
		m_MenuArray[Menu_Item_ID_Start] = m_pBtnStart;
	}

	m_pBtnCallBanker = createMenuItemSpriteByResID(Ox_Bt_Call_Banker_N, Ox_Bt_Call_Banker_C);
	if (m_pBtnCallBanker)
	{
		m_pBtnCallBanker->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchCallBanker));
		m_pBtnCallBanker->setPosition(ccp(mPoint.x - 100, fMenuY));
		m_MenuArray[Menu_Item_ID_CallBanker] = m_pBtnCallBanker;
	}

	m_pBtnNoCall = createMenuItemSpriteByResID(Ox_Bt_Bu_Jiao_N, Ox_Bt_Bu_Jiao_C);
	if (m_pBtnNoCall)
	{
		m_pBtnNoCall->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchNoCall));
		m_pBtnNoCall->setPosition(ccp(mPoint.x + 100, fMenuY));
		m_MenuArray[Menu_Item_ID_NoCall] = m_pBtnNoCall;
	}

	m_nJetBeginTag = 100;
	for (BYTE i = 0; i < CountArray(m_pBtnJetton); ++i)
	{
		m_pBtnJetton[i] = createMenuItemSpriteByResID(Ox_Bt_Jetton_Bk_N, Ox_Bt_Jetton_Bk_C, Ox_Bt_Jetton_Bk_D);
		if (m_pBtnJetton[i])
		{
			m_pBtnJetton[i]->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchJetton));
			m_pBtnJetton[i]->setTag(m_nJetBeginTag + i);
			m_pBtnJetton[i]->setPosition(ccp(mPoint.x - 300 + i * 200, fMenuY));

			if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Ox_Font_Jetton_Value, m_pJettonValue[i]))
			{
				CCSize btnSize = m_pBtnJetton[i]->getContentSize();
				m_pJettonValue[i]->setAnchorPoint(ccp(0.5, 0.5));
				m_pJettonValue[i]->setPosition(btnSize.width / 2, btnSize.height / 2);
				m_pBtnJetton[i]->addChild(m_pJettonValue[i]);
			}
		}
	}
	m_MenuArray[Menu_Item_ID_Jetton0] = m_pBtnJetton[0];
	m_MenuArray[Menu_Item_ID_Jetton1] = m_pBtnJetton[1];
	m_MenuArray[Menu_Item_ID_Jetton2] = m_pBtnJetton[2];
	m_MenuArray[Menu_Item_ID_Jetton3] = m_pBtnJetton[3];

	m_pBtnSortCard = createMenuItemSpriteByResID(Ox_Bt_Pai_Xu_N, Ox_Bt_Pai_Xu_C);
	if (m_pBtnSortCard)
	{
		m_pBtnSortCard->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchSortCard));
		m_pBtnSortCard->setPosition(ccp(mPoint.x - 190, fMenuY));
		m_MenuArray[Menu_Item_ID_SortCard] = m_pBtnSortCard;
	}

	m_pBtnShowCard = createMenuItemSpriteByResID(Ox_Bt_Show_Card_N, Ox_Bt_Show_Card_C, Ox_Bt_Show_Card_D);
	if (m_pBtnShowCard)
	{
		m_pBtnShowCard->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchShowCard));
		m_pBtnShowCard->setPosition(ccp(mPoint.x, fMenuY));
		m_MenuArray[Menu_Item_ID_ShowCard] = m_pBtnShowCard;
	}

	m_pBtnTiShi = createMenuItemSpriteByResID(Ox_Bt_Ti_Shi_N, Ox_Bt_Ti_Shi_C);
	if (m_pBtnTiShi)
	{
		m_pBtnTiShi->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchTiShi));
		m_pBtnTiShi->setPosition(ccp(mPoint.x + 190, fMenuY));
		m_MenuArray[Menu_Item_ID_TiShi] = m_pBtnTiShi;
	}

	m_pBtnTuoGuan = createMenuItemSpriteByResID(Ox_Bt_Tuo_Guan_N, Ox_Bt_Tuo_Guan_C);
	if (m_pBtnTuoGuan)
	{
		m_pBtnTuoGuan->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchTuoGuan));
		m_pBtnTuoGuan->setPosition(ccp(mPoint.x + 555, mPoint.y - 320));
		m_MenuArray[Menu_Item_ID_TuoGuan] = m_pBtnTuoGuan;
	}

	m_pBtnNoTuoGuan = createMenuItemSpriteByResID(Ox_Bt_Qu_Xiao_TG_N, Ox_Bt_Qu_Xiao_TG_C);
	if (m_pBtnNoTuoGuan)
	{
		m_pBtnNoTuoGuan->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchNoTuoGuan));
		m_pBtnNoTuoGuan->setPosition(ccp(mPoint.x + 555, mPoint.y - 320));
		m_MenuArray[Menu_Item_ID_NoTuoGuan] = m_pBtnNoTuoGuan;
	}

	m_pBtnOut = createMenuItemSpriteByResID(Ox_Bt_Out_N, Ox_Bt_Out_C);
	if (m_pBtnOut)
	{
		m_pBtnOut->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchOut));
		m_pBtnOut->setAnchorPoint(ccp(0, 1));
		m_pBtnOut->setPosition(ccp(0, size.height));
		//m_MenuArray[Menu_Item_ID_Out] = m_pBtnOut;
	}

	m_pBtnOption = createMenuItemSpriteByResID(Ox_Bt_Option_N, Ox_Bt_Option_C);
	if (m_pBtnOption)
	{
		m_pBtnOption->setTarget(this, menu_selector(COxCJ4UILayer::OnTouchOption));
		m_pBtnOption->setAnchorPoint(ccp(0, 1));
		m_pBtnOption->setPosition(ccp(m_pBtnOut->getContentSize().width, size.height));
		//m_MenuArray[Menu_Item_ID_Out] = m_pBtnOut;
	}

	CCMenu * pMenu = CCMenu::create(m_pBtnStart, m_pBtnCallBanker, m_pBtnNoCall, m_pBtnSortCard,
		m_pBtnShowCard, m_pBtnTiShi, m_pBtnTuoGuan, m_pBtnNoTuoGuan, m_pBtnOut, m_pBtnOption, NULL);
	for (BYTE i = 0; i < CountArray(m_pBtnJetton); ++i)
		pMenu->addChild(m_pBtnJetton[i]);

	pMenu->setPosition(CCPointZero);
	addToRoot(pMenu);
}
Beispiel #22
0
// on "init" you need to initialize your instance
bool LevelGameScene::init()
{
	if ( !CCLayerColor::initWithColor( ccc4(100, 100, 100, 255) ) )
	{
		return false;
	}

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

	// Fondo con la textura de madera
	ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
	CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("purty_wood.png");
				 texture->setTexParameters(&tp);
	CCSprite* background = CCSprite::createWithTexture(texture, CCRectMake(0, 0, vs.width, vs.height));
			  background->setPosition( ccp( vs.width/2, vs.height/2 ) );

	this->addChild(background, 1);

	CCMenuItem* level1 = CCMenuItemImage::create("btn_level_1.png", "btn_level_1_h.png", this, menu_selector(LevelGameScene::level1Callback));
				level1->setPosition(ccp(vs.width/2 - 275, vs.height/2));

	CCMenuItem* level2 = CCMenuItemImage::create("btn_level_2.png", "btn_level_2_h.png", this, menu_selector(LevelGameScene::level2Callback));
				level2->setPosition(ccp(vs.width/2, vs.height/2));

	CCMenuItem* level3 = CCMenuItemImage::create("btn_level_3.png", "btn_level_3_h.png", this, menu_selector(LevelGameScene::level3Callback));
				level3->setPosition(ccp(vs.width/2 + 275, vs.height/2));

	CCMenu* menu = CCMenu::create(level1, level2, level3, NULL);
			menu->setPosition(ccp(0,0));

	this->addChild(menu, 5);

    this->setTouchEnabled(true);

    return true;
}
KDbool Level1Scene::init ( KDvoid )
{	
	m_nScoreCount	 = 0;
	m_bTargetThrough = KD_FALSE;
	m_bSecondTab	 = KD_FALSE;
	m_bHit			 = KD_FALSE;
	m_pMouseJoint	 = KD_NULL;
	m_nTargetIndex	 = 0;
	m_pTargetBody	 = KD_NULL;
	m_pTargetJoint   = KD_NULL;

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

	// ��ġ Ȱ��ȭ
	this->setTouchEnabled ( KD_TRUE );
 
	const CCSize&		tLyrSize = this->getContentSize ( );
	

	this->initPhysics ( );
    
	// ����̹����� �ѷ��ش�.
	CCSprite*	pSprite = CCSprite::create ( "BackGround/bgempty.png" );
	pSprite->setAnchorPoint ( ccpz );
	pSprite->setPosition ( ccp ( 0, 0 ) );
	this->addChild ( pSprite, 0, 0 );
	
	CCSprite*	spLevel = CCSprite::create ( "SpriteImage/level1.png" );
	spLevel->setAnchorPoint ( ccpz );
	spLevel->setPosition ( ccp ( 440, 290 ) );
	this->addChild ( spLevel, 10 );


	m_pBackgroundNode = CCParallaxNode::create ( );
	this->addChild ( m_pBackgroundNode, 3 );

	m_pCloud1 = CCSprite::create ( "SpriteImage/clowdsmall.png" );
	m_pCloud2 = CCSprite::create ( "SpriteImage/clowdlarge.png" );
	m_pCloud3 = CCSprite::create ( "SpriteImage/clowdlarge.png" );
    m_pCloud4 = CCSprite::create ( "SpriteImage/clowdsmall.png" );

	m_pBird1  = CCSprite::create ( "SpriteImage/bird1.png" );
	m_pBird2  = CCSprite::create ( "SpriteImage/bird1.png" );
	m_pBird3  = CCSprite::create ( "SpriteImage/bird1.png" );
	m_pBird4  = CCSprite::create ( "SpriteImage/bird1.png" );
	
	m_nBirdindex = 1;

	CCPoint dustSpeed = ccp ( 0.1f, 0.1f );
	CCPoint bgSpeed   = ccp ( 0.05f, 0.05f);

	m_pBackgroundNode->addChild ( m_pCloud1, 6,   dustSpeed ,  ccp ( 300,250 ) );
	m_pBackgroundNode->addChild ( m_pCloud3, 6 ,  dustSpeed ,  ccp ( 700,280 ) ); 
	m_pBackgroundNode->addChild ( m_pCloud2, 6,   dustSpeed ,  ccp ( 100,220 ) ); 
	m_pBackgroundNode->addChild ( m_pCloud4, 6 ,  dustSpeed ,  ccp ( 400,200 ) );

	m_pBackgroundNode->addChild ( m_pBird1,  6 ,  dustSpeed ,  ccp ( 200,160 ) );
	m_pBackgroundNode->addChild ( m_pBird2,  6 ,  dustSpeed ,  ccp ( 700,180 ) );
	m_pBackgroundNode->addChild ( m_pBird3,  6 ,  dustSpeed ,  ccp ( 500,260 ) );
	m_pBackgroundNode->addChild ( m_pBird4,  6 ,  dustSpeed ,  ccp ( 800,200 ) );
	
	// ���ھ� ǥ�� 
	this->m_pScoreLabel = CCLabelTTF::create ( "Score:0", "Marker Felt.ttf", 20 );
	m_pScoreLabel ->retain      ( );
	m_pScoreLabel ->setColor    ( ccc3 ( 128, 128, 250 ) );
	m_pScoreLabel ->setPosition ( ccp ( 70, 300 ) );
	this->addChild ( m_pScoreLabel ,0 );

	CCMenuItemImage*	pCloseItem = CCMenuItemImage::create
	(
		"SpriteImage/backbutton.png",
		"SpriteImage/backbutton.png",
		this,
		menu_selector ( Level1Scene::onMenu ) 
	);

	pCloseItem->setPosition ( ccp ( tLyrSize.cx - 30, tLyrSize.cy - 30 ) );
	this->addChild ( CCMenu::createWithItem ( pCloseItem ), 20, 1 );

	// ���� �̹���.
	CCSprite*	pSlingshot = CCSprite::create ( "SpriteImage/shooter.png" );
	this->addChild ( pSlingshot, 1 );
	
	// 
	b2BodyDef tSlingshotBodyDef;
	tSlingshotBodyDef.type = b2_dynamicBody;
	tSlingshotBodyDef.position.Set ( 130.0f / PTM_RATIO, 38.0f / PTM_RATIO );
	tSlingshotBodyDef.userData = pSlingshot;
	m_pSlingBody = m_pWorld->CreateBody ( &tSlingshotBodyDef );

	b2PolygonShape tBox;
	b2FixtureDef tSlingshotBoxDef;
	tSlingshotBoxDef.shape = &tBox;
	tSlingshotBoxDef.density = 0.3f;
	tBox.SetAsBox ( 11.0/PTM_RATIO, 31.0f/PTM_RATIO );
	m_pSlingBody->CreateFixture ( &tSlingshotBoxDef );

	b2RevoluteJointDef tSlingshotJointDef;
	tSlingshotJointDef.Initialize ( m_pBody, m_pSlingBody, b2Vec2 ( 140.0f / PTM_RATIO, 0.0f/ PTM_RATIO ) );
	tSlingshotJointDef.maxMotorTorque = 800.0f; // ������ġ, 0�̸� �������.
	tSlingshotJointDef.motorSpeed     = -10.0f;
	tSlingshotJointDef.lowerAngle     = CC_DEGREES_TO_RADIANS ( 5 );
	tSlingshotJointDef.upperAngle     = CC_DEGREES_TO_RADIANS ( 175 );
	tSlingshotJointDef.enableLimit    = KD_TRUE;
	tSlingshotJointDef.enableMotor    = KD_TRUE;
	
	m_pSlingJoint = ( b2RevoluteJoint* ) m_pWorld->CreateJoint ( &tSlingshotJointDef );
	
	m_pTargets    = new std::vector<b2Body*>;
	m_pStructures = new std::vector<b2Body*>;
	m_pClowns     = new std::vector<b2Body*>;
	m_pClownheads = new std::vector<b2Body*>;
	m_pRocks      = new std::vector<b2Body*>;
	m_pWoods      = new std::vector<b2Body*>;
	m_pAngle      = new std::vector <CCSprite*>;

	GameSetup ( );

	m_pContact    = new Level1ContactListener ( );
	m_pWorld->SetContactListener ( m_pContact );

	schedule ( schedule_selector ( Level1Scene::tick ) );
	schedule ( schedule_selector ( Level1Scene::update ) );

	return KD_TRUE;
}
Beispiel #24
0
void SGMail::viewDidLoad()
{
    //界面布局
    CCPoint upLeft = SGLayout::getPoint(kUpLeft);
    CCPoint upCenter = SGLayout::getPoint(kUpCenter);
    CCSize s=CCDirector::sharedDirector()->getWinSize();
    float h = SGMainManager::shareMain()->getTotleHdHgt();
    //星形背景
    ResourceManager::sharedInstance()->bindTexture("sanguobigpic/barrack_bg.plist", RES_TYPE_LAYER_UI, sg_mailLayer);

    CCSprite *spriteBackground = CCSprite::createWithSpriteFrameName("barrack_bg.png");
    CCRect r = CCRectMake(0, 30+150+72, spriteBackground->getContentSize().width, SGLayout::getSkewingY(480)-47-150-72-61-101);
    //spriteBackground->setScaleY(r.size.height / spriteBackground->getContentSize().height);
    spriteBackground->setTextureRect(r);
    spriteBackground->setScaleX(s.width/spriteBackground->getContentSize().width * 1.01);
    spriteBackground->setAnchorPoint(ccp(0.5, 1));
    spriteBackground->setPosition(ccpAdd(upCenter, ccp(0, -47-150-72)));
    this->addChild(spriteBackground);
    spriteBackground->setVisible(false);
    
    
    CCSprite *title_bg = CCSprite::createWithSpriteFrameName("title_bg.png");
    title_bg->setAnchorPoint(ccp(0.5, 1));
    title_bg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -h + title_bg->getContentSize().height-2)));
    this->addChild(title_bg,-1);

    
    //标题
    SGCCLabelTTF *spriteTitle = SGCCLabelTTF::create(str_SystemMailLayer_str4, FONT_XINGKAI, 36 , COLOR_UNKNOW_TAN);
    //modify by:zyc. merge into create.
	//spriteTitle->setColor(ccc3(0xff, 0x95, 0x0c));
//    spriteTitle->setPosition(ccpAdd(upCenter, ccp(0, -s.height*0.23)));
    
    spriteTitle->setPosition(ccpAdd(upCenter, ccp(0, -h+65/2)));
    this->addChild(spriteTitle);
    //五张图片的尺寸   -47-150-72-56-101
//    SGButton *buttonBack = SGButton::create("chatbtn.png", "public_font_fanhui.png", this, menu_selector(SGMail::buttonClickGoBack),CCPointZero,false,true);
	SGButton *buttonBack = SGButton::createFromLocal("store_exchangebtnbg.png", str_back, this, menu_selector(SGMail::buttonClickGoBack),CCPointZero,FONT_PANGWA,ccWHITE,32);
	buttonBack->setScale(1.05);
    buttonBack->setAnchorPoint(ccp(0, 0.5));
    buttonBack->setPosition(ccpAdd(upLeft, ccp(0, -h+65/2)));
    addBtn(buttonBack);
    float headhgt = SGMainManager::shareMain()->getTotleHdHgt();
    float btmhgt = SGMainManager::shareMain()->getBottomHeight();
    //tableview
//    this->tableView->setFrame(CCRectMake(0,101+61, SGLayout::getSkewing(320), SGLayout::getSkewingY(480)-47-150-72-63-101));
    tableView->setFrame(CCRectMake(0, 0, s.width, s.height - headhgt - btmhgt));
    tableView->setPosition(ccpAdd(SGLayout::getPoint(kUpLeft), ccp(0, -tableView->getContentSize().height - headhgt)));

    this->tableView->setZOrder(999);
    this->tableViewHeight = 110;
    tableView->setDown(-25);
    
    tableView -> setPageNEnable(true);
    
//    float headhgt = SGMainManager::shareMain()->getTotleHdHgt();
    CCSprite *titlecenter = CCSprite::createWithSpriteFrameName("title_bg_2.png");
    titlecenter->setAnchorPoint(ccp(0.5, 0));
    titlecenter->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0,  -headhgt- 10)));
    this->addChild(titlecenter,10);
    titlecenter->setScaleX(4);
    
    CCSprite *title_bg_l = CCSprite::createWithSpriteFrameName("title_bg_LR.png");
    title_bg_l->setAnchorPoint(ccp(0, 0));
    title_bg_l->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-s.width/2,  -headhgt- 10)));
    this->addChild(title_bg_l,10);
    
    CCSprite *title_bg_r = CCSprite::createWithSpriteFrameName("title_bg_LR.png");
    title_bg_r->setFlipX(true);
    title_bg_r->setAnchorPoint(ccp(1, 0));
    title_bg_r->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(s.width/2,  -headhgt- 10)));
    this->addChild(title_bg_r,10);
    
}
Beispiel #25
0
bool Senario::constructSenarioStage(bool skip)
{
    CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    ccColor3B colorBlack = ccc3(0, 0, 0);
   // ccColor3B colorYellow = ccc3(225, 219, 108);
    ccColor3B colorBlue = ccc3(0, 0, 255);
    clearElements();
    
    if(slidesList->count() <= curSlide)
    {
        return false;
    }
    
    Slide* slide = (Slide*)slidesList->objectAtIndex(curSlide);
    
    CCArray* elementArray = slide->elementList;
    
    if(slide->isScene)
    {
        
        CCTextureCache::sharedTextureCache()->removeAllTextures();
        CCTextureCache::sharedTextureCache()->purgeSharedTextureCache();
        CCAnimationCache::sharedAnimationCache()->purgeSharedAnimationCache();
        CCDirector::sharedDirector()->purgeCachedData();
        
        backgroundImage = slide->scene_src;
    }
    
    CCSprite* blackScreen = CCSprite::create(backgroundImage.c_str());
    blackScreen->setScale(screenSize.width / blackScreen->boundingBox().size.width);
    blackScreen->setAnchorPoint(ccp(0.5, 0.5));
    blackScreen->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
    this->addChild(blackScreen, 1);
    spriteList.push_back(blackScreen);
    
    skipButton = CCSprite::create("skip_button.png");
    skipButton->retain();
    skipButton->setScale(1.0f);
    skipButton->setAnchorPoint(ccp(1, 1));
    skipButton->setPosition(ccp(screenSize.width, screenSize.height));
    this->addChild(skipButton, 2);
    spriteList.push_back(skipButton);
    
    if(slide->hasVideo)
    {
        //Config *c = Config::getConfig();
        if(slide->video_clip.compare("") != 0)
        {
            WrapperClass::getShared()->playVideo(slide->video_clip.c_str());
        }
    }
    
    if(slide->playBGM)
    {
        if(slide->bgm_clip.compare("") != 0)
        {
            SoundtrackManager::PlayBGM(slide->bgm_clip);
        }
    }
    
    if(slide->playSFX)
    {
        if(slide->sfx_clip.compare("") != 0)
        {
            SoundtrackManager::PlaySFX(slide->sfx_clip);
        }
    }
    
    if(GameScene::getThis()->systemConfig->hideSkipButton)
    {
        skipButton->setAnchorPoint(ccp(0, 1));
        skipButton->setPosition(ccp(screenSize.width, screenSize.height));
    }
    
    bool isChoosingOption = false;
    for(int i = 0; i < elementArray->count(); i++)
    {
        Element* ele = (Element*)elementArray->objectAtIndex(i);
        
        /*
         * In the senario stage, there are two types of elements -> sprite and dialogue, treat these two types of elements differently in order to make this display them correctly!
         */
        
        if(ele->type == Element::sprite)
        {
            /*
             * Sprite: only has a picture of the sprite shown on the screen
             * Future: may include animation of the sprite shown on the screen (probably a gif?)
             */
            
            AnimatedSprite* as = AnimatedSprite::create(ele->src.c_str(), ele->fadeIn, ele->fadeOut, true);
            stringstream ss;
            CCSprite* cha = as->getSprite();
            CCSize spriteSize = cha->getContentSize();
            cha->setScale(screenSize.width / spriteSize.width * ele->width / 100.0f);
            cha->setFlipX(true);
            
            cha->setAnchorPoint(ccp(0, 1));
            cha->setPosition(ccp(screenSize.width * (ele->left / 100.0f), screenSize.height * (ele->top / 100.0f)));
            this->addChild(cha, 2);
            spriteList.push_back(cha);
            
            animatedSpriteList->addObject(as);
        }
        else if(ele->type == Element::dialogue)
        {
            /*
             * Dialogue: contains a picture of the background of that dialogue, a name label, a dialogue text and a proceed button
             * Future: may include dialogue functionalities like save, load, auto proceed, text jumper, etc....
             */
            
            AnimatedDialogue* ad = AnimatedDialogue::create(ele->src.c_str(), ele->fadeIn, ele->fadeOut);
            CCSprite* chbox = ad->getSprite();
            CCSize boxSize = chbox->getContentSize();
            chbox->setScale(screenSize.width / boxSize.width * ele->width / 100.0f);
            chbox->setAnchorPoint(ccp(0, 1));
            chbox->setPosition(ccp(screenSize.width * (ele->left / 100.0f), screenSize.height * (ele->top / 100.0f)));
            
            if(ele->isBackground)
            {
                this->addChild(chbox, 3);
                spriteList.push_back(chbox);
                animatedDialogueList->addObject(ad);
                continue;
            }
            
            float heightOff = 80.0f - ele->textOffY;
            float widthOff = 80.0f;
            
            displayTexts(ele->text, screenSize.width * (ele->left / 100.0f) + widthOff, screenSize.height * (ele->top / 100.0f) - heightOff, ele->font.c_str(), (float)ele->fontSize, colorBlack, ele->limitX);
            
            std::stringstream ss;
            ss << ele->text;
            
            heightOff = 40.0f;
            widthOff = 80.0f;
            
            ss.str(std::string());
            ss << ele->name;
            CCLabelTTF* chboxName = CCLabelTTF::create(ss.str().c_str(), ele->font.c_str(), ele->fontSize, CCSizeMake(ss.str().length() * 20.0f, 5.0f), kCCTextAlignmentLeft);
            chboxName->setColor(colorBlue);
            chboxName->setAnchorPoint(ccp(0, 1));
            chboxName->setPosition(ccp(screenSize.width * (ele->left / 100.0f) + widthOff, screenSize.height * (ele->top / 100.0f) - heightOff));
            
            this->addChild(chbox, 3);
            this->addChild(chboxName, 4);
            spriteList.push_back(chbox);
            labelList.push_back(chboxName);
            animatedDialogueList->addObject(ad);
        }
        else if(ele->type == Element::option)
        {
            isChoosingOption = true;
            inOption = true;
            notJump = true;
            
            CCMenuItemImage* selectButton = CCMenuItemImage::create(ele->src.c_str(), ele->srcp.c_str(), this, menu_selector(Senario::selectButtonPressed));
            selectButton->setTag(i);
            selectButton->setAnchorPoint(ccp(0, 1));
            selectButton->setScale(0.6f);
            
            CCMenu* menu = CCMenu::create(selectButton, NULL);
            menu->setPosition(ccp(screenSize.width * (ele->left / 100.0f), screenSize.height * (ele->top / 100.0f)));
            this->addChild(menu, 4);
            menuList.push_back(menu);
        }
    }
    
    if(!isChoosingOption && skip)
    {
        return false;
    }
    
    this->schedule(schedule_selector(Senario::update), 1.0f/60.0f);
    
    return true;
}
Beispiel #26
0
void WallSingleScene::onEnter(){
	CCLayer::onEnter();
	CCLog("WallSingleScene::onEnter()");
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	//add Menu Item
	CCMenuItemImage* ceshi_button = CCMenuItemImage::create("ceshi_1.png",
		"ceshi_2.png",
		this,
		menu_selector(WallSingleScene::pingpanwriting));
	CCMenuItemImage* back_button = CCMenuItemImage::create("strangedesign/back_button.png",
		"strangedesign/back_button_down.png",
		this,
		menu_selector(WallSingleScene::back));
	back_button->setPosition(ccp(back_button->getContentSize().width/2+10,visibleSize.height-back_button->getContentSize().height/2-50));

	//评判书写
	CCMenuItemImage* judge_button = CCMenuItemImage::create("strangedesign/Page_judgewritting_button.png",
		"strangedesign/Page_judgewritting_button_down.png",
		this,
		menu_selector(WallSingleScene::pingpanwriting));

	//自由练习
	CCMenuItemImage* free_button = CCMenuItemImage::create("strangedesign/Page_freewritting_button.png",
		"strangedesign/Page_freewritting_button_down.png",
		this,
		menu_selector(WallSingleScene::freewriting));
	judge_button->setPosition(ccp(visibleSize.width - judge_button->getContentSize().width/2 ,judge_button->getContentSize().height/2));
	free_button->setPosition(ccp(free_button->getContentSize().width/2,free_button->getContentSize().height/2));

	CCMenu* menu = CCMenu::create(judge_button,free_button,back_button,NULL);
	this->addChild(menu,20);
	ceshi_button->setPosition(ccp(visibleSize.width - ceshi_button->getContentSize().width/2 ,ceshi_button->getContentSize().height/2));
	menu->setPosition(CCPointZero);

	CCSprite* titlebar = CCSprite::create("strangedesign/title bar_background.png");
	addChild(titlebar,10);
	titlebar->setPosition(ccp(visibleSize.width/2,visibleSize.height-titlebar->getContentSize().height/2));

	CCSprite* selectionMode = CCSprite::create("strangedesign/Page_selectionmode_character.png");
	addChild(selectionMode,11);
	selectionMode->setPosition(titlebar->getPosition());

	CCSprite* wall_tail = CCSprite::create("strangedesign/title bar_background.png");
	this->addChild(wall_tail,2);
	CCSize tailSize = wall_tail->getContentSize();
	wall_tail->setPosition(ccp(visibleSize.width/2,wall_tail->getContentSize().height/2));
	wall_tail->setScaleX(visibleSize.width/wall_tail->getContentSize().width);

	//Screenshot function 截屏功能待后续加入
	CCMenuItemImage* screenshot = CCMenuItemImage::create("strangedesign/Page_Screenshot_button.png",
		"strangedesign/Page_Screenshot_button_down.png",
		this,
		menu_selector(WallSingleScene::screenshot));
	menu->addChild(screenshot,12);
	screenshot->setPosition(wall_tail->getPosition());

	groupChar = SQLiteData::getUnit(unitID);

#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
	string str_filename = "strangedesign/scoretable.xml";
	string myfilename = CCFileUtils::sharedFileUtils()->fullPathForFilename(str_filename.c_str());
	unsigned long size = 0;
	char* pFileContent = (char*)CCFileUtils::sharedFileUtils()->getFileData(myfilename.c_str(),"r",&size);
	TiXmlDocument* myDocument = new TiXmlDocument();
	myDocument->Parse(pFileContent,0,TIXML_ENCODING_UTF8);
#endif
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
	string str_filename = "strangedesign/scoretable.xml";
	string myfilename=CCFileUtils::sharedFileUtils()->fullPathForFilename(str_filename.c_str());
	TiXmlDocument* myDocument = new TiXmlDocument(myfilename.c_str());
	myDocument->LoadFile();
#endif
    TiXmlElement* rootElement = myDocument->RootElement();  // Class
	TiXmlElement* metaElement = rootElement->FirstChildElement();  // meta   
	TiXmlElement* heightElement = metaElement->FirstChildElement(); //获得meta的height元素
	string mheight=heightElement->GetText();
	int height=atoi(mheight.c_str());
	TiXmlElement* widthElement = heightElement->NextSiblingElement(); //获得meta的width元素
	string mwidth=widthElement->GetText(); 
	int width=atoi(mwidth.c_str());

	rescale=(visibleSize.height - wall_tail->getContentSize().height)/(float)height;
	float width_rescale = visibleSize.width/(float)width;
	//////////////
	TiXmlElement* dataElement = metaElement->NextSiblingElement();  // data
	TiXmlElement* stoneElement = dataElement->FirstChildElement();  // stone

	hanzilist.clear();
	int indexOfCharacter = 0;
	while (stoneElement) {
		CHanziManage temphanziManage;
		TiXmlElement* typeElement = stoneElement->FirstChildElement();  // type

		string flag1("wordbox");
		string flag3(typeElement->GetText());
		if(flag3==flag1)
		{
			//wordbox
			TiXmlElement* xElement = typeElement->NextSiblingElement();  // x
			TiXmlElement* yElement = xElement->NextSiblingElement();  // y
			TiXmlElement* wElement = yElement->NextSiblingElement();  // w
			TiXmlElement* hElement = wElement->NextSiblingElement();  // h
			TiXmlElement* imgElement = hElement->NextSiblingElement();  // img
			TiXmlElement* characterposx = imgElement->NextSiblingElement();	//
			TiXmlElement* characterposy = characterposx->NextSiblingElement();
			TiXmlElement* scoreposx = characterposy->NextSiblingElement();
			TiXmlElement* scoreposy = scoreposx->NextSiblingElement();
			TiXmlElement* timesposx = scoreposy->NextSiblingElement();
			TiXmlElement* timesposy = timesposx->NextSiblingElement();

			string tempx=xElement->GetText();
			int x=atoi((tempx.substr(0,tempx.size()-2)).c_str());
			string tempy=yElement->GetText();
			int y=atoi((tempy.substr(0, tempy.size()-2)).c_str());
			string tempw=wElement->GetText();
			int w=atoi((tempw.substr(0,tempw.size()-2)).c_str());
			string temph=hElement->GetText();
			int h=atoi((temph.substr(0, temph.size()-2)).c_str());

			string strcharacterposx=characterposx->GetText();
			int intcharacterposx=atoi((strcharacterposx.substr(0,strcharacterposx.size())).c_str());
			string strcharacterposy=characterposy->GetText();
			int intcharacterposy=atoi((strcharacterposy.substr(0, strcharacterposy.size())).c_str());
			string strscoreposx=scoreposx->GetText();
			int intscoreposx=atoi((strscoreposx.substr(0,strscoreposx.size())).c_str());
			string strscoreposy=scoreposy->GetText();
			int intscoreposy=atoi((strscoreposy.substr(0,strscoreposy.size())).c_str());
			string strtimesposx=timesposx->GetText();
			int inttimesposx=atoi((strtimesposx.substr(0,strtimesposx.size())).c_str());
			string strtimesposy=timesposy->GetText();
			int inttimesposy=atoi((strtimesposy.substr(0, strtimesposy.size())).c_str());


			//坐标系重定位 将XML中第四象限坐标转成第一象限
			x+=w/2;
			y=height-y-h/2;

			intcharacterposx=height-intcharacterposx;
			intscoreposy=height-intscoreposy;
			inttimesposy=height-inttimesposy;

			//缩放
			x*=width_rescale;
			y*=rescale;

			intcharacterposx*=width_rescale;
			intcharacterposy*=rescale;
			intscoreposx*=width_rescale;
			intscoreposy*=rescale;
			inttimesposx*=width_rescale;
			inttimesposy*=rescale;

			w*=width_rescale;
			h*=rescale;
			y += wall_tail->getContentSize().height-20;

			intcharacterposy += wall_tail->getContentSize().height-20;
			intscoreposy += wall_tail->getContentSize().height-20;
			inttimesposy += wall_tail->getContentSize().height-20;

			string tempfilename=imgElement->GetText();

			//添加田字格背景图
			CCSprite* pSprite1 = CCSprite::create(tempfilename.c_str());
			pSprite1->setScaleY(rescale);
			pSprite1->setScaleX(width_rescale);
			pSprite1->setPosition(ccp(origin.x+x, origin.y+y));
			addChild(pSprite1, 1);

			hanzis.push_back(groupChar.at(indexOfCharacter).at(0));

			//添加汉字
			CCLabelTTF* pLabel = CCLabelTTF::create(groupChar.at(indexOfCharacter).at(0).c_str(), "Arial", 100);
			pLabel->setPosition(ccp(origin.x + x, origin.y + y));
			pLabel->setColor(ccc3(0,0,0));
			this->addChild(pLabel, 2);
			//添加次数
			CCLabelTTF* timesLabel = CCLabelTTF::create(groupChar.at(indexOfCharacter).at(1).c_str(),"Arial",35);
			timesLabel->setPosition(ccp(origin.x+inttimesposx,origin.y+inttimesposy));
			timesLabel->setColor(ccc3(0,0,0));
			addChild(timesLabel,2);
			//添加评判最高分
			float f_scroe = DataTool::stringToFloat(groupChar.at(indexOfCharacter).at(2));
			string highscore = DataTool::to_string_with_precision(f_scroe);
			CCLabelTTF* scoreLabel = CCLabelTTF::create(highscore.c_str(),"Arial",35);
			scoreLabel->setPosition(ccp(origin.x+intscoreposx,origin.y+intscoreposy));
			scoreLabel->setColor(ccc3(0,0,0));
			addChild(scoreLabel,2);

			//汉字管理
			temphanziManage.character=groupChar.at(indexOfCharacter).at(0);
			temphanziManage.textbox=pLabel;
			temphanziManage.pos=CCPoint(x,y);
			temphanziManage.filename=tempfilename;
// 			temphanziManage.proficiency=atoi(temppro.c_str());

			vector<CHanziManage>::iterator it = hanzilist.end(); 
			hanzilist.insert(it,temphanziManage);
			stoneElement=stoneElement->NextSiblingElement();

			indexOfCharacter++;
		}
	}
}
void RPGMapItemsMenuLayer::onChoicePlayer(cocos2d::CCObject *pObject)
{
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
    
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    if(menuItem->getTag() == kRPGMapChoicePlayerMenuLayerTagMainMenuBack)
    {
        //按了退出
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg, true);
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer, true);
        this->getParent()->removeChildByTag(kRPGMapItemsMenuLayerTagBtnDiscard, true);
        this->setVisible(true);
    }
    else
    {
        bool isSuccess = RPGResultsLogic::useItems(this->m_db, menuItem->getTag() - kRPGMapChoicePlayerMenuLayerTagMainMenuPlayer, this->m_selectedItems->m_dataId);
        if(!isSuccess)
        {
            //道具使用失败
            CCSize winSize = CCDirector::sharedDirector()->getWinSize();
            RPGDialogLayer *dialog = RPGDialogLayer::create(((CCString*)this->m_stringList->objectForKey("menu_items_fail"))->getCString(), ((CCString*)this->m_stringList->objectForKey("confirm_exit_ok"))->getCString(), kRPGMapItemsMenuLayerTagDialogOK, winSize.width, winSize.height, this, menu_selector(RPGMapItemsMenuLayer::onDialog));
            dialog->setTag(kRPGMapItemsMenuLayerTagDialog);
            this->getParent()->addChild(dialog);
            
        }
        else
        {
            //道具使用成功
            this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg, true);
            this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer, true);
            this->getParent()->removeChildByTag(kRPGMapItemsMenuLayerTagBtnDiscard, true);
            this->setVisible(true);
            
            this->loadItemsData();
        }
    }
    
}
Beispiel #28
0
void StoreBScene::createListViewItem(CCPoint& origin, CCMenu* menu, CCSize& visibleSize, int tag, const char* img) {
	GameMenuItem *pChooseItem = GameMenuItem::itemWithLabel(
		CCSprite::create("button.png"),
					this,
					menu_selector(StoreBScene::menuChooseCallback));

	string itemId = itemIdFromTag(tag);

	char name[512];
	char info[512];
	double price = 0;
	int balance = 0;
	if (itemId == "ERROR") {
		snprintf(name, sizeof(name), "Remove Ads!");
		snprintf(info, sizeof(info), "Test purchase of MANAGED item.");
		price = 5.99f;
	}
	else {
		// TODO: exception handling ..
	    string nameS = cocos2dx_StoreInfo::getItemName(itemId.c_str());
		string infoS = cocos2dx_StoreInfo::getItemDescription(itemId.c_str());
		price = cocos2dx_StoreInfo::getItemPrice(itemId.c_str());

		snprintf(name, sizeof(name), nameS.c_str());
		snprintf(info, sizeof(info), infoS.c_str());
	}

	float yOffset = - 200;

	pChooseItem->setPosition(ccp(origin.x + visibleSize.width/2, yOffset + origin.y + visibleSize.height - 100 - (tag * pChooseItem->boundingBox().size.height)));
	pChooseItem->setTag(tag);


	CCSprite* pSpritePic = CCSprite::create(img);
	pSpritePic->setPosition(ccp(pSpritePic->boundingBox().size.width/2 + 20, pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pSpritePic, 0);


	CCLabelTTF* pLabelName = CCLabelTTF::create(name, "GoodDog.otf", 44);
	pLabelName->setColor(ccc3(0,0,0));
	pLabelName->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelName->boundingBox().size.width / 2) + 20 , pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelName);


	CCLabelTTF* pLabelInfo = CCLabelTTF::create(info, "GoodDog.otf", 20);
	pLabelInfo->setColor(ccc3(50,50,50));
	pLabelInfo->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelInfo->boundingBox().size.width / 2) + 20 , -50 + (pChooseItem->boundingBox().size.height/2)));
	pChooseItem->addChild(pLabelInfo);


	CCLabelTTF* pLabelClickToBuy = CCLabelTTF::create("Click to Buy", "GoodDog.otf", 24);
	pLabelClickToBuy->setColor(ccc3(0,255,255));
	pLabelClickToBuy->setPosition(ccp(pChooseItem->boundingBox().size.width - (pLabelClickToBuy->boundingBox().size.width / 2) - 20 , 60 + pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelClickToBuy);

	char buffer[512];

	snprintf(buffer, sizeof(buffer), "price: $%.2f",  price);

	CCLabelTTF* pLabelPriceBalance = CCLabelTTF::create(buffer, "GoodDog.otf", 24);
	pLabelPriceBalance->setColor(ccc3(0,255,255));
	pLabelPriceBalance->setPosition(ccp(pChooseItem->boundingBox().size.width - (pLabelPriceBalance->boundingBox().size.width / 2) - 20 , 60));
	pChooseItem->addChild(pLabelPriceBalance);

	menu->addChild(pChooseItem, 1);
}
Beispiel #29
0
bool SGSetItem::initWithSize(int num)
{
	ResourceManager::sharedInstance()->bindTexture("sgsetlayer/sgsetlayer.plist", RES_TYPE_LAYER_UI, sg_setLayer);
 	
    menu1 = CCMenu::create();
    menu1->setPosition(CCPointZero);
    this->addChild(menu1);

    if (!SNSTableViewCellItem::init()) {
		return false;
	}
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCSprite *item = CCSprite::createWithSpriteFrameName("item_bigbg.png");
    bgbgbg = NULL;

    this->addChild(item,-1);
//    if(num ==2)
//    {
//        on = SGButton::create("help/blueBtn.png", "help/font_show.png", this,menu_selector(SGSetItem::turnOnHandler),CCPointZero,false,false);
//        off = SGButton::create("friend/friend_grayBtn.png", "help/font_hide.png", this,menu_selector(SGSetItem::turnOffHandler),CCPointZero,false,false);
//    }
//    else{
        on = SGButton::create("blueBtn.png", "font_on.png", this,menu_selector(SGSetItem::turnOnHandler),CCPointZero,false,true);
        off = SGButton::create("friend_grayBtn.png", "font_off.png", this,menu_selector(SGSetItem::turnOffHandler),CCPointZero,false,true);
//    }
    
    
    
    on->setPosition(ccpAdd(item->getPosition(), ccp(item->getContentSize().width*.12, 0)));
    
    menu1->addChild(on,1,num);
    off->setPosition(ccpAdd(item->getPosition(), ccp(item->getContentSize().width*.3, 0)));
    menu1->addChild(off,1,num);
    on->setTag(num);
    off->setTag(100+num);
    
    SGCCLabelTTF *label = SGCCLabelTTF::create("", FONT_PANGWA, FONTSIZE(18));
    this->addChild(label);
    label->setAnchorPoint(ccp(0, 0.5));
    label->setPosition(ccpAdd(item->getPosition(), ccp(- item->getContentSize().width*.4, 0)));
    
    switch (num) {
        case 0:
        {
            label->setString(str_SetItem_str1);
//            CCSprite *tujian = CCSprite::create("help/font_yinyue.png");
//            tujian->setPosition(ccpAdd(item->getPosition(), ccp(- item->getContentSize().width*.35, 0)));
//            tujian->setAnchorPoint(ccp(0, 0.5));
//            this->addChild(tujian);
            std::string str;
            str = CCUserDefault::sharedUserDefault()->getStringForKey("isplaymusic");
            int isplay = CCString::create(str)->intValue();
            if (isplay != 0) {
                off->setImage("blueBtn.png");
                on->setImage("friend_grayBtn.png");
            }
            
            }
            break;
        case 1:
        {
            label->setString(str_SetItem_str2);
            std::string str;
            str = CCUserDefault::sharedUserDefault()->getStringForKey("isplayeffect");
            int isplay = CCString::create(str)->intValue();
            if (isplay != 0) {
                off->setImage("blueBtn.png");
                on->setImage("friend_grayBtn.png");
            }
//            CCSprite *shezhi = CCSprite::create("help/font_yinxiao.png");
//            shezhi->setPosition(ccpAdd(item->getPosition(), ccp(- item->getContentSize().width*.35, 0)));
//            shezhi->setAnchorPoint(ccp(0, 0.5));
//            this->addChild(shezhi);
            
        }
            break;
        case 2:
        {
            label->setString(str_SetItem_str3);
//            CCSprite *bangzhu = CCSprite::create("help/font_wangge.png");
//            bangzhu->setPosition(ccpAdd(item->getPosition(), ccp(- item->getContentSize().width*.35, 0)));
//            bangzhu->setAnchorPoint(ccp(0, 0.5));
//            this->addChild(bangzhu);                       
        }
            break;
        case 3:
        {
            label->setString(str_SetItem_str3);
//            CCSprite *fankui = CCSprite::create("help/font_tuisong.png");
//            fankui->setPosition(ccpAdd(item->getPosition(), ccp(- item->getContentSize().width*.35, 0)));
//            fankui->setAnchorPoint(ccp(0, 0.5));
//            this->addChild(fankui);
                   }
            break;
        default:
            break;
            
    }    
     return true;
}
Beispiel #30
0
void GameLayer::instructionButtonClick(CCObject *sender){
	if (bPaused) {
		return;
	}

	bPaused = true;
	CCLayer *layer2 = new CCLayer();

	CCSprite* dialog_bk = ThemeManager::sharedInstance()->spriteWithImageFile("dialog_intro.png");
	dialog_bk->setScaleX(SCREEN_WIDTH/dialog_bk->getContentSize().width);
	dialog_bk->setScaleY(SCREEN_WIDTH/dialog_bk->getContentSize().width);
	dialog_bk->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
	layer2->addChild(dialog_bk,11);

	CCSprite* cancelNormal = ThemeManager::sharedInstance()->spriteWithImageFile("btn_know.png");
	CCSprite* cancelSelected = ThemeManager::sharedInstance()->spriteWithImageFile("btn_know.png");
	
	//CCMenuItemSprite* pcancelItemSprite = CCMenuItemSprite::itemWithNormalSprite(cancelNormal, cancelSelected, this, menu_selector(GameLayer::theme3useButtonClick));
	CCMenuItemSprite* pcancelItemSprite = CCMenuItemSprite::itemWithNormalSprite(cancelNormal, cancelSelected, this, menu_selector(GameLayer::cancelButtonClick));
	pcancelItemSprite->setScale(0.6*LL_SCREEN_SCALE_VALUE);
	CCMenu* pcancelMenu = CCMenu::menuWithItems(pcancelItemSprite,NULL);
	pcancelMenu->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.28));

	layer2->addChild(pcancelMenu, 12);
	layer2->setTag(1000);
	CCActionInterval* largeto = CCScaleBy::create(0.2, 2);
	layer2->setScale(0.5);
	layer2->runAction(largeto);
	this->addChild(layer2, 10);
}