本文整理汇总了C++中CCMenuItemImage::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::setScale方法的具体用法?C++ CCMenuItemImage::setScale怎么用?C++ CCMenuItemImage::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::setScale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startGame
void TetrisGameLayer::startGame(){
G_current_HandleType = new LongBlock_Type();
G_current_HandleType->init();
CCSize size = CCDirector::sharedDirector()->getWinSize();
//控制按钮//
CCMenuItemImage * left = CCMenuItemImage::create("left.png", "left.png");
left->setTarget(this, menu_selector(TetrisGameLayer::leftButtonPressed));
left->setScale(0.5);
CCMenuItemImage * right = CCMenuItemImage::create("right.png", "right.png");
right->setTarget(this, menu_selector(TetrisGameLayer::rightButtonPressed));
left->setAnchorPoint(ccp(0, 0));
right->setAnchorPoint(ccp(0, 0));
right->setScale(0.5);
right->setPosition(ccp(size.width/2+size.width/4, 0));
CCMenuItemImage * down = CCMenuItemImage::create("down.png", "down.png");
down->setTarget(this, menu_selector(TetrisGameLayer::downButtonPressed));
down->setAnchorPoint(ccp(0,0));
down->setScale(0.5);
down->setPosition(ccp(size.width/2 -100,0));
down->setOpacity(0.7*255);
CCMenu * menu = CCMenu::create(left,down,right, NULL);
menu->setAnchorPoint(ccp(0, 0));
menu->setPosition(ccp(0, 0));
this->addChild(menu);
}
示例2: init
bool StartScene::init()
{
if (!CCLayer::init()) {
return false;
}
CCSize winsize = CCDirector::sharedDirector()->getWinSize();
CCSprite* bgsprite = CCSprite::create("bg54.jpg");
bgsprite->setScale(0.6);
bgsprite->setPosition(ccp(winsize.width/2, winsize.height/2));
this->addChild(bgsprite);
CCSprite* bgtitle = CCSprite::create("bgtitle.png");
bgtitle->setScale(0.35);
bgtitle->setPosition(ccp(winsize.width/2, winsize.height/2+100));
this->addChild(bgtitle);
CCSprite* bg = CCSprite::create("gamebg.png");
bg->setScale(0.6);
bg->setPosition(ccp(winsize.width/2, winsize.height/2-25));
this->addChild(bg);
//选择按钮
CCMenuItemImage* startItem = CCMenuItemImage::create("start.png", "start.png",this,menu_selector(StartScene::startBtn));
startItem->setScale(0.6);
startItem->setPosition(ccp(winsize.width/2, winsize.height/2-25));
CCMenuItemImage* helpItem = CCMenuItemImage::create("help.png", "help.png");
helpItem->setTarget(this, menu_selector(StartScene::helpBtn));
helpItem->setScale(0.6);
helpItem->setPosition(ccp(winsize.width/2, winsize.height/2-75));
//音效按钮
CCMenuItemImage* start = CCMenuItemImage::create("music2.png", "music2.png");
CCMenuItemImage* start1 = CCMenuItemImage::create("music1.png", "music1.png");
CCMenuItemToggle* tog1 = CCMenuItemToggle::createWithTarget(this, menu_selector(StartScene::musicBtn),start,start1,NULL);
tog1->setPosition(ccp(winsize.width/2+100, winsize.height/2-25));
CCMenuItemImage* yinxiao = CCMenuItemImage::create("music3.png", "music3.png");
CCMenuItemImage* yinxiao1 = CCMenuItemImage::create("music4.png", "music4.png");
CCMenuItemToggle* tog2 = CCMenuItemToggle::createWithTarget(this, menu_selector(StartScene::yinxiaoBtn),yinxiao,yinxiao1,NULL);
tog2->setPosition(ccp(winsize.width/2+100, winsize.height/2-55));
CCMenu* menu = CCMenu::create(startItem,helpItem,tog1,tog2, NULL);
menu->setPosition(CCPointZero);
this->addChild(menu,1);
return true;
}
示例3: onHandlePropTypeSpriteFrame
NS_CC_EXT_BEGIN
void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame);
// #HLP_BEGIN
// #resource_scale_fix
CCMenuItemImage *item = (CCMenuItemImage *)pNode;
item->setNormalSpriteFrame(pCCSpriteFrame);
if(item->getTag() != TAG_INTERNET_MENU_ITEM_IMAGE){
item->setScale(item->getScale() * CC_CONTENT_SCALE_FACTOR() / CC_RESOURCE_SCALE_FACTOR());
}
// #HLP_END
}
} else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame);
}
} else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame);
}
} else {
CCMenuItemLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
}
}
示例4: addCtrlPanel
void SceneGame::addCtrlPanel()
{
CCMenu* menu = CCMenu::create();
addChild(menu, Z_MENU);
CCMenuItemImage* regretItem = CCMenuItemImage::create("regret.jpg", "regret.jpg",
this, menu_selector(SceneGame::Regret));
menu->addChild(regretItem, Z_MENU);
Common::moveNode(regretItem, ccp(160, 60));
// 启动服务器的按钮
CCMenuItem* startServerItem = CCMenuItemFont::create("StartServer", this, menu_selector(SceneGame::startServer));
menu->addChild(startServerItem, Z_MENU);
Common::moveNode(startServerItem, ccp(160, 0));
// 启动客户端的按钮
CCMenuItem* startClientItem = CCMenuItemFont::create("StartClient", this, menu_selector(SceneGame::startClient));
menu->addChild(startClientItem, Z_MENU);
Common::moveNode(startClientItem, ccp(160, -60));
startServerItem->setUserObject(startClientItem);
startClientItem->setUserObject(startServerItem);
regretItem->setScale(0.7f);
startServerItem->setScale(0.7f);
startClientItem->setScale(0.7f);
}
示例5: showGameEnd
void GameScene::showGameEnd()
{
gameLayer->showGameEnd();
timeBoard->runAction(CCMoveTo::create(0.3f,ccp(0,1136+158)));
CCLayer* gameEndLayer = CCLayer::create();
CCSprite* bgSprite = CCSprite::create("fade.png");
scoreTxt = CCLabelBMFont::create(GameData::shareData()->getScoreString(),"fonts/scorefont.fnt");
scoreTxt->setPosition(ccp(320,700));
scoreTxt->setScale(0.0f);
CCScaleTo* scaleTo = CCScaleTo::create(0.9f,2.5f);
CCEaseElasticInOut* scoreEff = CCEaseElasticInOut::create(scaleTo);
scoreTxt->runAction(scoreEff);
if(!scoreTxt->getParent())
gameEndLayer->addChild(scoreTxt);
bgSprite->setAnchorPoint(ccp(0,0));
gameEndLayer->addChild(bgSprite);
CCLabelTTF* txt = CCLabelTTF::create("Game End","fonts/Marker Felt.ttf",40.0f);
txt->setPosition(ccp(320,568));
gameEndLayer->addChild(txt);
CCMenuItemImage* imageItem = CCMenuItemImage::create("CloseNormal.png","CLoseSelected.png", this,menu_selector(GameScene::backToMainMenu));
CCMenu* menu = CCMenu::create(imageItem,NULL);
menu->setAnchorPoint(ccp(0,0));
menu->setPosition(ccp(320,300));
imageItem->setScale(3.0f);
gameEndLayer->addChild(menu);
this->addChild(gameEndLayer,100,this->getChildrenCount());
}
示例6: initSceneChoose
//添加3个选关按钮
void MenuScene::initSceneChoose()
{
float pngWidth = 362.0;
float xSpace = (size.width - pngWidth*3)/4;
//添加练习场菜单项
CCActionInterval* scaleToex1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleToex2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence1 = CCSequence::create(scaleToex1,scaleToex2,NULL);
CCActionInterval* rotate1 = CCRepeatForever::create(sequence1);
CCMenuItemImage *exersize = CCMenuItemImage::create("ZF_Shoot_Button_lxc.png", "ZF_Shoot_Button_lxc.png", this, menu_selector(MenuScene::menuChoseScene));
exersize->setPosition(ccp(xSpace+pngWidth/2, size.height/2));
exersize->setScale(kScaleRitio);
exersize->setTag(kExserciseTag);
exersize->runAction(rotate1);
//添加平民场菜单项
CCActionInterval* scaleTope1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleTope2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence2 = CCSequence::create(scaleTope1,scaleTope2,NULL);
CCActionInterval* rotate2 = CCRepeatForever::create(sequence2);
CCMenuItemImage *people = CCMenuItemImage::create("ZF_Shoot_Button_pmc.png", "ZF_Shoot_Button_pmc.png", this, menu_selector(MenuScene::menuChoseScene));
people->setPosition(ccp(xSpace*2+pngWidth*1.5, size.height/2));
people->setScale(kScaleRitio);
people->setTag(kPeopleTag);
people->runAction(rotate2);
//添加富豪场菜单项
CCActionInterval* scaleTori1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleTori2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence3 = CCSequence::create(scaleTori1,scaleTori2,NULL);
CCActionInterval* rotate3 = CCRepeatForever::create(sequence3);
CCMenuItemImage *rich = CCMenuItemImage::create("ZF_Shoot_Button_hhc.png", "ZF_Shoot_Button_hhc.png", this, menu_selector(MenuScene::menuChoseScene));
rich->setPosition(ccp(xSpace*3+pngWidth*2.5, size.height/2));
rich->setScale(kScaleRitio);
rich->setTag(kRichTag);
rich->runAction(rotate3);
//集成到菜单容器
richMenu = CCMenu::create(rich,people,exersize,NULL);
richMenu->setPosition(CCPointZero);
this->addChild(richMenu,1);
}
示例7: init
bool CollectView::init()
{
if ( !CCLayer::init() )
{
return false;
}
CollectView::set=false;
CollectView::set2=true;
CCSize size=CCDirector::sharedDirector()->getWinSize();
CCSprite* back=CCSprite::create("ZBG.png");
back->setPosition(ccp(size.width/2,size.height/2));
this->addChild(back);
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(CollectView::next) );
pCloseItem->setPosition( ccp(size.width - 25, size.height-25) );
pCloseItem->setScale(2.0);
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
setImage();
CCSprite* state=CCSprite::create("state.png");//ステータスバー
state->setScaleY(0.7);
state->setScaleX(0.9);
state->setPosition(ccp(size.width/2,size.height-(state->getContentSize().height/3)));
this->addChild(state);
//ステータスに表示
CCLabelTTF* power=CCLabelTTF::create(HelloWorld::getPower().c_str(),"Thonburi",40);
CCLabelTTF* stamina=CCLabelTTF::create(HelloWorld::getStamina().c_str(),"Thonburi",40);
CCLabelTTF* money=CCLabelTTF::create(HelloWorld::getMoney().c_str(),"Thonburi",40);
power->setPosition(ccp(size.width/5*4,size.height/40*39));
stamina->setPosition(ccp(size.width/5*4,size.height/40*37.5));
money->setPosition(ccp(size.width/5*4,size.height/40*36-5));
ccColor3B sc=power->getColor();
sc.r=0;
sc.g=0;
sc.b=0;
power->setColor(sc);
stamina->setColor(sc);
money->setColor(sc);
this->addChild(power);
this->addChild((stamina));
this->addChild((money));
//ここまで
setHatenaK();
return true;
}
示例8: addFailMenu
// Add button menu to fail layer.
void GameEndLayer::addFailMenu()
{
CCMenuItemImage* replay = CCMenuItemImage::create(nameOfRestartNormal, nameOfRestartSelect, this,
menu_selector(GameEndLayer::onReplay));
replay->setScale(1.5f);
CCMenuItemImage* levels = CCMenuItemImage::create(nameOfSelectLevelNormal, nameOfSelectLevelSelect, this,
menu_selector(GameEndLayer::onLevels));
levels->setScale(1.5f);
CCMenu* menu = CCMenu::create(replay, levels, NULL);
//menu->setScale(1.5f);
// Padding the items.
menu->alignItemsHorizontallyWithPadding(20);
menu->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2 ,
CCDirector::sharedDirector()->getWinSize().height / 3));
this->addChild(menu, 2);
}
示例9: init
bool CustomPop::init(){
if(!CCLayerColor::initWithColor(ccc4(0, 0, 0, 180))){
return false;
}
this->setTouchEnabled(true);
CCSize size=CCDirector::sharedDirector()->getWinSize();
this->setContentSize(size);
CCSprite *bkg = CCSprite::create("common_pop_bkg.png");
bkg->setPosition(ccp(size.width/2, size.height/2));
this->addChild(bkg);
CCSize sz = bkg->getContentSize();
ccColor3B black1 = ccc3(236, 190, 108);
ccColor3B black = ccc3(27, 18, 6);
CCLabelTTF* title = CCLabelTTF::create("提 示", "hycc.ttf", 28);
title->setColor(black);
title->setAnchorPoint(ccp(0.5, 1));
title->setPosition(ccp(sz.width/2+1, sz.height-23));
bkg->addChild(title);
CCLabelTTF* title1 = CCLabelTTF::create("提 示", "hycc.ttf", 28);
title1->setColor(black1);
title1->setAnchorPoint(ccp(0.5, 1));
title1->setPosition(ccp(sz.width/2, sz.height-22));
bkg->addChild(title1);
desc = CCLabelTTF::create("", "hycc.ttf", 25,CCSizeMake(400, 0),kCCTextAlignmentCenter);
desc->setColor(black);
// desc->setAnchorPoint(ccp(0.5, 1));
desc->setPosition(ccp(sz.width/2, sz.height/2+10));
bkg->addChild(desc);
CCMenuItemImage* bz = CCMenuItemImage::create("common_btn_ok_1.png", "common_btn_ok_2.png", this, menu_selector(CustomPop::close));
// bz->setAnchorPoint(ccp(0,0));
// bz->setPosition(ccp(sz.width/2, 30));
bz->setScale(1.3);
btnsMenu = CCMenu::create(bz,NULL);
btnsMenu->setPosition(ccp(sz.width/2,80));
bkg->addChild(btnsMenu);
return true;
}
示例10: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
/////////////////////////////
// 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::itemWithNormalImage(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 80, 120) );
pCloseItem->setScale(3);
pCloseItem->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(1.0f, 360)));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::menuWithItems(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::labelWithString("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
// add the label as a child to this layer
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
return true;
}
示例11: 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( ccp(CCDirector::sharedDirector()->getWinSize().width - 60, 60) );
pCloseItem->setTag(1);
pCloseItem->setScale(2.5f);
CCMenuItemImage *pCloseItem1 = CCMenuItemImage::create("CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem1->setPosition( ccp(60, 60) );
pCloseItem1->setTag(2);
pCloseItem1->setScale(2.5f);
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, pCloseItem1, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
pSprite = CCSprite::create("CloseNormal.png");
pSprite->setPosition( ccp(600, 700) );
pSprite->setTag(-1);
this->addChild(pSprite, 0);
lines = (Line *)malloc(sizeof(Line) * COUNT);
lines[0].p1 = ccp(100, 100);
lines[0].p2 = ccp(400, 100);
lines[1].p1 = ccp(500, 600);
lines[1].p2 = ccp(700, 600);
lines[2].p1 = ccp(400, 400);
lines[2].p2 = ccp(600, 500);
lines[3].p1 = ccp(500, 200);
lines[3].p2 = ccp(1000, 200);
speedX = 0;
speedY = 0;
this->scheduleUpdate();
return true;
}
示例12: init
bool GameMenu::init() {
if (!CCLayer::init()) {
return false;
}
_size = CCDirector::sharedDirector()->getWinSize();
_width = _size.width;
_height = _size.height;
_SIZE_RATIO = (_width + _height) / (640 + 960);
_SIZE_RATIO_X = _width / 640;
_SIZE_RATIO_Y = _height / 960;
CCLOG("%f %f", _width, _height);
CCSprite * background = CCSprite::create("bg_maps.png");
background->setAnchorPoint(ccp(0.5, 0.5));
background->setPosition(ccp(_width / 2, _height / 2));
background->setScaleX(_SIZE_RATIO_X);
background->setScaleY(_SIZE_RATIO_Y);
this->addChild(background);
CCMenuItemImage * startButton =
CCMenuItemImage::create("btn_continues.png", "btn_continues_active.png",
this, menu_selector(GameMenu::menuStart));
startButton->setPosition(ccp(_width / 2, 3 * _height / 5));
startButton->setScale(_SIZE_RATIO);
CCMenuItemImage * quitButton =
CCMenuItemImage::create("frame_room.png", "frame_room.png", this,
menu_selector(GameMenu::menuCloseCallback));
quitButton->setPosition(ccp(_width / 2, _height / 5));
quitButton->setScale(_SIZE_RATIO);
CCMenuItemImage * rankButton =
CCMenuItemImage::create("frame_room.png", "frame_room.png", this,
menu_selector(GameMenu::menuRank));
rankButton->setPosition(ccp(_width / 2, 2 * _height / 5));
rankButton->setScale(_SIZE_RATIO);
CCMenu * pMenu = CCMenu::create(startButton, quitButton, rankButton, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu);
return true;
}
示例13: init
bool GameMenu::init()
{
if (!CCLayer::init())
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
//菜单背景
CCSprite *bg = CCSprite::create("MainMenu.png");
bg->setScale(0.5);
bg->setPosition(ccp(size.width/2, size.height/2));
this->addChild(bg,0,0);
//按钮
CCMenuItemImage *newGameItem = CCMenuItemImage::create("newgameA.png", "newgameB.png",this,menu_selector(GameMenu::menuNewGameCallback));
newGameItem->setScale(0.5);
newGameItem->setPosition(ccp(size.width/2 + 40, size.height/2 - 20));
newGameItem->setEnabled(false);
CCMenuItemImage *continueItem = CCMenuItemImage::create("continueA.png", "continueB.png",this,menu_selector(GameMenu::menuContinueCallback));
continueItem->setScale(0.5);
continueItem->setPosition(ccp(size.width/2 + 40, size.height/2 - 60));
continueItem->setEnabled(false);
CCMenuItemImage *aboutItem = CCMenuItemImage::create("aboutA.png", "aboutB.png",this,menu_selector(GameMenu::menuAboutCallback));
aboutItem->setScale(0.5);
aboutItem->setPosition(ccp(size.width/2 + 40, size.height/2 - 100));
aboutItem->setEnabled(false);
soundItem = CCMenuItemImage::create("sound-on-A.png", "sound-on-B.png",this,menu_selector(GameMenu::menuSoundCallback));
soundItem->setScale(0.5);
soundItem->setEnabled(false);
soundItem->setPosition(ccp(40, 40));
CCMenu *mainmenu = CCMenu::create(newGameItem,continueItem,aboutItem,soundItem,NULL);
mainmenu->setPosition(ccp(0, 0));
this->addChild(mainmenu,1,3);
issound = true;
//初始化声音
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("background.mp3"));
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("background.mp3")).c_str(), true);
return true;
}
示例14: WSBackGroundLayer
bool
WSGameScene::initWithGameCoreModeAndLevel(WSGameMode mode, uint16_t level)
{
if (CCScene::init())
{
_gameCore = new WSGameCore;
_gameCore->initWithGameModeAndMapName(mode, level, this);
_backGroundLayer = new WSBackGroundLayer();
_backGroundLayer->init();
_backGroundLayer->setAnchorPoint(ccp(0, 0));
_backGroundLayer->setPosition(ccp(0, 0));
this->addChild(_backGroundLayer);
_backGroundLayer->autorelease();
_gameBackGroundLayer = new WSGameBackGroundLayer();
_gameBackGroundLayer->initWithScene(this);
_gameBackGroundLayer->setAnchorPoint(ccp(0, 0));
_gameBackGroundLayer->setPosition(ccp(0, 0));
this->addChild(_gameBackGroundLayer);
_gameBackGroundLayer->autorelease();
_gameLayer = new WSGameLayer();
_gameLayer->initWithGameScene(this);
_gameLayer->setAnchorPoint(ccp(0, 0));
_gameLayer->setPosition(ccp(0, 0));
this->addChild(_gameLayer);
_gameLayer->autorelease();
_joyStick = new CCJoystick;
_joyStick->setScale(3);
_joyStick->init(10, 20, false, true, false, false);
_joyStick->setAnchorPoint(ccp(0, 0));
_joyStick->setPosition(ccp(160, 350));
this->addChild(_joyStick);
_joyStick->autorelease();
_joyStick->setBallTexture("joystick.png");
_joyStick->setDelegate(this);
CCMenuItemImage* btn = CCMenuItemImage::create("btn.png", "btn.png", this, menu_selector(WSGameScene::btnClick));
btn->setPosition(ccp(980, 350));
btn->setScale(2.5);
CCMenu* menu = CCMenu::createWithItem(btn);
menu->setAnchorPoint(ccp(0, 0));
menu->setPosition(ccp(0, 0));
this->addChild(menu);
this->startGame();
return true;
}
return false;
}
示例15: init
bool GameAbout::init()
{
if (!CCLayer::init()) {
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite *bg = CCSprite::create("bg.png");
bg->setPosition(ccp(size.width/2, size.height/2));
bg->setScale(0.5f);
this->addChild(bg, 0, 0);
CCSprite *bgStar = CCSprite::create("moon.png");
bgStar->setAnchorPoint(ccp(0.5, 0));
bgStar->setPosition(ccp(size.width/3, 0));
bgStar->setScale(0.5f);
this->addChild(bgStar, 1, 1);
CCSprite *frame = CCSprite::create("tb.png");
frame->setPosition(ccp(size.width/2, size.height/2));
frame->setScale(0.5f);
this->addChild(frame, 2, 2);
char info[256];
sprintf(info, "name: meow war\n\nprogram: aiyiai\n\nart design: wa wa\n\ncompany: xi an men\n\n powered by cocos2d-x");
CCLabelTTF *label = CCLabelTTF::create(info, "Marker Felt", 40, CCSizeMake(400, 400), kCCTextAlignmentLeft);
label->setAnchorPoint(ccp(0, 1));
label->setPosition(ccp(50, 600));
label->setColor(ccc3(200, 200, 200));
frame->addChild(label);
CCSprite *aboutTitle = CCSprite::create("about.png");
aboutTitle->setPosition(ccp(size.width/2, size.height - 20));
aboutTitle->setScale(0.5f);
this->addChild(aboutTitle, 3, 3);
CCMenuItemImage *backItem = CCMenuItemImage::create("backA.png", "backB.png", this, menu_selector(GameAbout::menuBackCallback));
backItem->setPosition(ccp(size.width - 20, size.height - 20));
backItem->setScale(0.5f);
backItem->setEnabled(false);
CCMenu *mainMenu = CCMenu::create(backItem, NULL);
mainMenu->setPosition(CCPointZero);
this->addChild(mainMenu, 3, 4);
return true;
}