当前位置: 首页>>代码示例>>C++>>正文


C++ CCMenuItemImage::getContentSize方法代码示例

本文整理汇总了C++中CCMenuItemImage::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::getContentSize方法的具体用法?C++ CCMenuItemImage::getContentSize怎么用?C++ CCMenuItemImage::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCMenuItemImage的用法示例。


在下文中一共展示了CCMenuItemImage::getContentSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

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

    //set color on background
    if (CCLayerColor::initWithColor(ccc4 (255, 255, 255, 255)))
    {
    }

    CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("background-music-aac.wav", true);

    mtargets = new CCArray;
    mprojectiles = new CCArray;

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

    /////////////////////////////
    // 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);

    /////////////////////////////
    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::create("Player.png", CCRectMake(0, 0, 27, 40));

    // position the sprite on the center of the screen
    pSprite->setPosition(ccp(20, visibleSize.height/2));

    //listern touch action
    setTouchEnabled (true);

    //add enemies into game
    this->schedule( schedule_selector (HelloWorld::gameLogic), 1.0);
    //call update function
    this->schedule( schedule_selector (HelloWorld::update) );
    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);

    return true;
}
开发者ID:nhanv,项目名称:tutorial1,代码行数:61,代码来源:HelloWorldScene.cpp

示例2: init

// on "init" you need to initialize your instance
bool HelloOgre::init(){
    if ( !CCLayer::init() ){
        return false;
    }

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

    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
	tAssertm( pSprite, "HelloWorld.png" );
    pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
	pSprite->setScale( 0.1 );
    this->addChild(pSprite, 0);

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
    					"CloseNormal.png", "CloseSelected.png", this,
						menu_selector(HelloOgre::menuCloseCallback));
	pCloseItem->setPosition(
				ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
               		origin.y + pCloseItem->getContentSize().height/2));
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCLabelTTF* pLabel = CCLabelTTF::create("Hello Ogre", "Arial", TITLE_FONT_SIZE);
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));
    this->addChild(pLabel, 1);

	initOgre();
	createManual();
	scheduleUpdate();
    return true;
}
开发者ID:dorgonman,项目名称:cocos2d-x-ogre,代码行数:35,代码来源:helloogre.cpp

示例3: init

// on "init" you need to initialize your instance
bool GameScene::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

    // 背景画像を設定する
    setBackGroundSprite();

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

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

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

    CCMenu* pMenuClose = CCMenu::create(pCloseItem, NULL);
    pMenuClose->setPosition(CCPointZero);
    this->addChild(pMenuClose, 1);

    CCLabelTTF* pLabel = CCLabelTTF::create("GameScene", "Arial", 24);
    pLabel->setColor(ccc3((GLubyte)0,(GLubyte)0,(GLubyte)0));
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

    this->addChild(pLabel, 1);

    // 線引きのガイダンスを表示
    int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 18;
    CCLabelTTF *label = CCLabelTTF::create("指でなぞったラインを CCMotionStreak で描画します", "Helvetica", /*fontSize*/ 24);
    label->setColor(ccc3((GLubyte)0,(GLubyte)0,(GLubyte)0));
    label->setPosition(ccp(visibleSize.width / 2, visibleSize.height - label->getContentSize().height * 4));
    this->addChild(label);

    this->setTouchEnabled(true);	// タッチイベントを有効化
    this->setTouchMode(kCCTouchesOneByOne);		// シングルタッチ

//    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
//    pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
//    this->addChild(pSprite, 0);

    // 次の画面へ遷移するボタン
    CCMenuItemImage *pNextItem = CCMenuItemImage::create(
                                     "HelloWorld.png",
                                     "HelloWorld_02.png",
                                     this,
                                     menu_selector(GameScene::buttonOnClickCallBack));
    pNextItem->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    CCMenu* pMenuNext = CCMenu::create(pNextItem, NULL);
    pMenuNext->setPosition(CCPointZero);
    this->addChild(pMenuNext, 0);

    return true;
}
开发者ID:nitobe-gloops,项目名称:DemoApplication,代码行数:61,代码来源:GameScene.cpp

示例4: init

// 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();

    /////////////////////////////
    // 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);

	initScene();

    return true;
}
开发者ID:jinjianxin,项目名称:cocos2d-x,代码行数:36,代码来源:HelloWorldScene.cpp

示例5: tableCellAtIndex

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


	return cell;
}
开发者ID:longguai,项目名称:game-DarkWar,代码行数:27,代码来源:MainLayerZhuangBeiBody.cpp

示例6: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccpAdd(VisibleRect::rightBottom(), 
	                        	ccp(-pCloseItem->getContentSize().width/2, pCloseItem->getContentSize().height/2)));
	
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", SCALE_FACTOR * 24);
	pLabel->setPosition(ccpAdd(VisibleRect::top(),
                            ccp(0, -pLabel->getContentSize().height)));
    this->addChild(pLabel, 1);

    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
	pSprite->setPosition(VisibleRect::center());
    this->addChild(pSprite, 0);

	CCSprite *pLogoSprite = CCSprite::create("icon.png");
	pLogoSprite->setAnchorPoint( ccp(0, 0.5) );
	pLogoSprite->setPosition(ccpAdd(VisibleRect::left(), ccp(50, 0)));
	this->addChild(pLogoSprite, 0);

    return true;
}
开发者ID:wwb0709,项目名称:feichuan,代码行数:36,代码来源:HelloWorldScene.cpp

