本文整理汇总了C++中CCMenuItemImage::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::setPosition方法的具体用法?C++ CCMenuItemImage::setPosition怎么用?C++ CCMenuItemImage::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width-45 - 20, 20) );
// 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", "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);
// test code
// 배경화면
CCSprite* pSpriteBack = CCSprite::create("test.png");
// position the sprite on the center of the screen
pSpriteBack->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
this->addChild(pSpriteBack, 0);
// 시작화면
// CCSprite* pSpriteStart = CCSprite::create("q_start.jpg");
// position the sprite on the center of the screen
// pSpriteStart->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
// this->addChild(pSpriteStart, 0);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("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;
}
示例2: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayer::init());
//////////////////////////////////////////////////////////////////////////
// add your codes below...
//////////////////////////////////////////////////////////////////////////
// 1. Add a menu item with "X" image, which is clicked to quit the program.
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
CC_BREAK_IF(! pCloseItem);
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCLog("Origin: (%.3f, %.3f)\n", origin.x, origin.y);
// Place the menu item bottom-right conner.
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2,
origin.y + pCloseItem->getContentSize().height/2));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu);
// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu, ZORDER_UI);
// 2. background
m_pSpaceDust = CCSprite::create("bg_front_spacedust.png");
m_pSpaceDust->setPosition(ccp(origin.x + visibleSize.width/2, origin.y + visibleSize.height));
m_pPlanetSunrise = CCSprite::create("bg_planetsunrise.png");
m_pPlanetSunrise->setPosition(ccp(origin.x + visibleSize.width, origin.y + visibleSize.height*0.9f));
m_pGalaxy = CCSprite::create("bg_galaxy.png");
m_pGalaxy->setPosition(ccp(origin.x + visibleSize.width*0.0f, origin.y + visibleSize.height*0.5f));
//m_pSpacialAnomaly = CCSprite::create("bg_spacialanomaly.png");
//m_pSpacialAnomaly->setPosition(ccp(origin.x + visibleSize.width*0.3f, origin.y + visibleSize.height*0.7f));
m_pSpacialAnomaly2 = CCSprite::create("bg_spacialanomaly2.png");
m_pSpacialAnomaly2->setPosition(ccp(origin.x + visibleSize.width, origin.y + visibleSize.height*0.1f));
this->addChild(m_pSpaceDust, ZORDER_BACKGROUND);
this->addChild(m_pPlanetSunrise, ZORDER_BACKGROUND);
this->addChild(m_pGalaxy, ZORDER_BACKGROUND);
//this->addChild(m_pSpacialAnomaly, ZORDER_BACKGROUND);
this->addChild(m_pSpacialAnomaly2, ZORDER_BACKGROUND);
// 3. player
m_pPlayer = CCSprite::create("spaceman_tiny.png");
m_x = origin.x + visibleSize.width/2;
m_y = origin.y + GROUND_HEIGHT;
m_pPlayer->setPosition(ccp(m_x, m_y));
this->addChild(m_pPlayer, ZORDER_PLAYER);
// 4. planets
m_pBatchNode = CCSpriteBatchNode::create("planets.pvr.ccz");
this->addChild(m_pBatchNode, ZORDER_INTERACTIVE);
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("planets.plist");
// 5. events
this->scheduleUpdate();
this->setTouchEnabled(true);
this->schedule(schedule_selector(HelloWorld::gameLogic), 2.0f);
// 6. other
m_pPlanets = new CCArray;
CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("SpaceGame.wav", true);
bRet = true;
} while (0);
return bRet;
}
示例3: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayer::init());
//////////////////////////////////////////////////////////////////////////
// add your codes below...
//////////////////////////////////////////////////////////////////////////
// 1. Add a menu item with "X" image, which is clicked to quit the program.
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
CC_BREAK_IF(! pCloseItem);
// Place the menu item bottom-right conner.
pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu);
// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu, 1);
// 2. Add a label shows "Hello World".
// Create a label and initialize with string "Hello World".
CCLabelTTF* pLabel = CCLabelTTF::create("Hello 11111", "Arial", 24);
CC_BREAK_IF(! pLabel);
// Get window size and place the label upper.
CCSize size = CCDirector::sharedDirector()->getWinSize();
pLabel->setPosition(ccp(size.width / 2, size.height - 50));
// Add the label to HelloWorld layer as a child layer.
this->addChild(pLabel, 1);
// 3. Add add a splash screen, show the cocos2d splash image.
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
CC_BREAK_IF(! pSprite);
// Place the sprite on the center of the screen
pSprite->setPosition(ccp(size.width/2, size.height/2));
// Add the sprite to HelloWorld layer as a child layer.
this->addChild(pSprite, 0);
bRet = true;
} while (0);
return bRet;
}
示例4: init
bool ResultLayer::init() {
if ( CCLayerColor::initWithColor( ccc4(255, 255, 255, 255) ) ) {
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// make the labels of the score and the high score and add them on the layer.
int score = Score::getScore();
int highScore = Score::getHighScore();
// CCLog("score = %d", score);
// CCLog("high score= %d", highScore);
CCString* scoreValue = CCString::createWithFormat("Score: %d", score);
CCString* highScoreValue = CCString::createWithFormat("High Score: %d", highScore);
// set font.
CCLabelTTF* pScoreLabel = CCLabelTTF::create(scoreValue->getCString(), "arial", 48.0);
// set the font color
pScoreLabel->setColor(ccc3(255, 0, 127));
int widthScoreLabel =pScoreLabel->getContentSize().width;
// set font.
CCLabelTTF* pHighScoreLabel = CCLabelTTF::create(highScoreValue->getCString(), "arial", 48.0);
// set the font color.
pHighScoreLabel->setColor(ccc3(255, 0, 127));
// get the width and the height of the high score label.
int widthHighScoreLabel =pHighScoreLabel->getContentSize().width;
int heightHighScoreLabel = pHighScoreLabel->getContentSize().height;
// set the positions of the labels.
pScoreLabel->setPosition(ccp(origin.x + visibleSize.width / 2 - widthScoreLabel / 2,
origin.y + (int)(visibleSize.height * (1.0 - 0.4))));
pHighScoreLabel->setPosition(ccp(origin.x + visibleSize.width / 2 - widthScoreLabel/ 2
+ abs(widthHighScoreLabel - widthScoreLabel) / 2,
origin.y + (int)(visibleSize.height * (1.0 - 0.4))
- heightHighScoreLabel - 20));
// add the labels to the layer.
this->addChild(pScoreLabel, 1);
this->addChild(pHighScoreLabel, 1);
// 1. Add a menu item with "X" image, which is clicked to quit the program.
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"BackNormal.png",
"BackSelected.png",
this,
menu_selector(ResultLayer::menuBackCallback));
// Place the menu item bottom-right conner.
// CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
// CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2,
origin.y + pCloseItem->getContentSize().height/2));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
// Add the menu to SecondWorld layer as a child layer.
this->addChild(pMenu, 1);
return true;
} else {
return false;
}
}
示例5: init
bool CGroupInfoScene::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// 背景
cocos2d::CCSprite *pSpriteBg = CCSprite::create( PATCH_RES_DIR("bg8.png") );
pSpriteBg->setScale(BG_SCALE);
pSpriteBg->setAnchorPoint( ccp(0, 0) );
pSpriteBg->setPosition( ccp(0, 0) );
addChild( pSpriteBg, 0 );
// 关闭按钮
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
PATCH_RES_DIR("close2.png"),
PATCH_RES_DIR("close1.png"),
this,
menu_selector(CGroupInfoScene::menuCloseCallback) );
CC_BREAK_IF( !pCloseItem );
pCloseItem->setAnchorPoint( ccp(0, 0) );
float w = visibleSize.width - pCloseItem->getContentSize().width - 5;
float h = 5;
pCloseItem->setPosition( ccp(w, h) );
CCMenu *pMenu = CCMenu::create( pCloseItem, NULL );
pMenu->setPosition( CCPointZero );
CC_BREAK_IF( !pMenu );
addChild( pMenu, 1 );
// 后退
{
CCMenuItemImage *pBackItem = CCMenuItemImage::create(
PATCH_RES_DIR("back.png"),
PATCH_RES_DIR("back.png"),
this,
menu_selector(CGroupInfoScene::menuBackCallback) );
CC_BREAK_IF( !pBackItem );
pBackItem->setAnchorPoint( ccp(0, 0) );
float w = visibleSize.width - pBackItem->getContentSize().width - 5 - pCloseItem->getContentSize().width;
float h = 5;
pBackItem->setPosition( ccp(w, h) );
CCMenu *pMenu = CCMenu::create( pBackItem, NULL );
pMenu->setPosition( CCPointZero );
CC_BREAK_IF( !pMenu );
addChild( pMenu, 1 );
}
bRet = true;
// 群名字
CGroupInfo *group = CGameManager::Instance().GetCurGroup();
cocos2d::CCSprite *pGroupSprite = CCSprite::create( PATCH_RES_DIR("group.png") );
pGroupSprite->setScale(BG_SCALE);
pGroupSprite->setAnchorPoint( ccp(0, 0) );
pGroupSprite->setPosition( ccp(10, visibleSize.height-pGroupSprite->getContentSize().height-5 ) );
addChild( pGroupSprite, 0 );
CCLabelTTF *labelGroup = CCLabelTTF::create(group->m_Name.c_str(), "Helvetica", 20.0);
labelGroup->setAnchorPoint(CCPointZero);
labelGroup->setPosition( ccp(pGroupSprite->getContentSize().width+20, visibleSize.height-pGroupSprite->getContentSize().height-5 ) );
addChild( labelGroup, 0 );
// 自己
cocos2d::CCSprite *pSelf = CCSprite::create( PATCH_RES_DIR("group_self.png") );
pSelf->setScale(BG_SCALE);
pSelf->setAnchorPoint( ccp(0, 0) );
pSelf->setPosition( ccp(visibleSize.width/2, visibleSize.height-pGroupSprite->getContentSize().height-5 ) );
addChild( pSelf, 0 );
CCLabelTTF *labelSelf = CCLabelTTF::create(CGameManager::Instance().GetUser().c_str(), "Helvetica", 20.0);
labelSelf->setAnchorPoint(CCPointZero);
labelSelf->setPosition( ccp(visibleSize.width/2+pSelf->getContentSize().width+20, visibleSize.height-pGroupSprite->getContentSize().height-5 ) );
addChild( labelSelf, 0 );
// 加载成员列表
_InitMemberList();
_InitAddGame();
CNetManager::Instance().ResumeProcMsg();
CGameManager::Instance().SetGameWorld( this );
} while (0);
return bRet;
}
示例6: _initComponent
void LoginLayer::_initComponent() {
CCSize size = CCDirector::sharedDirector()->getVisibleSize();
/* 大游戏之名字 */
CCSprite* nameOfGame = CCSprite::create("GAME_NAME.png");
nameOfGame->setPosition(ccp(size.width / 2, size.height - 120));
addChild(nameOfGame, 10);
/* 可移动背景 */
srand( (unsigned)time( NULL ) );
int x = rand() % 2;
int y = rand() % 1500;
CCSprite* pLoginBg = CCSprite::create("bg_big.png");
pLoginBg->setAnchorPoint(CCPointZero);
pLoginBg->setPosition(ccp(-y/*(LOGIN_BG_WIDTH - size.width) / 2*/, 0));
this->addChild(pLoginBg);
if (x == 0) {
CCActionInterval * move = CCMoveTo::create(LOGIN_BG_TIME, ccp(size.width - LOGIN_BG_WIDTH, 0));
CCActionInterval * move1 = CCMoveTo::create(LOGIN_BG_TIME, ccp(0, 0));
CCFiniteTimeAction * seq= CCSequence::create(move, move1, NULL);
CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
pLoginBg->runAction(repeatForever);
} else if (x == 1) {
CCActionInterval * move = CCMoveTo::create(LOGIN_BG_TIME, ccp(0, 0));
CCActionInterval * move1 = CCMoveTo::create(LOGIN_BG_TIME, ccp(size.width - LOGIN_BG_WIDTH, 0));
CCFiniteTimeAction * seq= CCSequence::create(move, move1, NULL);
CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
pLoginBg->runAction(repeatForever);
}
/* 效果火焰 */
CCParticleSystemQuad* particle = CCParticleSystemQuad::create("dzt3.plist");
particle->setAnchorPoint(CCPointZero);
particle->setPosition(ccp(320, 0));
particle->setScaleX(0.9);
particle->setAutoRemoveOnFinish(true);
addChild(particle, 11);
/* 火星 */
CCParticleSystemQuad* particlefire = CCParticleSystemQuad::create("firefly.plist");
particlefire->setAnchorPoint(CCPointZero);
particlefire->setPosition(ccp(0, 800));
particlefire->setAutoRemoveOnFinish(true);
addChild(particlefire, 11);
/* 火星1 */
CCParticleSystemQuad* particlefire1 = CCParticleSystemQuad::create("firefly2.plist");
particlefire1->setAnchorPoint(CCPointZero);
particlefire1->setPosition(ccp(0, 800));
particlefire1->setAutoRemoveOnFinish(true);
addChild(particlefire1, 11);
/* 开始游戏按钮 */
CCMenuItemImage *pLoginBtn = CCMenuItemImage::create( "pre.png",
"def.png",
this,
menu_selector(LoginLayer::gameInit));
pLoginBtn->setAnchorPoint(ccp(0.5, 0));
pLoginBtn->setPosition(ccp(size.width / 2, 70));
CCMenu* pLoginMenu = CCMenu::create(pLoginBtn, NULL);
pLoginMenu->setAnchorPoint(CCPointZero);
pLoginMenu->setPosition(CCPointZero);
this->addChild(pLoginMenu);
CCSprite* startFont = CCSprite::create("start.png");
startFont->setAnchorPoint(ccp(0.5, 0));
startFont->setPosition(ccp(size.width / 2, 115));
this->addChild(startFont);
CCActionInterval * scale = CCScaleTo::create(1, 1.2);
CCActionInterval * scale1 = CCScaleTo::create(1.5, 1);
CCFiniteTimeAction * seq= CCSequence::create(scale,scale1,NULL);
CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
startFont->runAction(repeatForever);
/* 服务器列表滚动视图 */
/*
m_scrollView = CCScrollView::create(VIEW_SIZE);
m_scrollView->setViewSize(VIEW_SIZE);
m_scrollView->setContentSize(CCSizeMake(62*5, VIEW_SIZE.height));
m_scrollView->setAnchorPoint(ccp(0, 0));
m_scrollView->setPosition(SCROLLVIEW_OFFSETX, OFFSET_1136 + SCROLLVIEW_OFFSETY);
m_scrollView->setDirection(kCCScrollViewDirectionHorizontal);
m_scrollView->setBounceable(true);
m_scrollView->setDelegate(this);
this->addChild(m_scrollView);
*/
for (int i = 0; i < 5; ++i) {
CCMenuItemImage *pSvrBtn = CCMenuItemImage::create( "LG_nor.png",
"LG_nor.png",
this,
menu_selector(LoginLayer::option));
pSvrBtn->setTag(SVRBG_NORMAL + i);
pSvrBtn->setAnchorPoint(ccp(0, 0));
pSvrBtn->setPosition(ccp(SCROLLVIEW_OFFSETX + 60 * i, m_pGameState->getBottomOffset() + SCROLLVIEW_OFFSETY));
CCMenu* pMenu = CCMenu::create(pSvrBtn, NULL);
pMenu->setAnchorPoint(ccp(0, 0));
pMenu->setPosition(ccp(0, 0));
this->addChild(pMenu);
//.........这里部分代码省略.........
示例7: init
bool Combat::init(int monsterType)
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// Switch BGM
AudioPlayer::PlayCombatBGM();
//角色创建
cplayer = CPlayer::create();
cplayer->setPlayer();
this->addChild(cplayer);
monster = Monster::create();
monster->setMonster(monsterType);
this->addChild(monster);
//血条创建
playerblood = Blood::create();
playerblood->setBloodSlider();
playerblood->setSliderPosition(ccp(150,visibleSize.height-50));
playerblood->setTotalBlood(cplayer->healthPoint);
playerblood->setCurrentBlood(cplayer->currentHp);
monsterblood = Blood::create();
monsterblood->setBloodSlider();
monsterblood->setSliderPosition(ccp(visibleSize.width-150,visibleSize.height-50));
monsterblood->setTotalBlood(monster->healthPoint);
monsterblood->setCurrentBlood(monster->currentHp);
this->addChild(playerblood);
this->addChild(monsterblood);
//等级与当前血量label
/*等级*/
char level[10],blood[10];
sprintf(level,LEVEL_LBL,cplayer->level);
plevelLabel = CCLabelTTF::create(level, LABEL_FONT,20);
plevelLabel->setPosition(ccp(60,visibleSize.height-20));
this->addChild(plevelLabel,2);
sprintf(level,LEVEL_LBL,monster->level);
mlevelLabel = CCLabelTTF::create(level, LEVEL_LBL,20);
mlevelLabel->setPosition(ccp(visibleSize.width-60,visibleSize.height-20));
this->addChild(mlevelLabel,2);
/*血量*/
sprintf(blood,HEALTH_LBL,cplayer->currentHp);
pbloodLabel = CCLabelTTF::create(blood,LABEL_FONT,20);
pbloodLabel->setPosition(ccp(240,visibleSize.height-20));
this->addChild(pbloodLabel,2);
sprintf(blood,HEALTH_LBL,monster->currentHp);
mbloodLabel = CCLabelTTF::create(blood,LABEL_FONT,20);
mbloodLabel->setPosition(ccp(visibleSize.width-240,visibleSize.height-20));
this->addChild(mbloodLabel,2);
//按钮创建
playerbutton = AbilityButton::create();
monsterbutton = AbilityButton::create();
playerbutton->CreateButton();
playerbutton->setButtonPosition(ccp(50,50));
playerbutton->updateDamage(cplayer->level);
monsterbutton->CreateButton();
monsterbutton->setButtonPosition(ccp(480,50));
monsterbutton->LockButtonTouch();
monsterbutton->updateDamage(monster->level);
if (monsterType==0)
{
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(RUN_BTN_IMG_PATH,RUN_DOWN_BTN_IMG_PATH,this,menu_selector(Combat::exitCombat));
pCloseItem->setPosition(ccp(visibleSize.width/2,50));
CCMenu* pMenu = CCMenu::create(pCloseItem,NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu);
}
this->addChild(playerbutton);
this->addChild(monsterbutton);
//游戏结束Label
winLabel = CCLabelTTF::create(YOU_WIN_LBL, LABEL_FONT, 80);
loseLabel = CCLabelTTF::create(YOU_LOSE_LBL, LABEL_FONT, 80);
winLabel->setPosition(ccp(visibleSize.width/2-20,visibleSize.height/2+20));
loseLabel->setPosition(ccp(visibleSize.width/2-20,visibleSize.height/2+20));
winLabel->setVisible(false);
loseLabel->setVisible(false);
this->addChild(winLabel);
this->addChild(loseLabel);
//schedule监听,每帧刷新一次
this->scheduleUpdate();
//订阅播放动画的消息
CCNotificationCenter::sharedNotificationCenter()->addObserver(this,callfuncO_selector(Combat::playAnimation),ANIMATION_MSG,NULL);
//订阅游戏结束
CCNotificationCenter::sharedNotificationCenter()->addObserver(this,callfuncO_selector(Combat::gameOver),GAME_OVER_MSG,NULL);
return true;
}
示例8: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite* pBackground = CCSprite::create("background.png");
pBackground->setPosition(ccp(size.width / 2, size.height / 2));
addChild(pBackground);
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
CCPoint posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
CCPoint posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
// 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(posBR.x - 20, posBR.y + 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
CCPoint posStep = ccp(220, -150);
CCPoint beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f));
int line = 0;
int row = 0;
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
CCMenuItemImage* pMenuItem = CCMenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
this, menu_selector(HelloWorld::eventMenuCallback));
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
CCPoint pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
CCSize itemSize = pMenuItem->getContentSize();
if ((pos.x + itemSize.width / 2) > posBR.x)
{
line += 1;
row = 0;
pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
}
row += 1;
pMenuItem->setPosition(pos);
}
CCLabelTTF* label = CCLabelTTF::create("reload all plugins", "Arial", 24);
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
pMenuItem->setAnchorPoint(ccp(0.5f, 0));
pMenu->addChild(pMenuItem, 0);
pMenuItem->setPosition( ccp(size.width / 2, 0));
return true;
}
示例9: initWithParam
bool ResultScene::initWithParam(int level, int minScore, int resultScore)
{
// 初期化色を変更
if (!CCLayerColor::initWithColor(ccc4(0xF8,0xEC,0xDE,0xFF))) //RGBA
{
return false;
}
//初期化に関するものを書く
m_level = level;
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//RESULTの文字
CCLabelTTF* resultLabel;
resultLabel = CCLabelTTF::create("RESULT", "Arial", 100.0);
resultLabel->setColor(ccc3(0, 0, 0));
resultLabel->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.9));
this->addChild(resultLabel);
//今回のスコア
CCString* resultScoreStr = CCString::createWithFormat("TOUCH : %d",resultScore);
CCLabelTTF* resultScoreLabel;
resultScoreLabel = CCLabelTTF::create(resultScoreStr->getCString(), "Arial", 60.0);
resultScoreLabel->setColor(ccc3(0, 0, 0));
resultScoreLabel->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.6));
this->addChild(resultScoreLabel);
//今回のLv
CCString* levelStr = CCString::createWithFormat("Lv : %d",level);
CCLabelTTF* levelLabel;
levelLabel = CCLabelTTF::create(levelStr->getCString(), "Arial", 60.0);
levelLabel->setColor(ccc3(0, 0, 0));
levelLabel->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.7));
this->addChild(levelLabel);
int rank;
if(minScore >= resultScore){
rank = 3;
//Game Center
Cocos2dExt::NativeCodeLauncher::postAchievement(level, 100);
}else if( minScore <= resultScore + 8){
rank = 2;
}else{
rank = 1;
}
for (int i=0; i < rank; i++) {
CCSprite* pStar = CCSprite::create("star.png");
pStar->setScale(0.2);
float posX;
if(i == 0){
posX = 0.3;
}else if(i == 1){
posX = 0.5;
}else{
posX = 0.7;
}
pStar->setPosition(ccp(winSize.width * posX, winSize.height * 0.8));
this->addChild(pStar);
}
//リトライボタン
CCMenuItemImage* pRetryItem;
pRetryItem = CCMenuItemImage::create("reload.png", "reload.png",this,menu_selector(ResultScene::replayGame));
pRetryItem->setScale(0.3);
pRetryItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.3));
//次のレベルへ
CCMenuItemImage* pNextLevelItem;
if (m_level == max_level){
pNextLevelItem = CCMenuItemImage::create("next.png", "next.png",this,menu_selector(ResultScene::showTitleMenu));
}else{
pNextLevelItem = CCMenuItemImage::create("next.png", "next.png",this,menu_selector(ResultScene::nextLevelGame));
}
pNextLevelItem->setScale(0.3);
pNextLevelItem->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.3));
CCMenu* pMenu = CCMenu::create(pRetryItem,pNextLevelItem,NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu);
return true;
}
示例10: init
bool GameWorld::init()
{
do
{
CC_BREAK_IF(! CCLayer::init());
CCMenuItemImage *pTransform = CCMenuItemImage::create(
"6.png",
"6.png",
this,
menu_selector(GameWorld::menuTransformCallback));
CCMenuItemImage *pLeft = CCMenuItemImage::create(
"6.png",
"6.png",
this,
menu_selector(GameWorld::menuLeftCallback));
CCMenuItemImage *pRight = CCMenuItemImage::create(
"6.png",
"6.png",
this,
menu_selector(GameWorld::menuRightCallback));
CCMenuItemImage *pDown = CCMenuItemImage::create(
"6.png",
"6.png",
this,
menu_selector(GameWorld::menuDownCallback));
CCMenuItemImage *pGameOver = CCMenuItemImage::create(
"GameOver.jpg",
"GameOver.jpg",
this,
menu_selector(GameWorld::menuGameOver));
// Place the menu item bottom-right conner.
CCSize size = CCDirector::sharedDirector()->getWinSize();
pTransform->setPosition(ccp(size.width - 190, 210));
pLeft->setPosition(ccp(size.width - 260, 140));
pRight->setPosition(ccp(size.width - 120, 140));
pDown->setPosition(ccp(size.width - 190, 70));
pGameOver->setPosition(ccp(size.width / 2, size.height / 2));
pGameOver->setScale(5);
pGameOver->setVisible(false);
mMenuGameOver = pGameOver;
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::create(pTransform, pLeft, pRight, pDown, pGameOver, NULL);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu);
addChild(pMenu, 1);
CCDrawNode *pDrawNode = CCDrawNode::create();
addChild(pDrawNode);
CCPoint points[] = {
CCPoint(0,0),
CCPoint((CubeManager::MAIN_BOARD_WIDTH)* CubeManager::CUBE_SIZE, 0),
CCPoint((CubeManager::MAIN_BOARD_WIDTH)* CubeManager::CUBE_SIZE, (CubeManager::MAIN_BOARD_HEIGHT + 1)* CubeManager::CUBE_SIZE),
CCPoint(0, (CubeManager::MAIN_BOARD_HEIGHT + 1)* CubeManager::CUBE_SIZE)
};
pDrawNode->drawPolygon(points, sizeof(points)/sizeof(points[0]), ccc4f(0,0,0.3f,0.5f), 4, ccc4f(0,0,1,1));
CCLabelTTF* pLabel = CCLabelTTF::create("Score:", "Arial", 56);
pLabel->setPosition(ccp(size.width - 300, 1100));
pLabel->setAnchorPoint(ccp(0, 0.5f));
this->addChild(pLabel);
pLabel = CCLabelTTF::create("0", "Arial", 56);
pLabel->setPosition(ccp(size.width - 300, 1000));
pLabel->setColor(ccc3(255, 192, 0));
pLabel->setAnchorPoint(ccp(0, 0.5f));
//pLabel->setHorizontalAlignment(kCCTextAlignmentRight);
this->addChild(pLabel);
mLabelScore = pLabel;
if (!mCubeManager.init(this))
return false;
schedule(schedule_selector(GameWorld::stepGo), 0.5f);
schedule(schedule_selector(GameWorld::checkKeyInput));
schedule(schedule_selector(GameWorld::onKeyInput), 0.05f);
} while(0);
return true;
}
示例11: 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();
m_fElapsedTime = 0;
m_fScale = 1.0;
m_bSpeedUp = 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::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("Map Maker", "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);
// 버퍼 생성 및 팔레트 로딩
m_pPaletteBuffer = new unsigned char[NUM_PALETTES * 4]; // RGBA * 256 인덱스 컬러
m_pIndexBuffer = new unsigned char[IMAGE_WIDTH * IMAGE_HEIGHT]; // 인덱스 컬러로 된 이미지 버퍼
m_pImageBuffer = new unsigned char[IMAGE_WIDTH * IMAGE_HEIGHT*4]; // RGBA * 512 * 512
/*
// LAND.COL로 부터 팔레트 로딩
std::string sFilePath = std::string("");
sFilePath += CCFileUtils::sharedFileUtils()->fullPathForFilename("LAND.COL");
FILE *pal_file = fopen(sFilePath.c_str(), "rb");
if (pal_file)
{
fread(&head, sizeof(ColHeader), 1, pal_file);
//if (head.num_cols > NUM_PALETTES)
// head.num_cols = NUM_PALETTES;
fread(palette, 256*3, 1, pal_file);
fclose(pal_file);
// 팔레트 변환 RGB -> RGBA
BuildPal(palette, m_pPaletteBuffer);
}
*/
// PNG로부터 팔레트 로딩
GetPaletteFromFile("mapheight.png", m_pPaletteBuffer, 256);
// add generating "Map" screen"
// 인덱스 컬러로 된 이미지에 랜덤 값을 채운다.
for (int i = 0; i < IMAGE_WIDTH*IMAGE_HEIGHT; i++)
m_pIndexBuffer[i] = rand()%NUM_PALETTES;
// 인덱스 -> 이미지 변환
IndexToImage(m_pIndexBuffer, m_pImageBuffer, m_pPaletteBuffer, IMAGE_WIDTH*IMAGE_HEIGHT);
m_pBitmap = new CCImage();
m_pBitmap->initWithImageData(m_pImageBuffer, IMAGE_WIDTH*IMAGE_HEIGHT*4, CCImage::kFmtRawData, IMAGE_WIDTH, IMAGE_HEIGHT, 8);
CCTexture2D *pTex = new CCTexture2D();
pTex->initWithImage(m_pBitmap);
m_pScreen = CCSprite::createWithTexture(pTex);
pTex->release();
m_pBitmap->release();
// position the sprite on the center of the screen
m_pScreen->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
m_pScreen->setScale( 2.0 );
// add the sprite as a child to this layer
//.........这里部分代码省略.........
示例12: init
// on "init" you need to initialize your instance
bool GameState::init()
{
//////////////////////////////
// 1. super init first
///LayerColor->Layer로 바꿔야됨. 성능차이 많이나는듯
if ( !CCLayer::init() )
{
return false;
}
Camera::sharedCameraInstance()->release();
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
// create menu, it's an autorelease object
this->setTouchEnabled(true);
for(int i=0;i<2;i++)
{
CCMenuItemImage* buttonLeftImg = CCMenuItemImage::create("UI/move_left_normal.png","UI/move_left_normal.png");
CCMenuItemImage* buttonRightImg = CCMenuItemImage::create("UI/move_right_normal.png","UI/move_right_normal.png");
CCSprite *pressImg = CCSprite::create("UI/move_left_normal.png");
pressImg->setOpacity(100);
buttonLeftImg->setSelectedImage(pressImg);
CCSprite *pressRightImg = CCSprite::create("UI/move_right_normal.png");
pressRightImg->setOpacity(100);
buttonRightImg->setSelectedImage(pressRightImg);
if(i == 0) {
buttonLeftImg->setPosition(ccp(60,60));
buttonRightImg->setPosition(ccp(160,60));
}
else {
buttonLeftImg->setPosition(ccp(800,60));
buttonRightImg->setPosition(ccp(900,60));
}
buttonLeftImg->setTag(LEFT_BUTTON);
buttonRightImg->setTag(RIGHT_BUTTON);
buttons[i] = Buttons::create();
buttons[i]->setMusicSrc("music/ui/ui_click.ogg");
buttons[i]->addChild(buttonLeftImg);
buttons[i]->addChild(buttonRightImg);
buttons[i]->setPosition(CCPointZero);
this->addChild(buttons[i],ZORDER_BUTTON);
}
CCMenuItemFont* pMenuItem1 = CCMenuItemFont::create("Http Post",this,menu_selector(GameState::sendPostHttp));
CCMenuItemFont* pMenuItem2 = CCMenuItemFont::create("Http Get",this,menu_selector(GameState::sendGetHttp));
pMenuItem2->setColor(ccc3(255,255,255));
pMenuItem1->setColor(ccc3(255,255,255));
CCMenu* pMenu = CCMenu::create(pMenuItem1,pMenuItem2,NULL);
pMenu->setPosition(240,160);
pMenu->alignItemsVertically();
//this->addChild(pMenu);
/////////////////////////////
// 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 "GameState" splash screen"
CCSprite* pSprite = CCSprite::create("background/background_1.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
#ifndef BODY_DEBUG
this->addChild(pSprite, -20);
#endif
//pChracImg = CCSprite::create("chracter/move_ani.png");
//box2d///
//.........这里部分代码省略.........
示例13: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayer::init());
//////////////////////////////////////////////////////////////////////////
// add your codes below...
//////////////////////////////////////////////////////////////////////////
// 1. Add a menu item with "X" image, which is clicked to quit the program.
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
CC_BREAK_IF(! pCloseItem);
// Place the menu item bottom-right conner.
pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));
// Create a menu with the "close" menu item, it's an auto release object.
CCMenu* pMenu = CCMenu::createWithItem(pCloseItem);
pMenu->setPosition(CCPointZero);
CC_BREAK_IF(! pMenu);
// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu, 1);
// 2. Add a label shows "Hello World".
// Create a label and initialize with string "Hello World".
CCLabelTTF* pLabel = CCLabelTTF::create("THE HULK", "Thonburi", 34);
CC_BREAK_IF(! pLabel);
// Get window size and place the label upper.
CCSize size = CCDirector::sharedDirector()->getWinSize();
pLabel->setPosition(ccp(size.width / 2, size.height - 20));
// Add the label to HelloWorld layer as a child layer.
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("streetbackground.jpg");
// 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);
///////////////////////////////////////////////////////////////////////////////
//Generate Menu bar for hulk actions
generateHulkMenu();
///////////////////////////////////////////////////////////////////////////////
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("hulkmoves.plist");
CCSpriteBatchNode * sceneSpriteBatchNode = CCSpriteBatchNode::create("hulkmoves.png");
this->addChild(sceneSpriteBatchNode, 0);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//hulk= CCSprite::spriteWithFile("slice_0_1.png.png");
hulk=CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("slice_0_1.png"));
hulk->setScale(0.8);
hulk->setPosition(ccp(winSize.width/2,winSize.height*0.4));
addChild(hulk, 1);
bRet = true;
} while (0);
return bRet;
}
示例14: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
// Static reference
mytry = this;
// Init
if ( !CCLayer::init() )
{
return false;
}
// Menu
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
// Menu
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// Hello World
InterfaceJNI::helloWorld();
#endif
// Welcome
CCLabelTTF* pLabel = CCLabelTTF::create("CCSocialNetwork", "Thonburi", 34);
CCSize size = CCDirector::sharedDirector()->getWinSize();
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
this->addChild(pLabel, 1);
// Static Label Score
CCLabelTTF* scLabel = CCLabelTTF::create("Your Score:", "Thonburi", 34);
scLabel->setPosition( ccp(10 + scLabel->getContentSize().width/2, size.height - 20) );
this->addChild(scLabel, 1);
// Simulate var Score
sLabel = CCLabelTTF::create("123", "Thonburi", 34);
sLabel->setPosition( ccp(10 + scLabel->getContentSize().width/2, size.height - 60) );
this->addChild(sLabel, 1);
// Internet Label
CCLabelTTF* internetLabel = CCLabelTTF::create("Internet Connection:", "Thonburi", 20);
CCLabelTTF* internetValueLabel = CCLabelTTF::create("", "Thonburi", 20);
internetLabel->setPosition( ccp(10 + internetLabel->getContentSize().width/2, size.height - 90) );
internetValueLabel->setPosition( ccp(10 + internetValueLabel->getContentSize().width/2, size.height - 120) );
this->addChild(internetLabel, 1);
this->addChild(internetValueLabel, 1);
// Check Internet
CCLog("Go to check Internet connection...");
bool internet = this->tryIsInternetConnection();
if (internet)
{
internetValueLabel->setString("Connected YES");
}
else
{
internetValueLabel->setString("Connected NO");
}
CCLog("Internet connection value: %d", internet);
mLabel = CCLabelTTF::create("", "Thonburi", 20);
mLabel->setPosition(ccp(size.width/2, 20));
this->addChild(mLabel);
//Main Menu With Font
CCLabelTTF *sendMailButtonLabel = CCLabelTTF::create("Send an email", "Thonburi", 24);
CCMenuItemLabel *sendMailButton = CCMenuItemLabel::create(sendMailButtonLabel, this, menu_selector(HelloWorld::trySendAnEmail));
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
CCLabelTTF *sendMailButtonLabelInApp = CCLabelTTF::create("Send an email (in app mailer)", "Thonburi", 24);
CCMenuItemLabel *sendMailButtonInApp = CCMenuItemLabel::create(sendMailButtonLabelInApp, this, menu_selector(HelloWorld::trySendAnEmailInApp));
#endif
CCLabelTTF *sendTweetButtonLabel = CCLabelTTF::create("Send a tweet", "Thonburi", 24);
CCMenuItemLabel *sendTweetButton = CCMenuItemLabel::create(sendTweetButtonLabel, this, menu_selector(HelloWorld::trySendATweet));
CCLabelTTF *postOnFBButtonLabel = CCLabelTTF::create("Post on FB", "Thonburi", 24);
CCMenuItemLabel *postOnFBButton = CCMenuItemLabel::create(postOnFBButtonLabel, this, menu_selector(HelloWorld::tryPostOnFB));
CCMenu *mainMenu = CCMenu::create(sendMailButton,
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
sendMailButtonInApp,
#endif
sendTweetButton, postOnFBButton, NULL);
mainMenu->alignItemsVerticallyWithPadding(size.height * 0.06f);
mainMenu->setPosition(ccp(size.width/2, size.height/2));
this->addChild(mainMenu, 1);
return true;
//.........这里部分代码省略.........
示例15: init
bool MPJonsMapLayer::init()
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// Exit button
CCMenuItemImage *backItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(MPJonsMapLayer::titleCallback));
backItem->setPosition(ccp(origin.x + visibleSize.width - backItem->getContentSize().width/2 ,
origin.y + backItem->getContentSize().height/2));
CCMenu* menu = CCMenu::create(backItem, NULL);
menu->setPosition(CCPointZero);
this->addChild(menu, 1);
// Screen Title
CCLabelTTF* label = CCLabelTTF::create("A Map Scene", "Arial", TITLE_FONT_SIZE);
label->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
this->addChild(label, 1);
// Tile Map
CCTMXTiledMap *map = CCTMXTiledMap::create("JonMap/Random.tmx");
this->addChild(map, 0);
MPJonsMapLayer::antiAliasMap(map);
map->setAnchorPoint(ccp(.5, .5));
map->setPosition(ccp(visibleSize.width * .5, visibleSize.height * .5));
map->setScale(.5);
CCTMXLayer* layer = map->layerNamed("Background");
assert(layer != NULL);
CCSize mapSize = map->getContentSize();
float mapHeight = mapSize.height;
float mapWidth = mapSize.width;
// player->setPosition(ccp(positionX,positionY));
/*
CCSprite *tile = layer->tileAt(ccp(5,6));
assert(tile != NULL);
layer->removeTileAt(ccp(5, 6));
CCActionInterval* actionBy = CCMoveBy::create(2, ccp(visibleSize.width * .5, visibleSize.height * .5));
map->runAction(actionBy);
CCActionInterval* action = CCScaleBy::create(2, 2);
map->runAction(action);
*/
/*
CCSize s = layer->getLayerSize();
for (int x = 2; x < s.width; x++) {
for (int y = 0; y < s.height; y++) {
layer->removeTileAt(ccp(x, y));
}
}
*/
return true;
}