本文整理汇总了C++中CCMenuItemSprite::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemSprite::setScale方法的具体用法?C++ CCMenuItemSprite::setScale怎么用?C++ CCMenuItemSprite::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemSprite
的用法示例。
在下文中一共展示了CCMenuItemSprite::setScale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool ProceedController::init(){
if (!CCLayer::init()) {
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
//暂停按钮
CCMenuItemSprite *pause = this->instanceButton("pause1.png", "pause2.png", menu_selector(ProceedController::gamePauseFunc));
pause->setScale(1.5f);
pause->setPosition(ccp(size.width - pause->getContentSize().width,
size.height - pause->getContentSize().height));
//跳跃按钮
CCMenuItemSprite *jump = this->instanceButton("control_btn1.png", "control_btn2.png", menu_selector(ProceedController::gameJumpFunc));
jump->setScale(1.6f);
jump->setPosition(ccp(size.width - jump->getContentSize().width - 50, 100));
//fever按钮
CCMenuItemSprite *fever = this->instanceButton("Fever_1_1.png", "Fever_1_1.png",menu_selector(ProceedController::gameFeverFunc));
fever->setScale(1.5f);
fever->setOpacity(0.0f);
fever->setPosition(ccp(jump->getPosition().x - fever->getContentSize().width * 2.0,
jump->getPosition().y));
CCMenu *menu = CCMenu::create(pause,jump,fever,NULL);
menu->setPosition(0, 0);
this->addChild(menu,80);
return true;
}
示例2: init
bool testEffect::init(){
if ( !CCLayer::init() ){return false;}
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("0.GeneralPart.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("MikuFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("SheldonFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("IronManFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LichKingFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("BladeMasterFight.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("FightGeneral.plist");
ASBotFightLayer* aaa = ASBotFightLayer::createAsFightLayer(2, 4,true,1000,1,10000,6,10000,10);
aaa->setPosition(CCPointZero);
addChild(aaa,9999,9999);
CCMenu* menu = CCMenu::create();
for (int i = 1; i < 7 ; i++) {
string tmp = "card_" + int2string(i) + ".png";
CCSprite* repeatSprite = CCSprite::createWithSpriteFrameName(tmp.c_str());
CCMenuItemSprite* repeat = CCMenuItemSprite::create(repeatSprite,repeatSprite,this,menu_selector(testEffect::Repeat));
repeat->setScale(0.45);
repeat->setPosition(ccp(size.width/7 + size.width*(i-1)/7,size.height/8));
repeat->setTag(i);
menu->addChild(repeat);
}
menu->setPosition(CCPointZero);
addChild(menu,10000);
return true;
}
示例3: instructionButtonClick
void GameLayer::instructionButtonClick(CCObject *sender){
if (bPaused) {
return;
}
bPaused = true;
CCLayer *layer2 = new CCLayer();
CCSprite* dialog_bk = ThemeManager::sharedInstance()->spriteWithImageFile("dialog_intro.png");
dialog_bk->setScaleX(SCREEN_WIDTH/dialog_bk->getContentSize().width);
dialog_bk->setScaleY(SCREEN_WIDTH/dialog_bk->getContentSize().width);
dialog_bk->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
layer2->addChild(dialog_bk,11);
CCSprite* cancelNormal = ThemeManager::sharedInstance()->spriteWithImageFile("btn_know.png");
CCSprite* cancelSelected = ThemeManager::sharedInstance()->spriteWithImageFile("btn_know.png");
//CCMenuItemSprite* pcancelItemSprite = CCMenuItemSprite::itemWithNormalSprite(cancelNormal, cancelSelected, this, menu_selector(GameLayer::theme3useButtonClick));
CCMenuItemSprite* pcancelItemSprite = CCMenuItemSprite::itemWithNormalSprite(cancelNormal, cancelSelected, this, menu_selector(GameLayer::cancelButtonClick));
pcancelItemSprite->setScale(0.6*LL_SCREEN_SCALE_VALUE);
CCMenu* pcancelMenu = CCMenu::menuWithItems(pcancelItemSprite,NULL);
pcancelMenu->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.28));
layer2->addChild(pcancelMenu, 12);
layer2->setTag(1000);
CCActionInterval* largeto = CCScaleBy::create(0.2, 2);
layer2->setScale(0.5);
layer2->runAction(largeto);
this->addChild(layer2, 10);
}
示例4: energyBarAnimation
void ASGame::energyBarAnimation(){
//1.显示行动力的圆形底座
CCSprite* energyBall = CCSprite::createWithSpriteFrameName("newEnergyContainer.png");
energyBall->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
addChild(energyBall,4);
//2.行动力数量
string perStr = int2string(moveCount);
CCLabelTTF* per = CCLabelTTF::create(perStr.c_str(),"Arial Rounded MT bold",32);
per->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
addChild(per,5,1*10000000+26);
//3.能量条
CCSprite* energyBarSprite = CCSprite::createWithSpriteFrameName("newEnergyBar.png");
CCProgressTimer* energyBar = CCProgressTimer::create(energyBarSprite);
energyBar->setPosition(ccp(size.width*8.45/80,size.height*79.89/90+winDif*2*alpha*alpha));
energyBar->setType(kCCProgressTimerTypeRadial);
energyBar->setPercentage(moveCount*20);
addChild(energyBar,4,1*10000000+20);
//4.攻击按钮底座
CCSprite* containerSprite = CCSprite::createWithSpriteFrameName("energyContainer.png");
CCSprite* containerSprite_s = CCSprite::createWithSpriteFrameName("energyContainer.png");
CCMenuItemSprite* energyContainer = CCMenuItemSprite::create(containerSprite,containerSprite_s,this,menu_selector(ASGame::enterFightLayer));
energyContainer->setScale(1.05);
energyContainer->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
CCMenu* energyContainerMenu = CCMenu::create(energyContainer,NULL);
energyContainerMenu->setPosition(CCPointZero);
if (moveCount < moveToFight)
energyContainerMenu->setTouchEnabled(false);
addChild(energyContainerMenu,2,1*10000000+27);
//5.攻击按钮充值槽
CCSprite* barSprite = CCSprite::createWithSpriteFrameName("energyBar.png");
CCProgressTimer* attackButton = CCProgressTimer::create(barSprite);
attackButton->setScale(1.05);
attackButton->setPosition(ccp(size.width*179.04/200,size.height*10/135));
attackButton->setType(kCCProgressTimerTypeBar);
attackButton->setMidpoint(ccp(0.5, 0));
attackButton->setBarChangeRate(ccp(0, 1));
attackButton->setPercentage(100*moveCount/moveToFight);
addChild(attackButton,3,1*10000000+25);
//4.能量的盖子
CCSprite* energyBarCover = CCSprite::createWithSpriteFrameName("energyBarCover.png");
energyBarCover->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
energyBarCover->setOpacity(0);
//addChild(energyBarCover,4,1*10000000+28);
}
示例5: init
bool GameScene::init()
{
screenSize = CCDirector::sharedDirector()->getWinSize();
int r = CCRANDOM_0_1() * 10;
CCSprite* bg = NULL;
if (r >= 5) {
bg = CCSprite::createWithSpriteFrameName("bg_day.png");
} else {
bg = CCSprite::createWithSpriteFrameName("bg_night.png");
}
bg->setAnchorPoint(ccp(0, 0));
bg->setPosition(ccp(0, 0));
addChild(bg, 0);
CCSprite* land0 = CCSprite::createWithSpriteFrameName("land.png");
land0->setAnchorPoint(ccp(0, 0));
land0->setPosition(ccp(0, 0));
addChild(land0, 3, TAG_LAND);
CCMoveBy* move = CCMoveBy::create(1.0f, ccp(-land0->getContentSize().width * 0.25f, 0));
CCCallFuncN* call = CCCallFuncN::create(this, callfuncN_selector(GameScene::removeNodeSelf));
CCSequence* seq = CCSequence::create(move, call, NULL);
land0->runAction(seq);
randomValue = 0;
gameScore = 0;
isGameOver = false;
isShowingHint = true;
pipeArray = CCArray::create();
CC_SAFE_RETAIN(pipeArray);
hitCheckArray = CCArray::create();
CC_SAFE_RETAIN(hitCheckArray);
createBird();
showHint();
CCMenuItemSprite* pauseItem = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("button_pause.png"), NULL, this, menu_selector(GameScene::touchPauseCallBack));
pauseItem->setPosition(ccp(screenSize.width * 0.92f, screenSize.height * 0.95f));
pauseItem->setScale(2.0f);
CCMenu* m = CCMenu::create(pauseItem, NULL);
m->setPosition(CCPointZero);
addChild(m, 10);
M3AudioManager::shareInstance();
return true;
}
示例6: init
bool RPGMapItemsMenuLayer::init(cocos2d::CCDictionary *stringList, CppSQLite3DB *db, float width, float height)
{
if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
{
this->m_stringList = stringList;
this->m_stringList->retain();
this->m_db = db;
this->m_itemsList = new CCArray();
this->m_itemsList->init();
CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
mainBg->setPosition(CCPointZero);
mainBg->setTag(kRPGMapItemsMenuLayerTagBg);
this->addChild(mainBg);
CCMenu *mainMenu = CCMenu::create();
mainMenu->setTag(kRPGMapItemsMenuLayerTagMainMenu);
mainMenu->setAnchorPoint(CCPointZero);
mainMenu->setPosition(CCPointZero);
this->addChild(mainMenu);
CCMenuItemSprite *menuBack = (CCMenuItemSprite*)mainMenu->getChildByTag(kRPGMapItemsMenuLayerTagMainMenuBack);
if(!menuBack)
{
menuBack = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapItemsMenuLayer::onMenu));
menuBack->setPosition(ccp(40, 600));
menuBack->setTag(kRPGMapItemsMenuLayerTagMainMenuBack);
menuBack->setScale(0.5);
mainMenu->addChild(menuBack);
}
CCTableView *tableView = CCTableView::create(this, CCSizeMake(900, 570));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(ccp(80, 30));
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setTag(kRPGMapItemsMenuLayerTagItemListTable);
this->addChild(tableView);
this->loadItemsData();
return true;
}
return false;
}
示例7: startPlay
//private
void RPGMapSceneLayer::startPlay(float delay)
{
CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap);
//数据库部分,读取npc数据
CppSQLite3Query query = this->m_db.execQuery(CCString::createWithFormat(NPC_QUERY, this->m_mapData.mapId)->getCString());
while(!query.eof())
{
float x = (stringToNumber<float>(query.getStringField("tmx_x")) + 0.5) * GAME_TMX_ROLE_WIDTH;
float y = (stringToNumber<float>(query.getStringField("tmx_y")) + 0.5) * GAME_TMX_ROLE_HEIGHT;
bool autoMove = query.getIntField("auto_move") == 1 ? true : false;
RPGMapNPCRoleSprite *npc = RPGMapNPCRoleSprite::create(query.getIntField("id"), CCString::create(query.getStringField("map_texture")), CCString::create("head_texture"), CCString::create(query.getStringField("name_cns")), CCString::create(query.getStringField("content_cns")), 1, autoMove);
npc->setTag(kRPGMapSceneLayerTagNPC + query.getIntField("id"));
npc->setPosition(ccp(x, y));
bgMap->addChild(npc);
query.nextRow();
}
query.finalize();
//player
int defaultSpriteFrameIndex = 1; //默认为向下
if(this->m_mapData.playerDirection.compare("up") == 0)
{
defaultSpriteFrameIndex = 10;
}
else if(this->m_mapData.playerDirection.compare("left") == 0)
{
defaultSpriteFrameIndex = 4;
}
else if(this->m_mapData.playerDirection.compare("right") == 0)
{
defaultSpriteFrameIndex = 7;
}
RPGMapRoleSprite *player = RPGMapRoleSprite::create(CCString::create("actor4_0.png"), CCString::create("Player"), true, defaultSpriteFrameIndex);
player->setPosition(ccp(this->m_mapData.playerToX * GAME_TMX_ROLE_WIDTH, this->m_mapData.playerToY * GAME_TMX_ROLE_HEIGHT));
player->setTag(kRPGMapSceneLayerTagPlayer);
player->m_type = kRPGMapRoleSpriteTypePlayer;
bgMap->addChild(player);
CCSprite *spJoystick = CCSprite::createWithSpriteFrameName("Ball.png");
CCSprite *joystickBg = CCSprite::createWithSpriteFrameName("Dock.png");
OzgJoystickLayer *joystick = OzgJoystickLayer::layerActivityJoystick(50, spJoystick, joystickBg, false);
joystick->setTag(kRPGMapSceneLayerTagJoystick);
joystick->m_target = this;
joystick->m_endedSelector = callfunc_selector(RPGMapSceneLayer::joystickEndedFunc);
this->addChild(joystick);
//menu
CCMenu *mainMenu = CCMenu::create();
mainMenu->setTag(kRPGMapSceneLayerTagMainMenu);
mainMenu->setAnchorPoint(ccp(0.5, 0.5));
mainMenu->setPosition(CCPointZero);
mainMenu->setContentSize(bgMap->getContentSize());
bgMap->addChild(mainMenu);
CCMenuItemSprite *menuCommand = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapSceneLayer::onMenu));
menuCommand->setPosition(ccp(mainMenu->getContentSize().width - 35, mainMenu->getContentSize().height - 35));
menuCommand->setTag(kRPGMapSceneLayerTagMainMenuCommand);
menuCommand->setRotation(180);
menuCommand->setScale(0.75);
mainMenu->addChild(menuCommand);
// CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo();
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, true);
this->scheduleUpdate();
}
示例8: glClearColor
Loading::Loading()
{
glClearColor(0.0f/255.0f, 0.0f/255.0f, 0.0f/255.0f, 1.0f);
setTouchEnabled( true );
float scale = ScreenHelper::getTextureScale();
float scaleX = ScreenHelper::getTextureScaleX();
float scaleY = ScreenHelper::getTextureScaleY();
CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Buttons.pvr.ccz");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Buttons.plist");
CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Icons.pvr.ccz");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Icons.plist");
CCTextureCache::sharedTextureCache()->addPVRImage("LoadingScreen.pvr.ccz");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LoadingScreen.plist");
CCPoint scalePoint;
scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
scalePoint.y += -5*scale;
CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_Screen_ver2.png");
sprite->setScale(scale);
sprite->setPosition(scalePoint);
addChild(sprite);
sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_ProgressScroll_Graphic.png");
sprite->setScaleX(scaleX);
sprite->setScaleY(scaleY*1.2f);
sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_LEFT,-140.0f,-50.0f));
loadingBar = sprite;
addChild(sprite,2);
sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_TopPanel.png");
sprite->setScaleX(scaleX);
sprite->setScaleY(scaleY);
sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-55.0f));
addChild(sprite,2);
sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_TopOverlay.png");
sprite->setScaleX(scaleX);
sprite->setScaleY(scaleY);
sprite->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
addChild(sprite,2);
sprite = CCSprite::createWithSpriteFrameName("BackgroundPlate.png");
sprite->setScale(scale);
scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
scalePoint.x += -135.0f*scale;
scalePoint.y += -97.0f*scale;
sprite->setPosition(scalePoint);
addChild(sprite,2);
sprite = CCSprite::createWithSpriteFrameName("BronzeText.png");
sprite->setScale(scale);
scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
scalePoint.x += -135.0f*scale;
scalePoint.y += -97.0f*scale;
sprite->setPosition(scalePoint);
addChild(sprite,2);
CCLabelTTF *label = CCLabelTTF::create(LevelSelect::getLevelName(), "impact.ttf", 42*scale);
addChild(label, 2);
label->setColor(ccc3(0,0,0));
label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,2.0f,-44.0f));
label = CCLabelTTF::create(LevelSelect::getLevelName(), "impact.ttf", 42*scale);
addChild(label, 2);
label->setColor(ccc3(237,188,0));
label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-42.0f));
int currentLevel = LevelSelect::getCurrentLevel();
if(currentLevel >= BONUS_LEVELSTART)
g_isTrickLevel = true;
else
g_isTrickLevel = false;
int medalLevel = SaveLoad::m_SaveData.medalLockLevel;
int showMedal = 0;
if(medalLevel==0)
{
if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::ONE_COCONUT)
showMedal = 1;
}
if(medalLevel==1)
{
if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::TWO_COCONUT)
showMedal = 2;
}
if(medalLevel==2)
{
if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::THREE_COCONUT)
showMedal = 3;
}
if(!showMedal)
{
//.........这里部分代码省略.........
示例9: init
bool LeaderBoard::init()
{
if (!CCLayer::init())
return false;
//float iMenuWidthOffset = 0.55;
SCREEN_WIDTH = CCDirector::sharedDirector()->getWinSize().width;
SCREEN_HEIGHT = CCDirector::sharedDirector()->getWinSize().height;
CCSprite* bgsprite =ThemeManager::sharedInstance()->spriteWithImageFile("leaderboard.png");
bgsprite->setScaleX(SCREEN_WIDTH/bgsprite->getContentSize().width);
bgsprite->setScaleY(SCREEN_HEIGHT/bgsprite->getContentSize().height);
bgsprite->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
this->addChild(bgsprite,1);
CCSprite* updateNicknamelb =ThemeManager::sharedInstance()->spriteWithImageFile("btn_update_nickname.png");
CCSprite* updateNicknameSelectedlb =ThemeManager::sharedInstance()->spriteWithImageFile("btn_update_nickname.png");
updateNicknameSelectedlb->setScale(1.1);
CCMenuItemSprite* pupdateNicknameItemSpritelb = CCMenuItemSprite::itemWithNormalSprite(updateNicknamelb, updateNicknameSelectedlb, this, menu_selector(LeaderBoard::updateNicknameClick));
pupdateNicknameItemSpritelb->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* pupdateNicknameMenu = CCMenu::menuWithItems(pupdateNicknameItemSpritelb,NULL);
pupdateNicknameMenu->setPosition(ccp(SCREEN_WIDTH*0.3, SCREEN_HEIGHT*0.15));
this->addChild(pupdateNicknameMenu, 3);
CCSprite* back2menuNormallb =ThemeManager::sharedInstance()->spriteWithImageFile("back2menu.png");
CCSprite* back2menuSelectedlb =ThemeManager::sharedInstance()->spriteWithImageFile("back2menu.png");
back2menuSelectedlb->setScale(1.1);
CCMenuItemSprite* pback2menuItemSpritelb = CCMenuItemSprite::itemWithNormalSprite(back2menuNormallb, back2menuSelectedlb, this, menu_selector(LeaderBoard::back2menuClick));
pback2menuItemSpritelb->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* pback2menuMenu = CCMenu::menuWithItems(pback2menuItemSpritelb,NULL);
pback2menuMenu->setPosition(ccp(SCREEN_WIDTH*0.7, SCREEN_HEIGHT*0.15));
this->addChild(pback2menuMenu, 3);
CCLayer *bg = CCLayer::create();
bg->setContentSize(CCSizeMake(SCREEN_WIDTH,SCREEN_HEIGHT*0.58));
bg->setAnchorPoint(ccp(0,0));
bg->setPosition(ccp(0,0));
char buff[16];
*buff = 0;
for(int i=0;i<10;i++){
int offsetHeight = SCREEN_HEIGHT*(0.63125-0.0583*i-0.08);
sprintf(buff,"%d ",i+1);
scoreLabel=CCLabelTTF::labelWithString(buff,CCSizeMake(300*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.43,offsetHeight));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
bg->addChild(scoreLabel, 4);
scoreLabel=CCLabelTTF::labelWithString(getNicknameByRank(i+1),CCSizeMake(300*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.50,offsetHeight));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
bg->addChild(scoreLabel, 4);
sprintf(buff,"%d ",getScore(i+1));
scoreLabel=CCLabelTTF::labelWithString(buff,CCSizeMake(150*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentRight,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.78,offsetHeight));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
bg->addChild(scoreLabel, 4);
}
CCScrollView * view = CCScrollView::create(CCSizeMake(SCREEN_WIDTH,SCREEN_HEIGHT*0.35), bg);
view->setDirection(kCCScrollViewDirectionVertical);
view->setContentSize( CCSizeMake(SCREEN_WIDTH,SCREEN_HEIGHT*0.58) );
view->setContentOffset(ccp(0,-SCREEN_HEIGHT*0.226));
view->setAnchorPoint(ccp(0,0));
view->setPosition(0,SCREEN_HEIGHT*0.305);
this->addChild(view,4);
sprintf(buff,"%d ",getBestScore());
scoreLabel=CCLabelTTF::labelWithString(buff,CCSizeMake(150*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentRight,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.78,SCREEN_HEIGHT*(0.62725-0.0583*6)));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
this->addChild(scoreLabel, 4);
scoreLabel=CCLabelTTF::labelWithString(getNickname(),CCSizeMake(300*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.51,SCREEN_HEIGHT*(0.62725-0.0583*6)));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
this->addChild(scoreLabel, 4);
/*char buff2[256];
*buff2 = 0;
sprintf(buff2,"%d %s",getUserRank(), getNickname());
scoreLabel=CCLabelTTF::labelWithString(buff2,CCSizeMake(330*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.43,SCREEN_HEIGHT*(0.63125-0.0583*7)));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
this->addChild(scoreLabel, 4);*/
return true;
}
示例10: init
//.........这里部分代码省略.........
m_NumberOfCarrots->setPosition(ccp(5.f+carrotSize.width*0.5f, m_Carrot->getPositionY()-2.f));
this->addChild(m_NumberOfCarrots, StageMapLayerDepth_UIComponents);
}
// END BASE
m_MapBase = CCNode::create();
m_MapBase->retain();
m_MapBase->setContentSize(winSize);
m_MapBase->setAnchorPoint(AnchorPointMidBottom);
m_MapBase->setPosition(ccp(winSize.width/2.f, 0.f));
this->addChild(m_MapBase,StageMapLayerDepth_MapBase);
m_StageInfoBox = CCSprite::createWithSpriteFrameName("stagemap_info_box.png");
m_StageInfoBox->retain();
m_StageInfoBox->setAnchorPoint(AnchorPointMid);
const CCSize stageInfoBoxSize = m_StageInfoBox->getContentSize();
m_StageInfoBox->setPosition(ccp(winSize.width*0.5f, stageInfoBoxSize.height*0.5f));
m_Bottom->addChild(m_StageInfoBox,StageMapLayerDepth_UIComponents);
StageInfoDictionary::Instance().ForEachStageInfo([this](StageInfo* stageInfo)
{
this->AddStageMapPoint(*stageInfo);
});
CharacterData characterData = *CharacterDictionary::Instance().GetCharacterData(GooRoomClient::Instance().GetUser()->GetSelectedCharacterType());
characterData.SetLevel(GooRoomClient::Instance().GetUser()->GetSelectedCharacterCard().GetLevel());
m_MyPlayer = PlayerNode::create(characterData, ActorID_None, GooRoomClient::Instance().GetUser()->GetUserName().c_str(), TeamType_None);
m_MyPlayer->retain();
m_MyPlayer->setPosition((m_StageMapPointList.front()->getPosition()+m_PlayerPositionOffset));
m_MyPlayer->setAnchorPoint(CharacterAnchorPoint);
m_MapBase->addChild(m_MyPlayer);
StageInfo* stageInfo = StageInfoDictionary::Instance().FindStageInfo(0);
m_MissionBox = MissionBox::create(*stageInfo);
m_MissionBox->retain();
m_MissionBox->setAnchorPoint(AnchorPointLeftBottom);
const CCSize missionBoxSize = m_MissionBox->getContentSize();
m_MissionBox->setPosition(ccp(missionBoxSize.width*0.5f, missionBoxSize.height*0.5f));
this->addChild(m_MissionBox, StageMapLayerDepth_UIComponents);
m_TitleBox = TitleBox::create(*stageInfo);
m_TitleBox->retain();
m_TitleBox->setAnchorPoint(AnchorPointLeftBottom);
const CCSize titleBoxSize = m_TitleBox->getContentSize();
m_TitleBox->setPosition(ccp(winSize.width-titleBoxSize.width*0.5f, titleBoxSize.height*0.5f+5.f));
this->addChild(m_TitleBox, StageMapLayerDepth_UIComponents);
// Create Button
m_CreateStage = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("create_button.png"), CCSprite::createWithSpriteFrameName("create_button_pushed.png"), this, menu_selector(StageMapLayer::OnCreateStageTouch));
m_CreateStage->retain();
m_MenuCreateStage = CCMenu::create(m_CreateStage, nullptr);
m_MenuCreateStage->retain();
m_MenuCreateStage->setAnchorPoint(AnchorPointMid);
const CCSize menuItemSize = m_CreateStage->getContentSize();
m_MenuCreateStage->setPosition(ccp(winSize.width-menuItemSize.width/2.f-40.f, menuItemSize.height/2.f+10.f));
this->addChild(m_MenuCreateStage, StageMapLayerDepth_UIComponents);
// End Create Button
// Exit Button
CCMenuItemSprite* exitButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("exit_button.png"),CCSprite::createWithSpriteFrameName("exit_button_pushed.png"), this, menu_selector(StageMapLayer::OnExitButtonTouch));
CCMenu* exitMenu = CCMenu::create(exitButton, NULL);
CCSize exitButtonSize = exitButton->getContentSize();
exitMenu->setPosition(winSize.width-exitButtonSize.width/2.f-5.f, winSize.height-exitButtonSize.height/2.f-5.f);
this->addChild(exitMenu, StageMapLayerDepth_UIComponents);
// Shop Menu
{
CCSprite* shopSprite = CCSprite::createWithSpriteFrameName("mainscene_blank_button.png");
CCSprite* shopPushedSprite = CCSprite::createWithSpriteFrameName("mainscene_blank_button_pushed.png");
CCMenuItemSprite* shopButton = CCMenuItemSprite::create(shopSprite, shopPushedSprite, this, menu_selector(StageMapLayer::OnShopButtonTouch));
CCLabelTTF* shopLabel = CCLabelTTF::create("구르몽 친구들", fontList[0].c_str(), 14);
shopLabel->setColor(ccBLACK);
shopLabel->setAnchorPoint(AnchorPointMid);
const CCSize shopSpriteSize = shopSprite->getContentSize();
shopLabel->setPosition(ccp(shopSpriteSize.width*0.5f, shopSpriteSize.height*0.5f));
shopSprite->addChild(shopLabel);
shopButton->setScale(0.85f);
CCMenu* shopMenu = CCMenu::create(shopButton, nullptr);
shopMenu->setPosition(ccp(winSize.width-shopSpriteSize.width*0.5f - 5.f, winSize.height-exitButtonSize.height - 5.f -shopSpriteSize.height*0.5f -10.f));
this->addChild(shopMenu, StageMapLayerDepth_UIComponents);
}
StageLevel currentStageLevel = GooRoomClient::Instance().GetUser()->GetStageLevel();
if( currentStageLevel >= m_StageMapPointList.size() )
{
currentStageLevel = m_StageMapPointList.size()-1;
}
this->SelectStageMapPoint(currentStageLevel-1, false);
this->SelectStageMapPoint(currentStageLevel, true);
this->scheduleUpdate();
return true;
}
示例11: init
bool MainLayer::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayer::init());
//////////////////////////////////////////////////////////////////////////
// add your codes below...
//////////////////////////////////////////////////////////////////////////
CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile("PlayBox.plist", "PlayBox.png");
cache->addSpriteFramesWithFile("resources.plist");
// 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.
CCMenuItemSprite *pCloseItem = CCMenuItemSprite::create(
CCSprite::createWithSpriteFrameName("close.png"), NULL, this,
menu_selector(MainLayer::menuCloseCallback));
CC_BREAK_IF(! pCloseItem);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
// Place the menu item bottom-right conner.
pCloseItem->setPosition(ccp(winSize.width - 64, winSize.height - 64));
pCloseItem->setScale(2.0f);
// 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 Main layer as a child layer.
this->addChild(pMenu, 1);
CCLabelTTF* label = CCLabelTTF::create("DreamBook", "Arial", 46);
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MainLayer::menuDreamBookCallback));
pMenu = CCMenu::create(pMenuItem, NULL);
label = CCLabelTTF::create("PhysicsTech", "Arial", 46);
pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MainLayer::menuPhysicsTechCallback));
pMenu->addChild(pMenuItem);
label = CCLabelTTF::create("ToyBrick", "Arial", 46);
pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MainLayer::menuToyBrickCallback));
pMenu->addChild(pMenuItem);
label = CCLabelTTF::create("DancingBone", "Arial", 46);
pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MainLayer::menuDancingBoneCallback));
pMenu->addChild(pMenuItem);
label = CCLabelTTF::create("Boy Model", "Arial", 46);
pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MainLayer::menuPhysicalBodyCallback));
pMenu->addChild(pMenuItem);
label = CCLabelTTF::create("Kong Rong Gave Away Bigger Pear", "Arial", 46);
pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MainLayer::menuKongRongCallback));
pMenu->addChild(pMenuItem);
label = CCLabelTTF::create("Dock Test", "Arial", 46);
pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(MainLayer::menuEFTestCallback));
pMenu->addChild(pMenuItem);
pMenu->alignItemsVertically();
this->addChild(pMenu);
pMenu->setPosition(ccp(winSize.width * 0.5F, winSize.height * 0.6F));
/*this->lbDebug = CCLabelTTF::create("Start", "Arial", 24);
this->lbDebug->setColor(ccc3(255, 255, 1));
this->lbDebug->setPosition(ccp(0, winSize.height - 100));
this->lbDebug->setAnchorPoint(CCPointZero);
this->addChild(this->lbDebug);*/
//add Whislly test start
/*cocos2d::extension::Parse parse;
parse.setApplicationId("n1s82tGoQDgDM09qFNm0UQkKNO7yW1gqpQSavT5n");
parse.setApiKey("Nh4K6HM2tohkmQdeu5vfN7ZWP83OMQ72uH0YMtW7");
parse.setMasterKey("doMxP88XvGkICRrI3gPcCdwWMI26QZfzPMKER33m");*/
//ParseFile* file = new ParseFile();
/*file->uploadFileCompleted.Set(this, (Delegate<FileInfo*, ParseError*>::MemberFun)&MainLayer::UploadComplet);
file->uploadFile("D:", "smbios.zip");*/
//file->downloadFile("http://files.parse.com/148a2d0f-6637-47cf-b4d1-0c2083de23ef/03e0430a-ee2f-4e36-81fa-48c91607afa7-smbios.zip","D:\\Test.zip");
//file->deleteFile("03e0430a-ee2f-4e36-81fa-48c91607afa7-smbios.zip");
//file->release();
/*
cocos2d::extension::ParseQuery* query = new cocos2d::extension::ParseQuery("GameTest");
query->findObjectsCompleted.Set(this, (Delegate<CCArray*, ParseError*>::MemberFun)&MainLayer::GetComplet);
query->findObjects();
query->release();*/
CC_BREAK_IF(! pMenu);
//.........这里部分代码省略.........
示例12: init
// on "init" you need to initialize your instance
bool GameLayer::init()
{
if (!CCLayer::init())
return false;
SCREEN_WIDTH = CCDirector::sharedDirector()->getWinSize().width;
SCREEN_HEIGHT = CCDirector::sharedDirector()->getWinSize().height;
bPaused = false;
//Jerry--LB
receiveRank();
CCSprite* sprite = ThemeManager::sharedInstance()->spriteWithImageFile("background.png");//ThemeManager::sharedInstance()->spriteWithImageFile("background.png");
sprite->setScaleX(SCREEN_WIDTH/sprite->getContentSize().width);
sprite->setScaleY(SCREEN_HEIGHT/sprite->getContentSize().height);
sprite->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
this->addChild(sprite,1);
float iMenuWidthOffset = 0.55;
CCSprite* startNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_start.png");
CCSprite* startSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_start.png");
CCMenuItemSprite* pStartItemSprite = CCMenuItemSprite::itemWithNormalSprite(startNormal, startSelected, this, menu_selector(GameLayer::startButtonClick));
CCMenu* pStartMenu = CCMenu::menuWithItems(pStartItemSprite,NULL);
pStartMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.6));
pStartItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
//Jerry--Action
CCScaleTo* large=CCScaleTo::actionWithDuration(0.5,0.7*LL_SCREEN_SCALE_VALUE);
CCScaleTo* small=CCScaleTo::actionWithDuration(0.5,LL_BUTTON_SCALE_VALUE);
CCDelayTime *waiting=CCDelayTime::actionWithDuration(1.0f);
CCFiniteTimeAction* action= CCSequence::actions(waiting,large,small,waiting,NULL);
CCActionInterval* actionShake=CCRepeatForever::actionWithAction((CCActionInterval*)action);
pStartItemSprite->stopAllActions();
pStartItemSprite->runAction(actionShake);
this->addChild(pStartMenu, 3);
/*CCSprite* leaderboardNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
CCSprite* leaderboardSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
CCSprite* leaderboardDisabled = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
CCMenuItemSprite* pleaderboardItemSprite = CCMenuItemSprite::itemWithNormalSprite(leaderboardNormal, leaderboardSelected, leaderboardDisabled, this, menu_selector(GameLayer::levelButtonClick));
pleaderboardItemSprite->setScale(0.8);
CCMenu* pleaderboardMenu = CCMenu::menuWithItems(pleaderboardItemSprite,NULL);
pleaderboardMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.4));
this->addChild(pleaderboardMenu, 3);*/
CCSprite* instructionNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_instruction.png");
CCSprite* instructionSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_instruction.png");
CCMenuItemSprite* pinstructionItemSprite = CCMenuItemSprite::itemWithNormalSprite(instructionNormal, instructionSelected,this, menu_selector(GameLayer::instructionButtonClick));
pinstructionItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* pinstructionMenu = CCMenu::menuWithItems(pinstructionItemSprite,NULL);
pinstructionMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.5));
this->addChild(pinstructionMenu, 3);
CCSprite* quitNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_quit.png");
CCSprite* quitSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_quit.png");
quitSelected->setScale(1.1);
CCMenuItemSprite* pquitItemSprite = CCMenuItemSprite::itemWithNormalSprite(quitNormal, quitSelected, this, menu_selector(GameLayer::finishButtonClick));
pquitItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* pquitMenu = CCMenu::menuWithItems(pquitItemSprite,NULL);
pquitMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.2));
this->addChild(pquitMenu, 3);
//Jerry--Code
CCSprite* lbNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
CCSprite* lbSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_leaderboard.png");
lbSelected->setScale(1.1);
CCMenuItemSprite* plbItemSprite = CCMenuItemSprite::itemWithNormalSprite(lbNormal, lbSelected, this, menu_selector(GameLayer::leaderboardButtonClick));
plbItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* plbMenu = CCMenu::menuWithItems(plbItemSprite,NULL);
plbMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.4));
this->addChild(plbMenu, 3);
//Jerry--Code
CCSprite* thNormal = ThemeManager::sharedInstance()->spriteWithImageFile("menu_theme.png");
CCSprite* thSelected = ThemeManager::sharedInstance()->spriteWithImageFile("menu_theme.png");
thSelected->setScale(1.1);
CCMenuItemSprite* pthItemSprite = CCMenuItemSprite::itemWithNormalSprite(thNormal, thSelected, this, menu_selector(GameLayer::themeButtonClick));
pthItemSprite->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* pthMenu = CCMenu::menuWithItems(pthItemSprite,NULL);
pthMenu->setPosition(ccp(SCREEN_WIDTH*iMenuWidthOffset, SCREEN_HEIGHT*0.3));
this->addChild(pthMenu, 3);
if(getFlags("INPUT_NICKNAME_FLAG") == 0) {
updateNickname(NULL);
setFlags("INPUT_NICKNAME_FLAG", 1);
}
//InitBdAd();
//showDoSplash();
PlatformManager::sharedInstance()->showBanner();
PlatformManager::sharedInstance()->showInter();
//showDoBanner();
return true;
//.........这里部分代码省略.........
示例13: init
// on "init" you need to initialize your instance
bool StartMenu::init()
{
//////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCTexture2D *shipTexture = CCTextureCache::sharedTextureCache()->addImage(s_ship01);
// 添加Android的按键处理,这里加了全局代理
this->setKeypadEnabled(true);
CostomeKeyPadDelegae *keyDelegate = new CostomeKeyPadDelegae();
keyDelegate->autorelease();
CCDirector::sharedDirector()->getKeypadDispatcher()->addDelegate(keyDelegate);
//////////////////
// 2. add main menu ,logo, loading, and ships
winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* sl = CCSprite::create(s_loading);
sl->setAnchorPoint(ccp(0, 0));
this->addChild(sl,0,1);
CCSprite* logo = CCSprite::create(s_logo);
logo->setAnchorPoint(ccp(0.5, 1));
logo->setPosition(ccp(winSize.width/2, winSize.height-100));
this->addChild(logo, 10, 1);
CCSprite* newGameNormal = CCSprite::create(s_menu, CCRectMake(0, 0, 126, 33));
CCSprite* newGameSelected = CCSprite::create(s_menu, CCRectMake(0, 33, 126, 33));
CCSprite* newGameDisabled = CCSprite::create(s_menu, CCRectMake(0, 33*2, 126, 33));
CCSprite* gameSettingNormal = CCSprite::create(s_menu, CCRectMake(126, 0, 126, 33));
CCSprite* gameSettingNSelected = CCSprite::create(s_menu, CCRectMake(126, 33, 126, 33));
CCSprite* gameSettingDesabled = CCSprite::create(s_menu, CCRectMake(126, 33*2, 126, 33));
CCSprite* aboutNormal = CCSprite::create(s_menu, CCRectMake(252, 0, 126, 33));
CCSprite* aboutSelected = CCSprite::create(s_menu, CCRectMake(252, 33, 126, 33));
CCSprite* aboutDesabled = CCSprite::create(s_menu, CCRectMake(252, 33*2, 126, 33));
CCMenuItemSprite* newGame = CCMenuItemSprite::create(newGameNormal, newGameSelected, newGameDisabled, this, menu_selector(StartMenu::flareEffect));
newGame->setScale(1.5f);
CCMenuItemSprite* gameSetting = CCMenuItemSprite::create(gameSettingNormal, gameSettingNSelected, gameSettingDesabled, this, menu_selector(StartMenu::menuCallback));
gameSetting->setScale(1.5f);
gameSetting->setTag(20);
CCMenuItemSprite* about = CCMenuItemSprite::create(aboutNormal, aboutSelected, aboutDesabled, this, menu_selector(StartMenu::menuCallback));
about->setScale(1.5f);
about->setTag(21);
// 最后一个参数要是NULL
CCMenu* menu = CCMenu::create(newGame, gameSetting, about, NULL);
menu->alignItemsVerticallyWithPadding(30);
this->addChild(menu, 1, 2);
menu->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 80));
this->schedule(schedule_selector(StartMenu::update), 0.1);
// ships
CCTexture2D *textCache = CCTextureCache::sharedTextureCache()->textureForKey(s_ship01);
m_ship = CCSprite::createWithTexture(textCache, CCRectMake(0, 45, 60, 38));
this->addChild(m_ship, 0, 4);
CCPoint position = ccp(CCRANDOM_0_1() * winSize.width, 0);
m_ship->setPosition(position);
m_ship->runAction(CCMoveBy::create(2, ccp(CCRANDOM_0_1() * winSize.width, position.y + winSize.height + 100)));
if (Config::sharedConfig()->getAudioState()&&!Config::sharedConfig()->isOptions()&&!Config::sharedConfig()->isAbout()) {
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.7);
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(s_mainMainMusic, true);
}
Config::sharedConfig()->setOptions(false);
Config::sharedConfig()->setAbout(false);
CCSprite* fragment = CCSprite::create();
fragment->initWithFile(s_fragment);
this->addChild(fragment,1000);
fragment->setPosition(ccp(240,300));
CCOrbitCamera * orbit = CCOrbitCamera::create(0.3, 1, 0, 0, 360, 0, 0);//(8, 1, 0, 0, 360, 90, -45)
fragment->runAction(CCRepeatForever::create(orbit));
/////////////////////////////////////////////////////////////////////////////
CCSprite *sprite = CCSprite::create();
sprite->initWithFile(s_fire);
this->addChild(sprite,10);
sprite->setPosition(ccp(100,200));
CCMyParticleSun *system = CCMyParticleSun::create();
sprite->addChild(system,10);
CCSize size = sprite->getContentSize();
system->setPosition(ccp(size.width/2,size.height/2));
CCMoveBy *by = CCMoveBy::create(5,ccp(400,100));
CCFiniteTimeAction *seq = CCSequence::create(by, by->reverse(), NULL);
sprite->runAction(CCRepeatForever::create((CCActionInterval*)seq));
/*
CCTexture2D *temp = CCTextureCache::sharedTextureCache()->addImage(s_boss_one);
CCTexture2D* texture = Util::getGrayTexture(temp);
//.........这里部分代码省略.........
示例14: init
bool PrepareLayer::init()
{
CCSize size = ToolsFun::sharedTools()->getSceneSize();
//背景
CCSprite *spBkg = CCSprite::create("ui/shared/bkg.png");
this->addChild(spBkg,-1);
spBkg->setPosition(size/2);
//放置人物设定背景
CCSprite *spBkgHero = CCSprite::create("ui/prepareUI/mainbkg.png");
this->addChild(spBkgHero,-1);
spBkgHero->setPosition(ccp(size.width/2,size.height - spBkgHero->getContentSize().height/2 - 50*gScaleY));
//购物
CCSprite *spBkgTop = CCSprite::create("ui/shared/top.png");
this->addChild(spBkgTop,0,108);
spBkgTop->setPosition(ccp(size.width/2,size.height - spBkgTop->getContentSize().height/2));
//人物游戏记录背景
CCSprite *spRecoreBkg = CCSprite::create("ui/prepareUI/recordbkg.png");
this->addChild(spRecoreBkg,-1);
spRecoreBkg->setPosition(ccp(315*gScaleX,600*gScaleY));
//spRecoreBkg->setScale(PRE_SCALE);
//宠物,道具背景
for (int i=0;i!=1;++i)
{
CCSprite *sp = CCSprite::create("ui/shared/placeboard.png");
this->addChild(sp,-1);
sp->setPosition(ccp(size.width/4 + i * size.width/2,165*gScaleY));
sp->setScale(1.10f);
}
int level = GameConfigData::initialGameData().getCurLevel();
int killTotal = 0;
killTotal = atoi( GameConfigData::initialGameData().getKillTotal().c_str());
char buf[64];
sprintf(buf,"%d",killTotal);
int levelMaxStr = GameConfigData::initialGameData().getMaxUnLockLevel();
string strs[4] =
{
GameConfigData::initialGameData().getHScores(),
GameConfigData::initialGameData().getHLenght(),
string(buf),
ToolsFun::sharedTools()->intToString(levelMaxStr)
};
for (int i=0;i!=4;++i)
{
CCLabelBMFont *hScores = CCLabelBMFont::create(strs[i].c_str() ,"font/white_30.fnt");
spRecoreBkg->addChild(hScores);
hScores->setPosition(ccp(150*gScaleX,(165-8-38*i))*gScaleY);
hScores->setAnchorPoint(ccp(0,0.5f));
}
m_menu = CCMenu::create();
this->addChild(m_menu,1);
m_menu->setPosition(CCPointZero);
//所有按钮的放置
const char* fName[9] =
{
"ui/shared/back.png",//返回
"ui/shared/coinplus.png",//添加金币
"ui/prepareUI/head.png",//主角头像
"ui/prepareUI/upgrade.png",//升级按钮
"ui/shared/shop_item.png",//宠物1
"ui/shared/shop_item.png",//宠物2
"ui/shared/shop_item.png",//道具1
// "ui/shared/shop_item.png",//道具2
"ui/shared/confirm.png"//确定开始游戏
};
const CCPoint posArray[9] =
{
ccp(37*gScaleX,size.height-37*gScaleY),ccp(430*gScaleX,size.height-30*gScaleY),ccp(290*gScaleX,435*gScaleY),ccp(360*gScaleX,335*gScaleY),
ccp(54*gScaleX,145*gScaleY),ccp(144*gScaleX,145*gScaleY),ccp(355*gScaleX,145*gScaleY),ccp(235*gScaleX,40*gScaleY),ccp(235*gScaleX,40*gScaleY)
};
for (int i=0;i!=8;++i)
{
CCSprite *spNml = CCSprite::create(fName[i]);
CCSprite *spSel = CCSprite::create(fName[i]);
spSel->setColor(ccc3(80,80,80));
CCMenuItemSprite *itemSp = CCMenuItemSprite::create(spNml,spSel,
this,menu_selector(PrepareLayer::menuTouch));
if(i==2)
{
m_menu->addChild(itemSp,1,100+i);
itemSp->setPosition(posArray[i]);
itemSp->setScale(0.8f);
}
else if(i ==3)
{
m_menu->addChild(itemSp,1,100+i);
itemSp->setPosition(posArray[i]);
itemSp->setScale(PRE_SCALE);
//.........这里部分代码省略.........
示例15: onMenu
void RPGBattleMenu::onMenu(cocos2d::CCObject *pObject)
{
CCMenuItem *menuItem = (CCMenuItem*)pObject;
SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
switch (menuItem->getTag())
{
case kRPGBattleMenuTagSkill:
{
CCLog("技能");
this->hideMenu();
this->m_selectedMenuTag = kRPGBattleMenuTagSkill;
CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
menuCancel->setPosition(ccp(43, 596));
menuCancel->setTag(kRPGBattleMenuTagCancel);
menuCancel->setScale(0.75);
this->addChild(menuCancel);
CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
selectLayer->setTag(kRPGBattleSceneLayerTagSkillSelectDialog);
((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);
((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
//显示title和分隔线
addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("skill_title"), 25, ccp(310, 285));
CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
titleLab->setFontFillColor(ccc3(144, 144, 144));
CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
separate->setScaleX(0.65);
separate->setTag(198);
selectLayer->addChild(separate);
//加载技能数据
CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
if(!tableView)
{
tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(CCSizeZero);
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setTag(197);
selectLayer->addChild(tableView);
}
this->m_tableItems->removeAllObjects();
string wq = "";
JsonBox::Value json;
json.loadFromString(this->m_playerData->m_skill.c_str());
JsonBox::Array jsonArr = json.getArray();
for (int i = 0; i < jsonArr.size(); i++)
{
char* str = (char*)malloc(10 * sizeof(char));
OzgCCUtility::itoa(jsonArr[i].getInt(), str);
wq.append(str);
if(i + 1 < jsonArr.size())
wq.append(", ");
free(str);
}
if((int)wq.length() > 0)
{
CppSQLite3Query query = this->m_db->execQuery(CCString::createWithFormat(SKILL_QUERY, wq.c_str())->getCString());
while(!query.eof())
{
RPGSkillBtnData *skill = RPGSkillBtnData::create();
skill->m_dataId = query.getIntField("id");
skill->m_name = query.getStringField("name_cns");
skill->m_MP = query.getIntField("mp");
skill->m_skillAttack = query.getIntField("skill_attack");
skill->m_type = query.getIntField("type");
skill->m_attr = query.getIntField("attr");
skill->m_enabled = true;
//不能使用技能的情况
if(this->m_playerData->m_MP <= 0 || this->m_playerData->m_HP <= 0)
skill->m_enabled = false;
else if(this->m_playerData->m_MP < skill->m_MP)
skill->m_enabled = false;
this->m_tableItems->addObject(skill);
query.nextRow();
}
query.finalize();
}
tableView->reloadData();
//加载技能数据 end
//.........这里部分代码省略.........