示例7: init

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

    this->setKeypadEnabled(true);

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

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

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

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

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

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

    return true;
}
开发者ID:CaiZhongda,项目名称:cocos2dx-talkingdata,代码行数:61,代码来源:MissionScene.cpp

示例8: init

bool GameEntryLayer::init() {
    if ( !CCLayerColor::initWithColor( ccc4(255, 255, 255, 255) ) ) {
		return false;
	}
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    
    
    CCSprite* pLargeImage = CCSprite::create("720x1080.png");
    pLargeImage->setPosition(CCPoint(origin.x + pLargeImage->getContentSize().width / 2, pLargeImage->getContentSize().height / 2));
    this->addChild(pLargeImage);
    
    CCSprite* pSmallImage = CCSprite::create("360x540.png");
    pSmallImage->setPosition(ccp(origin.x + pSmallImage->getContentSize().width / 2, origin.y + pSmallImage->getContentSize().height / 2));
    this->addChild(pSmallImage);
    
    // make the menu itemof start game.
    CCMenuItemImage *pStartGameItem = CCMenuItemImage::create(
                                                              "StartNormal.png",
                                                              "StartSelected.png",
                                                              this,
                                                              menu_selector(GameEntryLayer::menuStartGameCallback));
    
    pStartGameItem->setPosition(ccp(origin.x + visibleSize.width / 2 - pStartGameItem->getContentSize().width/2 ,
                                    origin.y + visibleSize.height / 2 + pStartGameItem->getContentSize().height/2));
    
    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pStartGameItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);
    
    
    return true;
}
开发者ID:andropenguin,项目名称:SimpleGameRev,代码行数:35,代码来源:GameEntry.cpp

示例9: init

// 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();

    /////////////////////////////
    // 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("HelloWorld.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);
    
    // enable standard touch
    this->setTouchEnabled(true);
    
    return true;
}
开发者ID:faizhalgumi,项目名称:cocos2dx-projects,代码行数:60,代码来源:HelloWorldScene.cpp

示例10: init

// 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();

    /////////////////////////////
    // 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...
    CCNode* gameScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("DemoCowboy.json");
    addChild(gameScene);
    
    //Create player
    CCNode* playerNode = gameScene->getChildByTag(10004);
    player = new Player(playerNode);
    
    //Assign callbacks to the buttons
    CCNode* uiNode = gameScene->getChildByTag(10005);
    UILayer* ui = (UILayer*)uiNode->getComponent("GUIComponent")->getNode();
    
    UIButton* btnLeft = (UIButton*)ui->getWidgetByName("LeftButton");
    btnLeft->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveLeft));
    
    UIButton* btnRight = (UIButton*)ui->getWidgetByName("RightButton");
    btnRight->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveRight));
    
    UIButton* btnFire = (UIButton*)ui->getWidgetByName("FireButton");
//    btnFire->addReleaseEvent(this, coco_releaseselector(HelloWorld::onFire));
    btnFire->addTouchEventListener(this, toucheventselector(HelloWorld::onFire));
    
    //Enable update loop
    this->scheduleUpdate();
    
    return true;
}
开发者ID:NSJang,项目名称:CocoStudioSamples,代码行数:60,代码来源:HelloWorldScene.cpp

示例11: init

// on "init" you need to initialize your instance
bool CMainScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCScene::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 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(CMainScene::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + pCloseItem->getContentSize().width/2 ,
		origin.y - pCloseItem->getContentSize().height/2 + visibleSize.height));

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

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

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

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

    // add "CMainScene" splash screen"
    CCSprite* pSprite = CCSprite::create("background.png");
	CCSize sz = pSprite->getContentSize();
    // position the sprite on the center of the screen
    pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
	this->addChild(pSprite);

	CNavigationLy *pNavLayer = CNavigationLy::create(m_pTitle);
	pNavLayer->setPosition(ccp(visibleSize.width / 2, pNavLayer->getButtonHeight() / 2));
	this->addChild(pNavLayer);

    return true;
}
开发者ID:alpha2z,项目名称:DJSender,代码行数:60,代码来源:CMainScene.cpp

示例12: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayerColor::initWithColor(ccc4(255,255,255,255)))
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 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

    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCSprite* player = CCSprite::create("Player.png");
    player->setPosition(ccp(winSize.width/2, winSize.height/15));
    //player->getContentSize().width*20
    this->addChild(player);
    
    //call game logic about every second
    this->schedule(schedule_selector(HelloWorld::gameLogic), 1.0f);
    this->schedule(schedule_selector(HelloWorld::update));
    
    
    this->setTouchEnabled(true);
    
    _targets = new CCArray;
    _projectiles = new CCArray;
    
    
    return true;
}
开发者ID:ChungH,项目名称:OOP-study,代码行数:57,代码来源:HelloWorldScene.cpp

