本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 ¢er = 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;
}
示例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);
}