本文整理汇总了C++中CCLayerColor::retain方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::retain方法的具体用法?C++ CCLayerColor::retain怎么用?C++ CCLayerColor::retain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayerColor
的用法示例。
在下文中一共展示了CCLayerColor::retain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool GameScene::init()
{
if ( !CCLayer::init() )
{
return false;
}
// Variables de tamanyo
CCSize vs = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// Layer con los botones al hacer pause
_layerPause = CCLayerColor::create(ccc4(255,255,255,0));
_layerPause->setContentSize(CCSizeMake(350, 100));
_layerPause->ignoreAnchorPointForPosition(false);
_layerPause->setAnchorPoint(ccp(0.5, 0.5));
_layerPause->setPosition(ccp(vs.width/2, vs.height/2));
_layerPause->retain();
CCMenuItem* button_resume = CCMenuItemImage::create("btn_resume.png", "btn_resume_h.png", this, menu_selector(GameScene::menuResumeCallback));
button_resume->setPosition(ccp(50, 50));
CCMenuItem* button_restart = CCMenuItemImage::create("btn_restart.png", "btn_restart_h.png", this, menu_selector(GameScene::menuRestartCallback));
button_restart->setPosition(ccp(175, 50));
CCMenuItem* button_exit = CCMenuItemImage::create("btn_exit.png", "btn_exit_h.png", this, menu_selector(GameScene::menuExitCallback));
button_exit->setPosition(ccp(300, 50));
CCMenu* menu_pause = CCMenu::create(button_resume, button_restart, button_exit, NULL);
menu_pause->setPosition(ccp(0,0));
_layerPause->addChild(menu_pause);
// Layer que se muestra al terminar la carrera
_layerEnd = CCLayerColor::create(ccc4(0,0,0,0));
_layerEnd->setContentSize(CCSizeMake(225, 225));
_layerEnd->ignoreAnchorPointForPosition(false);
_layerEnd->setAnchorPoint(ccp(0.5, 0.5));
_layerEnd->setPosition(ccp(vs.width/2, vs.height/2));
_layerEnd->retain();
CCMenuItem* button_end_restart = CCMenuItemImage::create("btn_restart.png", "btn_restart_h.png", this, menu_selector(GameScene::menuRestartCallback));
button_end_restart->setPosition(ccp(50, 50));
CCMenuItem* button_end_exit = CCMenuItemImage::create("btn_exit.png", "btn_exit_h.png", this, menu_selector(GameScene::menuExitCallback));
button_end_exit->setPosition(ccp(175, 50));
CCMenu* menu_end = CCMenu::create(button_end_restart, button_end_exit, NULL);
menu_end->setPosition(ccp(0,0));
CCLayerColor* layerTime = CCLayerColor::create(ccc4(255,255,255,255));
layerTime->setContentSize(CCSizeMake(225, 100));
layerTime->ignoreAnchorPointForPosition(false);
layerTime->setAnchorPoint(ccp(0.5, 0.5));
layerTime->setPosition(ccp(112.5, 175));
layerTime->retain();
_labelTimeEnd = CCLabelTTF::create("Time:\n0:00:000", "fonts/FrancoisOne.ttf", 30, CCSizeMake(225, 100), kCCTextAlignmentCenter);
_labelTimeEnd->setColor(ccc3(0,0,0));
_labelTimeEnd->setPosition(ccp(112.5, 50));
layerTime->addChild(_labelTimeEnd);
_layerEnd->addChild(menu_end);
_layerEnd->addChild(layerTime);
// Boton de pause (menu)
CCMenuItem* button_pause = CCMenuItemImage::create("btn_pause.png", "btn_pause_h.png", this, menu_selector(GameScene::menuPauseCallback));
button_pause->setPosition(ccp(75, vs.height - 75));
CCMenu* menu = CCMenu::create(button_pause, NULL);
menu->setPosition(ccp(0,0));
// Velocidad
CCString* stringVel = CCString::createWithFormat("%d km/h", (int)_vel);
_labelVel = CCLabelTTF::create(stringVel->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelVel->setColor(ccc3(255,255,255));
_labelVel->setPosition(ccp(vs.width - 72, 50));
// Distancia
CCString* stringDist = CCString::createWithFormat("%d m", (int)_dist);
_labelDist = CCLabelTTF::create(stringDist->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelDist->setColor(ccc3(255,255,255));
_labelDist->setPosition(ccp(72, 50));
// Tiempo
int hs = _time/3600000;
int mins = (_time%3600000)/60000;
int ss = ((_time%3600000)%60000)/1000;
int ms = ((_time%3600000)%60000)%1000;
CCString* stringTime = CCString::createWithFormat("%d:%02d:%03d", mins, ss, ms);
_labelTime = CCLabelTTF::create(stringTime->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelTime->setColor(ccc3(255,255,255));
_labelTime->setPosition(ccp(vs.width - 72, vs.height - 50));
// Click to start
_labelStart = CCLabelTTF::create("Click to Start", "fonts/FrancoisOne.ttf", 50, CCSizeMake(200, 200), kCCTextAlignmentCenter);
_labelStart->setColor(ccc3(255,255,255));
_labelStart->setPosition(ccp(vs.width/2, vs.height/2));
_labelStart->retain();
// Hierba
//.........这里部分代码省略.........