示例13: init

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

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

    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));

    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

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

#if 0
    CCLayerColor *colorLayer = CCLayerColor::create(ccc4(0,80,80,255));
    addChild(colorLayer);

    CCSprite *spr_premulti = CCSprite::create("Ball.png");
    spr_premulti->setPosition(ccp(16,48));

    CCSprite *spr_nonpremulti = CCSprite::create("Ball.png");
    spr_nonpremulti->setPosition(ccp(16,16));


    CCRenderTexture *rend = CCRenderTexture::create(32, 64, kCCTexture2DPixelFormat_RGBA8888);

    if (rend == NULL)
        exit(0);

    rend->begin();
    spr_premulti->visit();
    spr_nonpremulti->visit();
    rend->end();

    addChild(spr_nonpremulti);
    addChild(spr_premulti);
    addChild(rend);
#endif

	scheduleUpdate();

    return true;
}
开发者ID:jinjianxin,项目名称:cocos2d-x,代码行数:55,代码来源:HelloWorldScene.cpp

示例14: init

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

    CCSprite *bg = CCSprite::create("background.png");
    bg->setPosition(VisibleRect::center());
    //CCSize &winSize = CCDirector::sharedDirector()->getWinSize();
    //float scalex = winSize.width / 480;
    //float scaley = winSize.height / 800;
    //bg->setScaleX(scalex);
    //bg->setScaleY(scaley);
    addChild(bg);

    const CCPoint &center = VisibleRect::center();

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
        "CloseNormal.png",
        "CloseSelected.png",
        this,
        menu_selector(HelloScene::menuCloseCallback));
    pCloseItem->setPosition(ccp(VisibleRect::rightBottom().x - pCloseItem->getContentSize().width/2 ,
        pCloseItem->getContentSize().height/2));
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCLabelTTF *title = CCLabelTTF::create("Lovexin Plane Chess", "Arial", 40);
    title->setPosition(ccp(center.x, center.y + 250));
    CCLabelTTF *author = CCLabelTTF::create("made by Waltz Duyf", "Arial", 20);
    author->setPosition(ccp(center.x + 100, center.y + 200));
    addChild(title);
    addChild(author);

    addSetupSwitch(ccp(center.x - 120, center.y + 50 ), "RED", ccc3(255, 0, 0), FORCE_COLOR_RED);//, cccontrol_selector(HelloScene::valueChangedJoinInR), cccontrol_selector(HelloScene::valueChangedAIR));
    addSetupSwitch(ccp(center.x - 120, center.y - 10 ), "YEL", ccc3(234, 165, 0), FORCE_COLOR_YELLOW);//, cccontrol_selector(HelloScene::valueChangedJoinInY), cccontrol_selector(HelloScene::valueChangedAIY));
    addSetupSwitch(ccp(center.x - 120, center.y - 70 ), "GRE", ccc3(0, 255, 0), FORCE_COLOR_GREEN);//, cccontrol_selector(HelloScene::valueChangedJoinInG), cccontrol_selector(HelloScene::valueChangedAIG));
    addSetupSwitch(ccp(center.x - 120, center.y - 130), "BLU", ccc3(0, 144, 255), FORCE_COLOR_BLUE);//, cccontrol_selector(HelloScene::valueChangedJoinInB), cccontrol_selector(HelloScene::valueChangedAIB));

    CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
    CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
    CCLabelTTF *titleButton = CCLabelTTF::create("Play Now", "Arial", 30);
    titleButton->setColor(ccc3(159, 168, 176));
    CCControlButton *button = CCControlButton::create(titleButton, backgroundButton);
    button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
    button->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
    button->setMargins(70, 20);
    button->setPosition(ccp(center.x, center.y - 250));
    addChild(button);
    button->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloScene::playBtnCallback), CCControlEventTouchUpInside);

    return true;
}
开发者ID:waltzduyf,项目名称:cocos2d_game,代码行数:55,代码来源:HelloScene.cpp

示例15: setMenuBackMenu

void CreditsScene::setMenuBackMenu()
{
	CCMenuItemImage * itemImage = CCMenuItemImage::create("Menu.png","Menu.png",this,menu_selector(CreditsScene::mainMenuCallback));

	itemImage->setPosition(ccp(VisibleRect::rightBottom().x - itemImage->getContentSize().width/2,
                               VisibleRect::rightBottom().y + itemImage->getContentSize().height/2));

    CCMenu* pMenu = CCMenu::create(itemImage, NULL);
    pMenu->setPosition(CCPointZero);
    addChild(pMenu, 1);
}
开发者ID:Hector-hedb12,项目名称:Zombies,代码行数:11,代码来源:CreditsScene.cpp


注:本文中的CCMenuItemImage::getContentSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。