本文整理汇总了C++中CCMenu::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::setAnchorPoint方法的具体用法?C++ CCMenu::setAnchorPoint怎么用?C++ CCMenu::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::setAnchorPoint方法的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: onEnter
void NetworkUDP::onEnter()
{
NetworkDemo::onEnter();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// to test this sample, find udp_server.py in server folder, run it with python
// you need install greenlet and gevent
CCMenuItemLabel* item1 = CCMenuItemLabel::create(CCLabelTTF::create("Send Hello", "Helvetica", 40 / CC_CONTENT_SCALE_FACTOR()),
this,
menu_selector(NetworkUDP::onSendClicked));
item1->setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
CCMenu* menu = CCMenu::create(item1, NULL);
menu->setAnchorPoint(CCPointZero);
menu->setPosition(CCPointZero);
addChild(menu);
// received content
m_recv = CCLabelTTF::create("", "Helvetica", 20 / CC_CONTENT_SCALE_FACTOR());
m_recv->setPosition(ccp(origin.x + visibleSize.width / 2,
origin.y + visibleSize.height / 5));
addChild(m_recv);
// change ip to your server
// registerCallback must be invoked before createSocket otherwise bound event is lost
m_hub = CCUDPSocketHub::create();
m_hub->registerCallback(1, this);
m_hub->createSocket("192.168.1.104", 9000, 1);
CC_SAFE_RETAIN(m_hub);
}
示例3: createListView
void NewsScene::createListView()
{
// CCSize size = CCSize(750, 400);
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor * fundo = CCLayerColor::create(ccc4(255, 255, 255, 255), size.width, size.height);
fundo->setAnchorPoint(ccp(0,0));
fundo->setPosition(ccp(0, 0));
this->addChild(fundo,10);
// CCLayerColor * header = CCLayerColor::create(ccc4(200, 200, 200, 255), size.width, 80);
// header->setAnchorPoint(ccp(0,0));
// header->setPosition(ccp(0, size.height -80));
// fundo->addChild(header);
CCSprite *sprHeader;
sprHeader = CCSprite::create("Header_Blue.png");
sprHeader->setAnchorPoint(ccp(0,0));
sprHeader->setScale(1);
sprHeader->setPosition(ccp(0, size.height -90));
this->addChild(sprHeader,100);
CCSprite *sprTitle;
sprTitle = CCSprite::create("tit_informacoes.png");
sprTitle->setAnchorPoint(ccp(0,0));
sprTitle->setScale(1);
sprTitle->setPosition(ccp(110, size.height -50));
this->addChild(sprTitle,101);
CCMenu* menu = CCMenu::create();
CCSprite *spriteDefault = CCSprite::create("Seta1.png");
CCSprite *spriteSelected = CCSprite::create("Seta2.png");
CCMenuItemSprite *item = CCMenuItemSprite::create(spriteDefault, spriteSelected, this, menu_selector(NewsScene::btnBack));
item->setAnchorPoint(ccp(0, 0));
item->setPosition(ccp(0, size.height -90));
menu->addChild(item, 0, 100);
menu->setPosition(ccp(10,30));
menu->setAnchorPoint(ccp(0,0));
this->addChild(menu,102);
list = CCListView::create(CCListViewModeVertical);
list = cocos2d::extension::CCListView::create(CCListViewModeVertical);
list->setDelegate(this);
list->setContentSize(CCSize(size.width, size.height-70));
list->setAnchorPoint(ccp(0,0));
list->setPosition(ccp(0, 0));
list->setColor(ccc3(50, 50, 50));
list->setSeparatorStyle(CCListViewCellSeparatorStyleNone);
fundo->addChild(list);
this->loading = new AnimatedSprite("loader_einstein1.png");
this->loading->addAnimation(AnimatedSprite::animationWithFile("loader_einstein", 24, 0.030f), "anim");//frame_count
this->addChild(this->loading,999);
this->loading->runAnimation("anim",true, true);
this->loading->setAnchorPoint(ccp(0.5f, 0.5f));
this->loading->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height/2 - 30));
this->loading->setVisible(true);
}
示例4: init
bool HelpScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
setKeypadEnabled(true);
LayoutManager *layoutManager = LayoutManager::getInstance();
CCRect visibleRect = layoutManager->getVisibleRect();
CCDirector *director = CCDirector::sharedDirector();
m_Background = CCSprite::create("help.png");
m_Background->retain();
m_Background->setPosition(director->getVisibleOrigin() + director->getVisibleSize() / 2);
addChild(m_Background);
CCMenuItemImage *pBack = CCMenuItemImage::create("back.png", NULL, this, menu_selector(HelpScene::backCallback));
pBack->setAnchorPoint(CCPointZero);
pBack->setPosition(ccp(visibleRect.origin.x + 18, visibleRect.origin.y + 12));
CCMenu *pMenu = CCMenu::create(pBack, NULL);
pMenu->setAnchorPoint(CCPointZero);
pMenu->setPosition(CCPointZero);
addChild(pMenu);
return true;
}
示例5: showTimerBoarder
CCLayer* GameScene::showTimerBoarder()
{
CCLayer* board = CCLayer::create();
CCSprite* boardBG = CCSprite::create("header.png");
boardBG->setPosition(ccp(320,0));
boardBG->setAnchorPoint(ccp(0.5f,0));
board->addChild(boardBG);
CCMenuItemImage* imageItem = CCMenuItemImage::create("btn-pause.png","btn-pause-down.png", this,menu_selector(GameScene::restartScene));
imageItem->setAnchorPoint(ccp(0,1));
CCMenu* menu = CCMenu::create(imageItem,NULL);
menu->setAnchorPoint(ccp(0,1));
menu->setPosition(ccp(0,158));
pr = CCProgressTimer::create(CCSprite::create("timer.png"));
pr->setPosition(ccp(320,16));
pr->setAnchorPoint(ccp(0.5,0));
pr->setPercentage(1.0f);
pr->setType(kCCProgressTimerTypeBar);
pr->setMidpoint(ccp(1,0));
pr->setBarChangeRate(ccp(1,0));
this->schedule(schedule_selector(GameScene::countTime),1.0f);
scoreTxt = CCLabelBMFont::create("0","fonts/scorefont.fnt");
scoreTxt->setAnchorPoint(ccp(1,0.5f));
scoreTxt->setScale(1.0f);
scoreTxt->setAlignment(kCCTextAlignmentRight);
scoreTxt->setPosition(ccp(640,110));
board->addChild(scoreTxt,10);
board->addChild(pr);
board->addChild(menu);
return board;
}
示例6: loadUI
void BYGameScene::loadUI() {
CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
frameCache->addSpriteFramesWithFile("ui.plist", "ui.png");
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
/// pause button
CCSprite* btnNormalSprite = CCSprite::createWithSpriteFrameName("pause.png");
CCMenuItemSprite *pauseMenuItem = CCMenuItemSprite::create(btnNormalSprite,
btnNormalSprite,
this,
menu_selector(BYGameScene::pauseButtonHandler));
/// 2 labels for goals
ccColor3B color = ccc3(220, 70, 20); /// red color
_labelBotPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
_labelBotPlayerGoalsScored->setColor(color);
CCMenuItemLabel *labelBot = CCMenuItemLabel::create(_labelBotPlayerGoalsScored, NULL, NULL);
labelBot->setEnabled(false);
_labelTopPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
_labelTopPlayerGoalsScored->setColor(color);
CCMenuItemLabel *labelTop = CCMenuItemLabel::create(_labelTopPlayerGoalsScored, NULL, NULL);
labelTop->setEnabled(false);
/// CCMenu doesnt support anchorPoint as of 0x00020003 version
CCMenu *menu = CCMenu::create(labelTop, pauseMenuItem, labelBot, NULL);
menu->alignItemsHorizontallyWithPadding(5);
menu->setAnchorPoint(CCPointMake(0, 0));
menu->setPosition(CCPointMake(winSize.width - pauseMenuItem->getContentSize().width / 2,
winSize.height / 2));
menu->setRotation(90);
this->addChild(menu);
}
示例7: init
// on "init" you need to initialize your instance
bool GameScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
setTouchEnabled(true);
setKeypadEnabled(true);
m_GroundPosY = 187/* ground position in bg1.jpg(bg2.jpg) */ - m_VisibleOrigin.y;
m_pBackground1 = CCSprite::create("bg1.jpg");
m_pBackground1->retain();
m_pBackground1->setPosition(m_VisibleOrigin + m_VisibleSize / 2);
addChild(m_pBackground1);
m_pBackground2 = CCSprite::create("bg1.jpg");
m_pBackground2->retain();
m_pBackground2->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width * 1.5f, m_VisibleOrigin.y + m_VisibleSize.height * 0.5f));
addChild(m_pBackground2);
m_ScoreLabel = CCLabelAtlas::create(CCString::createWithFormat("%d", m_CurrentScore)->getCString(), "fonts/font1.png", 56, 72, '0');
m_ScoreLabel->retain();
m_ScoreLabel->setZOrder(1);
m_ScoreLabel->setAnchorPoint(ccp(0.5, 0.5));
m_ScoreLabel->setScale(0.85f);
m_ScoreLabel->setPosition(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height * 0.86125);
addChild(m_ScoreLabel);
m_Title = CCSprite::create("title_ready.png");
m_Title->retain();
m_Title->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.x + m_VisibleSize.height * 0.725f));
addChild(m_Title);
m_Hint = CCSprite::create("hint.png");
m_Hint->retain();
m_Hint->setScale(0.76f);
m_Hint->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height / 2));
addChild(m_Hint);
m_pPause = LGMenuItemImage::create("pause.png", NULL, this, menu_selector(GameScene::pauseCallback));
m_pPause->retain();
m_pPause->setVisible(false);
m_pPause->setScale(0.85f);
m_pPause->setPosition(m_VisibleOrigin.x + 43, m_VisibleOrigin.y + m_VisibleSize.height - 41);
CCMenu *pMenu = CCMenu::create(m_pPause, NULL);
pMenu->setZOrder(3);
pMenu->setAnchorPoint(CCPointZero);
pMenu->setPosition(CCPointZero);
addChild(pMenu);
addPig();
scheduleUpdate();
schedule(schedule_selector(GameScene::updatePillar), 0.1f, kCCRepeatForever, 0);
return true;
}
示例8: 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());
}
示例9: showMainMenu
void RPGStartSceneLayer::showMainMenu()
{
CCMenu *mainMenu = CCMenu::create();
mainMenu->setAnchorPoint(CCPointZero);
mainMenu->setPosition(CCPointZero);
mainMenu->setTag(kRPGStartSceneLayerTagMainMenu);
this->addChild(mainMenu);
CCString *menuStartStr = (CCString*)this->m_stringList->objectForKey("mainmenu_start");
CCLabelTTF *menuStartLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuStartStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCString *menuRestartStr = (CCString*)this->m_stringList->objectForKey("mainmenu_restart");
CCLabelTTF *menuRestartLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuRestartStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCString *menuSettingsStr = (CCString*)this->m_stringList->objectForKey("mainmenu_settings");
CCLabelTTF *menuSettingsLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuSettingsStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuStart = CCMenuItemLabel::create(menuStartLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuStart->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 230));
menuStart->setTag(kRPGStartSceneLayerTagMainMenuItemStart);
mainMenu->addChild(menuStart);
CCMenuItemLabel *menuRestart = CCMenuItemLabel::create(menuRestartLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuRestart->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 170));
menuRestart->setTag(kRPGStartSceneLayerTagMainMenuItemRestart);
mainMenu->addChild(menuRestart);
CCMenuItemLabel *menuSettings = CCMenuItemLabel::create(menuSettingsLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuSettings->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 110));
menuSettings->setTag(kRPGStartSceneLayerTagMainMenuItemSettings);
mainMenu->addChild(menuSettings);
}
示例10: init
bool StatusMenu::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLayerColor* layer = CCLayerColor::create( ccc4(135, 135 , 135, 255));
layer->ignoreAnchorPointForPosition(false);
layer->setPosition( CCPointMake(s.width/2, s.height/2) );
addChild(layer, 0);
CCMenuItemImage *closebutton = CCMenuItemImage::create("close.png", "close_down.png", this, menu_selector(StatusMenu::CloseCallback));
CCMenuItemImage *itembutton = CCMenuItemImage::create("package.png", "package_down.png", this, menu_selector(StatusMenu::ItemMenuCallback));
CCMenuItemImage *charabutton = CCMenuItemImage::create("chara.png", "chara_down.png", this, menu_selector(StatusMenu::CharacterMenuCallback));
closebutton->setPosition(ccp(-250, 50));
itembutton->setPosition(ccp(-250, 105));
charabutton->setPosition(ccp(-250, 160));
CCMenu *menu = CCMenu::create(charabutton,itembutton,closebutton,NULL);
addChild(menu,1);
CCSprite *charabox = CCSprite::create("menu_bg_all.png");
charabox->setPosition(ccp(450, s.height/2));
addChild(charabox,1,12);
CCSprite *itembox = CCSprite::create("item_bg_all.png");
itembox->setPosition(ccp(450, s.height/2));
addChild(itembox,1,13);
CCMenu *itemmenu = CCMenu::create();
for (int i=0; i<player->items.size(); i++) {
switch (player->items[i]) {
case 4:{
CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("手电筒 X1", "AR PLMingU20 Light", 24));
itemmenu->addChild(item, i+1, i+1);
break;
}
case 6:{
CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("水果刀 X1", "AR PLMingU20 Light", 24));
itemmenu->addChild(item, i+1, i+1);
break;
}
case 12:{
CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("钥匙 X1", "AR PLMingU20 Light", 24));
itemmenu->addChild(item, i+1, i+1);
break;
}
default:
break;
}
}
itemmenu->setAnchorPoint(ccp(0, 1));
itemmenu->alignItemsVertically();
itemmenu->setPosition(itembox->getPositionX()-300,itembox->getPositionY()+130);
itembox->addChild(itemmenu);
CharacterMenuCallback(NULL);
return true;
}
示例11: configureGame
void GameLayer::configureGame(GameLevel gameLevel)
{
_gameLevel = gameLevel;
_accelVelocity = CCPointZero;
CCPoint visOrigin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSize visSize = CCDirector::sharedDirector()->getVisibleSize();
_menuPause = CCMenuItemImage::create("pause_off.png", "pause.png", this, menu_selector(GameLayer::pauseGame));
_menuPause->setVisible(false);
_menuPause->setPositionX(visOrigin.x + _menuPause->getContentSize().width * 0.9f);
_menuPause->setPositionY(visOrigin.y + visSize.height - _menuPause->getContentSize().width * 0.6f);
CCMenu* menu = CCMenu::create();
menu->setAnchorPoint(ccp(0, 0));
menu->setPosition(CCPointZero);
menu->addChild(_menuPause);
addChild(menu, kDeepPauseLayer);
setTouchEnabled(true);
_worldSpeed = START_WORLD_SPEED;
_minDistanceObstaclesX = MIN_DISTANCE_OBSTACLES;
if(_gameLevel == kGameLevelEasy)
{
_minDistanceObstaclesX *= 2.0f; // 1.0
_worldSpeed *= 1.0f; // 0.9
_vectorMap.insert(_vectorMap.begin(), easyMap, easyMap + sizeof(easyMap) / sizeof(int));
}
else if(_gameLevel == kGameLevelNormal)
{
_minDistanceObstaclesX *= 1.3f; // 0.9
_worldSpeed *= 1.7f; // 1.8
_vectorMap.insert(_vectorMap.begin(), normalMap, normalMap + sizeof(normalMap) / sizeof(int));
}
else if(_gameLevel == kGameLevelHard)
{
_minDistanceObstaclesX *= 1.0f; // 0.7
_worldSpeed *= 2.2f; // 2.4
_vectorMap.insert(_vectorMap.begin(), hardMap, hardMap + sizeof(hardMap) / sizeof(int));
}
_itemMap = 0;
_gameState = kGameStarting;
_pause = false;
_gameOver = false;
_createPlayer();
_initElements();
}
示例12: init
bool HomeScene::init()
{
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite* bgSpr = CCSprite::create("home_bg.png");
bgSpr->setAnchorPoint(ccp(0, 0));
bgSpr->setPosition( ccp(0, size.height-960) );
this->addChild(bgSpr, -1, 0);
HomeLayer* layer = new HomeLayer();
layer->initWithDelegate(this);
this->addChild(layer);
//下导航区域
CCMenuItemImage *bu01 = CCMenuItemImage::create("zhuye.png", "zhuye.png", this, menu_selector(HomeScene::menuItemCallBack));
bu01->setTag(1);
bu01->setPosition(ccp(60, 0));
CCMenuItemImage *bu02 = CCMenuItemImage::create("chengshi.png", "chengshi.png", this, menu_selector(HomeScene::menuItemCallBack));
bu02->setTag(2);
bu02->setPosition(ccp(165, 0));
CCMenuItemImage *bu03 = CCMenuItemImage::create("fuben.png", "fuben.png", this, menu_selector(HomeScene::menuItemCallBack));
bu03->setTag(3);
bu03->setPosition(ccp(270, 0));
CCMenuItemImage *bu04 = CCMenuItemImage::create("huodong.png", "huodong.png", this, menu_selector(HomeScene::menuItemCallBack));
bu04->setTag(4);
bu04->setPosition(ccp(375, 0));
CCMenuItemImage *bu05 = CCMenuItemImage::create("beibao.png", "beibao.png", this, menu_selector(HomeScene::menuItemCallBack));
bu05->setTag(5);
bu05->setPosition(ccp(480, 0));
CCMenuItemImage *bu06 = CCMenuItemImage::create("shangcheng.png", "shangcheng.png", this, menu_selector(HomeScene::menuItemCallBack));
bu06->setTag(6);
bu06->setPosition(ccp(585, 0));
CCMenu* menu = CCMenu::create(bu01, bu02, bu03, bu04, bu05, bu06, NULL);
menu->setPosition(ccp(0, 60));
menu->setAnchorPoint(ccp(0, 0.5));
this->addChild(menu);
//系统公告
CCLabelTTF* sysLabel = CCLabelTTF::create("系统公告板:展示系统消息", "", 24.0f);
sysLabel->setAnchorPoint( ccp(0, 0.5f) );
sysLabel->setPosition( ccp(size.width, size.height-25) );
this->addChild(sysLabel, 0, 100);
//
CCMoveBy* pMove = CCMoveBy::create(10.0f, ccp(-size.width-sysLabel->getContentSize().width, 0));
CCAction* pStop = CCCallFuncND::create(this, callfuncND_selector(HomeScene::actionDidFinished), NULL);
sysLabel->runAction(CCSequence::create(pMove, pStop, NULL));
sysLabel->runAction(pMove);
return true;
}
示例13: 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;
}
示例14: fillBanner
void ADAds::fillBanner(Banner* banner)
{
#if defined(_DEBUG) && CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
CCRenderTexture* texture = CCRenderTexture::create(100, 100);
texture->beginWithClear(0.5f, 0.5f, 0.5f, 1);
texture->end();
CCSprite* s = CCSprite::createWithTexture(texture->getSprite()->getTexture());
s->setScaleX(banner->getContentSize().width/s->getContentSize().width);
s->setScaleY(banner->getContentSize().height/s->getContentSize().width);
banner->addChild(s);
s->setAnchorPoint(ccp(0,0));
s->setPosition(ccp(0,0));
#endif
if(_home_banners.size())
{
//std::random_shuffle(_home_banners.begin(), _home_banners.end());
CustomBanner* home_ads = getCustomBanner();
CCMenuItem* item = CCMenuItem::create(
home_ads, menu_selector(CustomBanner::onClick));
CCMenu* menu = CCMenu::create();
menu->addChild(item);
banner->addChild(menu, 0, HOME_ADS_NODE_TAG);
menu->setAnchorPoint(ccp(0,0));
menu->setPosition(ccp(0,0));
CCNode* banner_content = home_ads->getBanner();
CCSize content_size = banner_content->getContentSize();
CCSize zone_size = banner->getContentSize();
float scale = MIN(zone_size.width/content_size.width,
zone_size.height/content_size.height);
banner_content->setScale(scale);
banner_content->setAnchorPoint(ccp(0, 0));
banner_content->setPosition(ccp(0,0));
item->setContentSize(content_size*scale);
item->setAnchorPoint(ccp(0.5f,0.5f));
item->setPosition(zone_size*0.5f);
item->addChild(banner_content);
}
}
示例15: init
bool CStartAndHelpButtonLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
// get Windows Size
//// start Button
if ( CGameManager::GetInstance()->IsOnlineMode() && !CGameManager::GetInstance()->IsChannelMaster() )
{
m_StartButton = CCMenuItemImage::create(
GAME_SETTING_READY_BTN_UNSELECT.c_str(),
GAME_SETTING_READY_BTN_SELECT.c_str(),
this,
menu_selector(CStartAndHelpButtonLayer::ReadyButtonCallBack)
);
m_StartButton->setTag(READY_BUTTON_TAG);
}
else
{
m_StartButton = CCMenuItemImage::create(
GAME_SETTING_READY_BTN_UNSELECT.c_str(),
GAME_SETTING_READY_BTN_SELECT.c_str(),
this,
menu_selector(CStartAndHelpButtonLayer::StartButtonCallBack)
);
m_StartButton->setTag(START_BUTTON_TAG);
}
// at init, Start button is disabled
m_StartButton->setEnabled(false);
m_StartButton->selected();
// create StartButtonMenu
CCMenu *StartButtonMenu = CCMenu::create(m_StartButton, NULL);
StartButtonMenu->setPosition(CCPoint(GAME_SETTING_READY_BTN_POS));
StartButtonMenu->setAnchorPoint(ccp(0, 0));
// add StartButtonMenu to Layer
this->addChild(StartButtonMenu);
// button Position & readyAnchorPoint (0, 0)
m_StartButton->setPosition(ccp(0, 0));
m_StartButton->setAnchorPoint(ccp(0, 0));
return true;
}