void CharsetRendererV3::setColor(byte color) { bool useShadow = false; _color = color; // FM-TOWNS version of Loom uses old color method as well if ((_vm->_game.version >= 2) && ((_vm->_game.features & GF_16COLOR) || (_vm->_game.id == GID_LOOM && _vm->_game.version == 3))) { useShadow = ((_color & 0xF0) != 0); _color &= 0x0f; } else if (_vm->_game.features & GF_OLD256) { useShadow = ((_color & 0x80) != 0); _color &= 0x7f; } else useShadow = false; #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE if (_vm->_game.platform == Common::kPlatformFMTowns) { _color = (_color & 0x0f) | ((_color & 0x0f) << 4); if (_color == 0) _color = 0x88; } #endif enableShadow(useShadow); translateColor(); }
void Gameboard::addScoreLabel(uint32_t _Score, const Vec2 & _Position) { std::string scoreText; ScoreToString(_Score, scoreText); CCLOG("Score %d == %s", _Score, scoreText.c_str()); auto label = Label::createWithBMFont("fonts/overlay.fnt", scoreText, TextHAlignment::CENTER); label->setColor(Color3B::YELLOW); label->enableShadow(Color4B::BLACK, Size(2.f, 2.f), 5); addChild(label, TopmostLevel); label->setPosition(_Position); auto dissapear = Spawn::create( MoveBy::create(SlowSpeed, Vec2(0, 20)), FadeTo::create(SlowSpeed, 64), ScaleBy::create(SlowSpeed, 0.3f), nullptr); auto seq = Sequence::create( DelayTime::create(DissapearSpeed), dissapear, RemoveSelf::create(true), nullptr); label->runAction(seq); }
void Text::copySpecialProperties(Widget *widget) { Text* label = dynamic_cast<Text*>(widget); if (label) { setFontName(label->_fontName); setFontSize(label->getFontSize()); setTextColor(label->getTextColor()); setString(label->getString()); setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled); setTextHorizontalAlignment(label->_labelRenderer->getHorizontalAlignment()); setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment()); setTextAreaSize(label->_labelRenderer->getDimensions()); setContentSize(label->getContentSize()); LabelEffect effectType = label->getLabelEffectType(); if (effectType == LabelEffect::GLOW) { enableGlow(label->getEffectColor()); } else if (effectType == LabelEffect::OUTLINE) { enableOutline(label->getEffectColor(),label->getOutlineSize()); } if (label->isShadowEnabled()) { enableShadow(label->getShadowColor(),label->getShadowOffset(),label->getShadowBlurRadius()); } } }
void Label::setFontDefinition(const FontDefinition& textDefinition) { _systemFont = textDefinition._fontName; _systemFontSize = textDefinition._fontSize; _hAlignment = textDefinition._alignment; _vAlignment = textDefinition._vertAlignment; setDimensions(textDefinition._dimensions.width, textDefinition._dimensions.height); Color4B textColor = Color4B(textDefinition._fontFillColor); textColor.a = textDefinition._fontAlpha; setTextColor(textColor); #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) if (textDefinition._stroke._strokeEnabled) { CCLOGERROR("Currently only supported on iOS and Android!"); } _outlineSize = 0.f; #else if (textDefinition._stroke._strokeEnabled && textDefinition._stroke._strokeSize > 0.f) { Color4B outlineColor = Color4B(textDefinition._stroke._strokeColor); outlineColor.a = textDefinition._stroke._strokeAlpha; enableOutline(outlineColor, textDefinition._stroke._strokeSize); } #endif if (textDefinition._shadow._shadowEnabled) { enableShadow(Color4B(0, 0, 0, 255 * textDefinition._shadow._shadowOpacity), textDefinition._shadow._shadowOffset, textDefinition._shadow._shadowBlur); } }
void CCRichLabelTTF::_updateWithTextDefinition(ccFontDefinition & textDefinition, bool mustUpdateTexture) { m_tDimensions = CCSizeMake(textDefinition.m_dimensions.width, textDefinition.m_dimensions.height); m_hAlignment = textDefinition.m_alignment; m_vAlignment = textDefinition.m_vertAlignment; m_pFontName = new std::string(textDefinition.m_fontName); m_fFontSize = textDefinition.m_fontSize; // shadow if ( textDefinition.m_shadow.m_shadowEnabled ) { enableShadow(textDefinition.m_shadow.m_shadowOffset, textDefinition.m_shadow.m_shadowOpacity, textDefinition.m_shadow.m_shadowBlur, false); } // stroke if ( textDefinition.m_stroke.m_strokeEnabled ) { enableStroke(textDefinition.m_stroke.m_strokeColor, textDefinition.m_stroke.m_strokeSize, false); } // fill color setFontFillColor(textDefinition.m_fontFillColor, false); if (mustUpdateTexture) updateTexture(); }
void GameOverScene::AddLabels() { std::string mainCaption = ""; switch (m_type) { case FAIL: mainCaption = LABEL_FAIL; break; case TIME_OVER: mainCaption = LABEL_TIME_OVER; break; case SUCCESS: mainCaption = LABEL_SUCCESS; break; } auto gameOverLabel = Label::createWithSystemFont(mainCaption, "Arial", MAIN_LABEL_FONT_SIZE); gameOverLabel->setPosition(m_origin.x + m_visibleSize.width / 2.0, m_origin.y + m_visibleSize.height / 2.0 + MAIN_LABEL_OFFSET_Y); gameOverLabel->enableShadow(GAMEOVER_SHADOW_COLOR); std::string results = "Score : " + std::to_string(m_points) + " x "; float multiplier = 1.0f; if (m_type == EndType::SUCCESS) { multiplier = 1 + (m_maxSeconds - m_seconds) / 10.0; } std::stringstream ss; ss << std::fixed << std::setprecision(1) << multiplier; std::string multStr(ss.str()); results += multStr + " = "; m_points *= multiplier; results += std::to_string(m_points); if (m_type == EndType::SUCCESS) { int seconds = m_seconds % 60; std::string minuteString = "0" + std::to_string(m_seconds / 60), secondString = seconds > 9 ? std::to_string(seconds) : "0" + std::to_string(seconds); results += "\nTime - " + minuteString + ":" + secondString; } auto labelResults = Label::createWithSystemFont(results, "Arial", SCORE_LABEL_FONT_SIZE); labelResults->setPosition(m_origin.x + m_visibleSize.width / 2.0, m_origin.y + m_visibleSize.height / 2.0 + SCORE_LABEL_OFFSET_Y); labelResults->enableShadow(SCORE_SHADOW_COLOR); this->addChild(gameOverLabel); this->addChild(labelResults); }
static inline Label* makeText(string text, float size=28.0f) { auto lbl = Label::createWithTTF(text, NORMAL_TTF, size); lbl->setPositionX(10); lbl->setAnchorPoint(Point(0, 1)); lbl->setHorizontalAlignment(TextHAlignment::LEFT); lbl->enableShadow(Color4B::BLACK, Size(0.5f, -1.0f), 1); return lbl; }
void Label::setFontDefinition(const FontDefinition& textDefinition) { _fontDefinition = textDefinition; #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) if (_fontDefinition._stroke._strokeEnabled) { CCLOGERROR("Currently only supported on iOS and Android!"); } _fontDefinition._stroke._strokeEnabled = false; #endif if (_fontDefinition._shadow._shadowEnabled) { _fontDefinition._shadow._shadowEnabled = false; enableShadow(Color4B(0,0,0,255 * _fontDefinition._shadow._shadowOpacity),_fontDefinition._shadow._shadowOffset,_fontDefinition._shadow._shadowBlur); } }
bool LabelTest::init() { BackLayer::init(); Size visibleSize = Director::getInstance()->getVisibleSize(); //auto num = Director::getInstance()->getOpenGLView()->getReferenceCount(); //log("reference count:%d", num); auto layer = LayerColor::create(Color4B::GRAY); addChild(layer); //LabelBMFont的创建 auto labelBMFont = Label::createWithBMFont("bitmapFontTest.fnt", "A bit map font Label"); labelBMFont->setPosition(Vec2(visibleSize.width / 2, visibleSize.height - 100)); layer->addChild(labelBMFont); //LabelTTF的创建 //方法1:直接通过.ttf文件创建 auto labelTTF1 = Label::createWithTTF("A TTF Label", "fonts/Marker Felt.ttf", 24); labelTTF1->setPosition(Vec2(visibleSize.width / 2, visibleSize.height - 200)); layer->addChild(labelTTF1); //方法2:通过TTFConfig创建 TTFConfig labelConfig; labelConfig.fontFilePath = "fonts/Marker Felt.ttf"; labelConfig.fontSize = 24; auto labelTTF2 = Label::createWithTTF(labelConfig, "A TTF Label from TTFConfig"); labelTTF2->setPosition(Vec2(visibleSize.width / 2, visibleSize.height - 300)); layer->addChild(labelTTF2); //LabelSystemFont的创建 auto labelSystemFont = Label::createWithSystemFont("A SystemFont Label", "Arial", 36); labelSystemFont->setPosition(Vec2(visibleSize.width / 2, visibleSize.height - 400)); layer->addChild(labelSystemFont); //为字体加特效 auto labelTTFEffect = Label::createWithTTF("A TTF Label with effect", "fonts/Marker Felt.ttf", 36); labelTTFEffect->setPosition(Vec2(visibleSize.width / 2, visibleSize.height - 500)); labelTTFEffect->enableShadow(); labelTTFEffect->enableOutline(Color4B::BLACK, 3); layer->addChild(labelTTFEffect); return true; }
void CTimeOSD::show(time_t time_show, bool force) { time_show /= 1000; if (!force && (m_mode == MODE_HIDE || m_time_show == time_show || CScreenSaver::getInstance()->IsRun())) return; m_time_show = time_show; setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0); //use current theme colors paint_bg = true; if (g_settings.infoClockBackground) setColorBody(COL_MENUCONTENT_PLUS_0); else setColorBody(COL_BACKGROUND_PLUS_0); enableShadow(g_settings.infoClockBackground); paint(false); }
bool SplashScene::init() { if (!Layer::init()) return false; Size size = getContentSize(); auto background = Sprite::create(pathToBack); background->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); background->setScaleX(size.width / background->getContentSize().width); background->setScaleY(size.height / background->getContentSize().height); addChild(background, -1); auto label = Label::createWithSystemFont("LOADING. PLEASE WAIT.", "Fixedsys", 45); label->setAnchorPoint(Vec2::ANCHOR_MIDDLE); label->setPosition({ size.width / 2, size.height / 2 }); label->enableShadow(); addChild(label, 0); return true; }
void Label::setLabelEffect(LabelEffect effect,const Color3B& effectColor) { switch (effect) { case cocos2d::LabelEffect::NORMAL: disableEffect(); break; case cocos2d::LabelEffect::OUTLINE: enableOutline(Color4B(effectColor)); break; case cocos2d::LabelEffect::SHADOW: enableShadow(Color4B(effectColor)); break; case cocos2d::LabelEffect::GLOW: enableGlow(Color4B(effectColor)); break; default: break; } }
void Label::setFontDefinition(const FontDefinition& textDefinition) { reset(); _fontDefinition = textDefinition; _fontName = textDefinition._fontName; _fontSize = textDefinition._fontSize; _shadowEnabled = textDefinition._shadow._shadowEnabled; if (_shadowEnabled) { enableShadow(Color4B::BLACK,_fontDefinition._shadow._shadowOffset,_fontDefinition._shadow._shadowBlur); } _textColor = Color4B(_fontDefinition._fontFillColor); _textColorF.r = _textColor.r / 255.0f; _textColorF.g = _textColor.g / 255.0f; _textColorF.b = _textColor.b / 255.0f; _textColorF.a = _textColor.a / 255.0f; _contentDirty = true; }
bool GameOver::init() { if ( !Layer::init() ) { return false; } director = Director::getInstance(); visibleSize = director->getVisibleSize(); Vec2 origin = director->getVisibleOrigin(); auto pauseItem = MenuItemImage::create( "play.png", "play_pressed.png", CC_CALLBACK_1(GameOver::exitPause, this)); pauseItem->setPosition(Vec2(origin.x + visibleSize.width - pauseItem->getContentSize().width / 2, origin.y + pauseItem->getContentSize().height / 2)); auto menu = Menu::create(pauseItem, NULL); menu->setPosition(Vec2::ZERO); this->addChild(menu, 1); auto bg = Sprite::create("background.png"); bg->setAnchorPoint(Vec2()); bg->setPosition(0,0); this->addChild(bg, -1); auto label = Label::createWithTTF("Game Over", "fonts/Marker Felt.ttf", 96); label->enableOutline(Color4B(255, 0, 0, 100),6); label->enableGlow(Color4B(255, 0, 0, 255)); label->enableShadow(); label->setPosition(origin.x + visibleSize.width/2, origin.y + visibleSize.height /2); this->addChild(label, 1); auto label2 = Label::createWithSystemFont("Your score is", "Arial", 48); label2->setPosition(origin.x + visibleSize.width/2,origin.y + visibleSize.height /2.5); this->addChild(label2, 1); char scoreText[32]; int score = UserDefault::getInstance()->getIntegerForKey("score",0); sprintf(scoreText, "%d", score); auto label3 = Label::createWithBMFont("font.fnt", scoreText); label3->setPosition(origin.x + visibleSize.width/2,origin.y + visibleSize.height /3.5); this->addChild(label3, 1); return true; }
void MenuLayer::run() { Size visibleSize = Director::getInstance()->getVisibleSize(); Sprite* background = Sprite::create("../Resources/background.jpg"); background->setPosition(visibleSize.width/2,visibleSize.height/2); background->setOpacity(0); auto fadeIn_my_background = FadeIn::create(3.0f); this->addChild(background,0); auto seq_background = Sequence::create(fadeIn_my_background, nullptr); background->runAction(seq_background); //////////////////////////////////// auto my_title = Label::createWithTTF("John's Dream World", "../Resources/fonts/Verdana Bold.ttf", 66); my_title->setPosition(visibleSize.width/2,visibleSize.height/1.5); my_title->setOpacity(0); my_title->enableShadow(Color4B::BLACK, Size(2 ,-2), 0); auto fadeIn_my_title = FadeIn::create(3.0f); this->addChild(my_title,0); auto seq_title = Sequence::create(fadeIn_my_title, nullptr); my_title->runAction(seq_title); //////////////////////////////////// auto button = Button::create("start_menu_normal.png", "start_menu_clicked.png", "start_menu_clicked.png"); button->addClickEventListener(CC_CALLBACK_0(MenuLayer::startGame, this)); button->setPosition(Vec2(visibleSize.width/2,visibleSize.height/3)); button->setOpacity(0); auto fadeIn_my_button = FadeIn::create(5.0f); this->addChild(button); auto seq_button = Sequence::create(fadeIn_my_button, nullptr); button->runAction(seq_button); }
void CharsetRendererPCE::setColor(byte color) { _vm->setPCETextPalette(color); _color = 15; enableShadow(true); }
// on "init" you need to initialize your instance bool HelloWorld::init() { if ( !Layer::init() ) { return false; } auto size = Director::getInstance()->getWinSize(); auto layer = LayerColor::create(Color4B::GRAY); this->addChild(layer); auto label = Label::createWithTTF("Shadow", "fonts/Marker Felt.ttf", 40); label->setPosition(Vec2(size.width/2, size.height/3*2)); this->addChild(label); label->enableShadow(Color4B::RED, Size(5,5), 0); auto label2 = Label::createWithTTF("Shadow & Outline", "fonts/Marker Felt.ttf", 40); label2->setPosition(Vec2(size.width/2, size.height/3)); this->addChild(label2); label2->enableShadow(Color4B::RED, Size(10,-10), 0); label2->enableOutline(Color4B::BLACK, 5); /* TTFConfig config; config.fontFilePath = "fonts/Marker Felt.ttf"; config.fontSize = 40.0f; config.glyphs = GlyphCollection::DYNAMIC; config.outlineSize = 1; config.customGlyphs = nullptr; config.distanceFieldEnabled = false; auto label = Label::createWithTTF(config, "True Type Font"); label->setPosition(size/2); this->addChild(label); label->setColor(Color3B::RED); */ /* sec = 0; std::string secString = StringUtils::toString(sec); auto label = Label::createWithSystemFont(secString, "Arial", 40); label->setPosition(size/2); this->addChild(label); this->schedule([=](float dt) { sec++; std::string secString = StringUtils::toString(sec); label->setString(secString); }, 1.0f, "myCallbackKey"); */ /* auto sprite = Sprite::create("res/run_01.png"); sprite->setPosition(size/2); this->addChild(sprite); sprite->setScale(0.2f); auto cache = AnimationCache::getInstance(); cache->addAnimationsWithFile("res/run_animation.plist"); auto animation = cache->getAnimation("run"); auto action = Animate::create(animation); sprite->runAction(action); */ /* auto sprite = Sprite::create("res/run_01.png"); sprite->setPosition(Vec2(size.width/2, size.height)); sprite->setAnchorPoint(Vec2(0.5f, 0.0f)); this->addChild(sprite); sprite->setScale(0.2f); auto drop = MoveTo::create(3.0f, Vec2(size.width/2, 0)); auto ease = EaseOut::create(drop, 10.1f); sprite->runAction(ease); */ //auto origin = Director::getInstance()->getVisibleOrigin(); /* { auto sprite = Sprite::create("res/run_01.png"); sprite->setPosition(Vec2(300, 200)); this->addChild(sprite); sprite->setScale(0.2f); } { auto sprite = Sprite::create("res/run_01.png"); sprite->setPosition(Vec2(400, 200)); this->addChild(sprite); sprite->setScale(0.2f); sprite->setColor(Color3B(255,0,0)); } int i = 100; std::string int_string = StringUtils::toString(i); float j = 123.4f; std::string float_string = StringUtils::toString(j); CCLOG("i=%s, j=%s", int_string.c_str(), float_string.c_str()); */ /* { auto sprite = Sprite::create("res/run_01.png"); sprite->setPosition(Vec2(500, 200)); this->addChild(sprite); sprite->setScale(0.2f); sprite->setScaleY(0.2f*0.5f); } { auto sprite = Sprite::create("res/run_01.png"); sprite->setPosition(Vec2(650, 200)); this->addChild(sprite); sprite->setScale(0.2f); sprite->setScale(0.2f*2.0f, 0.2f*0.5f); } */ /* auto delay = DelayTime::create(2.0f); auto move = MoveBy::create(2.0f, Vec2(100, 0)); auto rotate = RotateBy::create(2.0f, 360.0f); auto fade = FadeOut::create(2.0f); auto spawn = Spawn::create(rotate, fade, nullptr); auto action = Sequence::create(move, spawn, nullptr); //auto action = Sequence::create(sequence, sequence->reverse(), nullptr); //auto action = RepeatForever::create(rotate); sprite->runAction(action); */ /*auto func = CallFunc::create([](){ CCLOG("finished actions"); });*/ //auto func = CallFunc::create(CC_CALLBACK_0(HelloWorld::finishedAction, this)); /*auto func = CallFuncN::create([=](Ref* sender){ CCLOG("callback"); Sprite* sprite = dynamic_cast<Sprite*>(sender); sprite->runAction(move->reverse()); }); auto action = Sequence::create(move, rotate, func, nullptr); sprite->runAction(action); */ // texture atlas /* auto cache = SpriteFrameCache::getInstance(); cache->addSpriteFramesWithFile("res/running.plist"); auto sprite = Sprite::createWithSpriteFrameName("run_01.png"); sprite->setPosition(size/2); sprite->setScale(0.2f); this->addChild(sprite); */ // batch node /*auto batchNode = SpriteBatchNode::create("res/run_01.png"); this->addChild(batchNode); for (int i=0; i<300; i++) { auto sprite = Sprite::createWithTexture(batchNode->getTexture()); sprite->setScale(0.2f); float x = CCRANDOM_0_1() * size.width; float y = CCRANDOM_0_1() * size.height; sprite->setPosition(Vec2(x,y)); batchNode->addChild(sprite); } */ //sprite->setColor(Color3B(255, 0, 0)); /* Rect rect = sprite->getBoundingBox(); Size contentSize = sprite->getContentSize(); CCLOG("rect size=%f,%f, content size=%f,%f", rect.size.width, rect.size.height, contentSize.width, contentSize.height); */ /* auto sprite3d = Sprite3D::create("res/girl.c3b"); sprite3d->setPosition(Vec2(size.width/2, 100)); this->addChild(sprite3d); auto animation3d = Animation3D::create("res/girl.c3b"); auto animate3d = Animate3D::create(animation3d); auto repeat = RepeatForever::create(animate3d); sprite3d->runAction(repeat); sprite3d->setPositionX(size.width); auto move1 = MoveBy::create(5.0f, Vec2(-size.width, 0)); auto move2 = MoveBy::create(5.0f, Vec2(size.width, 0)); auto seq = Sequence::create(move1, move2, NULL); auto loop = RepeatForever::create(seq); sprite3d->runAction(loop); */ /*{ auto rect = Rect::ZERO; rect.size = sprite->getContentSize(); Vector<AnimationFrame*> frames; // animation for (int i=1; i<=8; i++) { std::string name = StringUtils::format("res/run_%02d.png", i); auto frame = SpriteFrame::create(name.c_str(), rect); ValueMap info; auto animationFrame = AnimationFrame::create(frame, i, info); frames.pushBack(animationFrame); } auto animation = Animation::create(frames, 0.1f); animation->setDelayPerUnit(0.1f); animation->setRestoreOriginalFrame(true); animation->setLoops(-1); auto action = Animate::create(animation); sprite->runAction(action); }*/ /*{ // animation auto animation = Animation::create(); for (int i=1; i<=8; i++) { std::string name = StringUtils::format("res/run_%02d.png", i); animation->addSpriteFrameWithFile(name.c_str()); } animation->setDelayPerUnit(0.1f); animation->setRestoreOriginalFrame(true); animation->setLoops(-1); auto action = Animate::create(animation); sprite->runAction(action); }*/ // drawing a shape /* static const Color4F WHITE; static const Color4F YELLOW; static const Color4F BLUE; static const Color4F GREEN; static const Color4F RED; static const Color4F MAGENTA; static const Color4F BLACK; static const Color4F ORANGE; static const Color4F GRAY; */ /* auto size = Director::getInstance()->getWinSize(); auto origin = Director::getInstance()->getVisibleOrigin(); auto draw = DrawNode::create(); this->addChild(draw); //draw->drawDot(Vec2(size/2), 10.0f, Color4F::WHITE); */ //draw->drawLine(Vec2(300, 200), Vec2(600, 200), Color4F::WHITE); //draw->drawSegment(Vec2(300, 100), Vec2(600, 100), 10.0f, Color4F::WHITE); // drawing circles //draw->drawCircle(Vec2(300, size.height/2), 50.0f, 1.0f, 10, true, 1.0f, 1.0f, Color4F::WHITE); //draw->drawCircle(Vec2(450, size.height/2), 50.0f, 1.0f, 100, false, 1.0f, 1.0f, Color4F::WHITE); //draw->drawSolidCircle(Vec2(600, size.height/2), 50.0f, 1.0f, 100, 1.0f, 1.0f, Color4F::WHITE); // drawing rects //draw->drawRect(Vec2(240, 100), Vec2(340,200), Color4F::WHITE); //draw->drawSolidRect(Vec2(480, 100), Vec2(580, 200), Color4F::WHITE); // drawing triangle //draw->drawTriangle(Vec2(380,100), Vec2(480, 200), Vec2(580, 100), Color4F::WHITE); // Bezier curve // 第4引き数の数値 segment はカーブの滑らかさ //draw->drawQuadBezier(Vec2(240, 200), Vec2(480, 320), Vec2(720, 200), 24, Color4F::WHITE); //draw->drawCubicBezier(Vec2(240, 100), Vec2(240, 200), Vec2(720, 200), Vec2(720, 100), 24, Color4F::WHITE); // draw a polygon /* std::vector<Vec2>verts; verts.push_back(Vec2(380,100)); verts.push_back(Vec2(380,200)); verts.push_back(Vec2(480,250)); verts.push_back(Vec2(580,200)); verts.push_back(Vec2(580,100)); verts.push_back(Vec2(480,50)); draw->drawPolygon(&verts[0], verts.size(), Color4F::RED, 5.0f, Color4F::GREEN); */ /* { auto points = PointArray::create(10); draw->drawCatmullRom(points, 10, Color4F::ORANGE); } */ /* { _points = new PointArray(); _points->initWithCapacity(10000); //_points->addControlPoint(Vec2(0,size.height/2)); //_points->addControlPoint(Vec2(size.width/2,size.height)); //_points->addControlPoint(Vec2(size.width,size.height/2)); //draw->drawCardinalSpline(_points, 10.0f, 100, Color4F::ORANGE); _draw = draw; auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [](Touch* touch, Event* event){ return true; }; listener->onTouchMoved = [&](Touch* touch, Event* event){ //if (_points->count()>=1000) { // return; //} _points->addControlPoint(touch->getLocation()); //if (_points->count()>3) { // _draw->drawCatmullRom(_points, 100, Color4F::RED); _draw->drawCardinalSpline(_points, 10.0f, 100, Color4F::ORANGE); //} }; this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); } */ return true; }
void GameInfoScene::createGamePanel() { Size visibleSize = Director::getInstance()->getVisibleSize(); auto bgcolor = LayerColor::create(GameInfos[game].color, visibleSize.width, visibleSize.height); bgcolor->setPosition(Point::ZERO); addChild(bgcolor); addChild(BackgroundWidget::createWithoutBackground()); auto hooker = TopAnchor::create(); addChild(hooker, 1); addChild(Vignette::create()); auto gamelogo = MAKESPRITE(GameInfos[game].logo); hooker->addChild(gamelogo); gamelogo->setPosition(VCP(0.5f, 0.70f)); gamelogo->runAction(RepeatForever::create(Sequence::createWithTwoActions( ScaleTo::create(3.0f, 1.05f), ScaleTo::create(3.0f, 1.0f) ))); auto hookerMenu = Menu::create(); hookerMenu->setPosition(Point::ZERO); hooker->addChild(hookerMenu); #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) auto btnMenu = MAKEBUTTON("btnBackUp", "btnBackDn", GameInfoScene::menuCloseCallback); btnMenu->setPosition(VCP(0.03f, 0.95f)); btnMenu->setAnchorPoint(Point(0, 1.0f)); btnMenu->setScale(1.3f); hookerMenu->addChild(btnMenu); auto gems = GemsLayer::create(); gems->setAnchorPoint(Point(1, 1)); gems->setPosition(VCP(0.97f, 0.95f)); hooker->addChild(gems); #endif auto pMenu = Menu::create(); pMenu->setPosition(Point::ZERO); addChild(pMenu, 1); auto episodetitle = Label::createWithTTF(LS(GameInfos[game].title), NORMAL_TTF, 60.0f); episodetitle->setHorizontalAlignment(TextHAlignment::CENTER); episodetitle->setPosition(CP(0.5f, 0.45f)); addChild(episodetitle); auto unlocktext = Label::createWithTTF(LS(GameInfos[game].description), NORMAL_TTF, 38.0f); unlocktext->setHorizontalAlignment(TextHAlignment::CENTER); unlocktext->setPosition(CP(0.5f, 0.30f)); addChild(unlocktext); #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) if (GameSettings::Gems >= 1) { //show buy button auto btnBuy = MakeButton("btnGreenUp", "btnGreenDn", LS("PlayFor1Gem"), 42.0f, CC_CALLBACK_1(GameInfoScene::btnBuyPressed, this)); btnBuy->setPosition(CP(0.5f, 0.05f)); btnBuy->setAnchorPoint(Point(0.5f, 0)); pMenu->addChild(btnBuy); } else { auto errortext = Label::createWithTTF(LS("NotEnoughGems"), FANCY_TTF, 42.0f); errortext->setColor(Color3B::RED); errortext->enableShadow(); errortext->setPosition(CP(0.5f, 0.05f)); addChild(errortext); } #else auto btnBuy = MakeButton("btnGreenUp", "btnGreenDn", LS("Play"), 42.0f, CC_CALLBACK_1(GameInfoScene::btnBuyPressed, this)); btnBuy->setPosition(CP(0.5f, 0.05f)); btnBuy->setAnchorPoint(Point(0.5f, 0)); pMenu->addChild(btnBuy); #endif }
//init()より継承 bool MainScene::initWithLevel(int level) { if (!Layer::init()) { return false; } //ウィンドウサイズを取得 auto winSize = Director::getInstance()->getWinSize(); // this->scheduleUpdate(); //背景を描画 auto background = Sprite::create("background.png"); background->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); // auto parallaxNode = ParallaxNode::create(); this->addChild(parallaxNode); //ステージを作成(Stageクラスから呼び出し) auto stage = Stage::createWithLevel(level); this->setStage(stage); //stageの幅を取得 auto mapWidth = stage->getTiledMap()->getContentSize().width; //バックグラウンドの幅を取得 auto backgroundWidth = background->getContentSize().width; // parallaxNode->addChild(background, 0, Vec2((backgroundWidth - winSize.width) / mapWidth, 0), Vec2::ZERO); this->setParallaxNode(parallaxNode); // 物体が衝突したことを検知するEventListener auto contactListener = EventListenerPhysicsContact::create(); contactListener->onContactBegin = [this](PhysicsContact& contact) { auto otherShape = contact.getShapeA()->getBody() == _stage->getPlayer()->getPhysicsBody() ? contact.getShapeB() : contact.getShapeA(); auto body = otherShape->getBody(); auto category = body->getCategoryBitmask(); auto layer = dynamic_cast<TMXLayer *>(body->getNode()->getParent()); //衝突した物体が何かを判別し、条件によって行動を起こす //categoryとその後のものを比較 //なぜ&なのかはhttp://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1110789081参照 if (category & static_cast<int>(Stage::TileType::ENEMY)) { // ゲームオーバー。ゲームオーバーメソッドに飛ばす this->onGameOver(); } else if (category & (int)Stage::TileType::COIN) { // コイン layer->removeChild(body->getNode(), true); //コイン効果音 CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(AudioUtils::getFileName("coin").c_str()); //コイン個数を増加させる _coin += 1; } return true; }; // this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(contactListener, this); //ステージレイヤーを追加 this->addChild(stage); // タッチしたときにタッチされているフラグをオンにする auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [this](Touch *touch, Event *event) { this->setIsPress(true); return true; }; listener->onTouchEnded = [this](Touch *touch, Event *event) { this->setIsPress(false); }; listener->onTouchCancelled = [this](Touch *touch, Event *event) { this->setIsPress(false); }; //イベントリスナーの優先順位を定義 this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); // ステージの背景スプライト表示 auto stageBackground = Sprite::create("stage_ui.png"); stageBackground->setPosition(Vec2(stageBackground->getContentSize().width / 2, winSize.height - stageBackground->getContentSize().height / 2.0)); this->addChild(stageBackground); //ナンバーを表示 auto stageLabel = Label::createWithCharMap("numbers.png", 16, 18, '0'); stageLabel->setString(StringUtils::format("%d", _stage->getLevel() + 1)); stageLabel->setPosition(Vec2(60, winSize.height - 22)); this->addChild(stageLabel); // 制限時間を表示 auto secondLabel = Label::createWithCharMap("numbers.png", 16, 18, '0'); secondLabel->setPosition(Vec2(300, winSize.height - 10)); secondLabel->enableShadow(); this->addChild(secondLabel); this->setSecondLabel(secondLabel); // コインの背景 auto coin = Sprite::create("coin.png"); coin->setPosition(Vec2(160, winSize.height - 15)); this->addChild(coin); //数字を表示 auto label = Label::createWithCharMap("numbers.png", 16, 18, '0'); this->addChild(label); label->setPosition(Vec2(200, winSize.height - 10)); label->enableShadow(); this->setCoinLabel(label); return true; }
bool MainScene::init(){ if(!Layer::init()){ return false; } auto winSize = Director::getInstance()->getWinSize(); //TJA読み込み Tja tja = Tja(); tja.loadTja(); _noteTimes = tja.getNoteTimes(); auto background = Sprite::create("background.png"); background->setPosition(Vec2(winSize.width / 2.0, winSize.height / 2.0)); this->addChild(background); auto scoreLabel = Label::createWithSystemFont(StringUtils::toString(_score), "Marker Felt", FONT_SIZE); scoreLabel->enableShadow(Color4B::BLACK, Size(0.5, 0.5), 3); scoreLabel->enableOutline(Color4B::BLACK, 1.5); scoreLabel->setPosition(Vec2(winSize.width / 2 * 1.5, winSize.height - 40)); this->setScoreLabel(scoreLabel); this->addChild(scoreLabel); auto scoreLabelHeader = Label::createWithSystemFont("SCORE", "Marker Felt", FONT_SIZE); scoreLabelHeader->setPosition(Vec2(winSize.width / 2 * 1.5, winSize.height - 20)); this->addChild(scoreLabelHeader); int second = static_cast<int>(_second); auto secondLabel = Label::createWithSystemFont(StringUtils::toString(second), "Marker Felt", FONT_SIZE); secondLabel->setPosition(Vec2(winSize.width / 2, winSize.height - 40)); this->setSecondLabel(secondLabel); this->addChild(secondLabel); auto secondLabelHeader = Label::createWithSystemFont("TIME", "Marker Felt", FONT_SIZE); secondLabelHeader->setPosition(Vec2(winSize.width / 2, winSize.height - 20)); this->addChild(secondLabelHeader); //当たり判定 auto hitDetection = DrawNode::create(); hitDetection->drawDot(INIT_PLAYER_POSITION, 10.0f, Color4F(1.0f, 6.0f, 5.0f, 1.0f)); this->addChild(hitDetection); auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [this](Touch *touch, Event *event){ this->setTouchLocation(touch->getLocation()); return true; }; listener->onTouchMoved = [this](Touch *touch, Event *event){ SwipeDirection swipeDirection = this->getSwipeDirection(touch); if(swipeDirection != SwipeDirection::NONE){ // if(swipeDirection == SwipeDirection::RIGHT){ // if(_isSwipeTimeRight <= 0){ // this->initSwipeTime(); // this->setIsSwipeTimeRight(SWIPE_WAIT_TIME); // //音 // CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("dong.mp3"); // //エフェクト // auto explosion = ParticleFire::create(); // explosion->setPosition(INIT_PLAYER_POSITION); // explosion->setDuration(0.0001); // this->addChild(explosion); // explosion->setAutoRemoveOnFinish(true); // 表示が終わったら自分を親から削除! // } // } // else if(swipeDirection == SwipeDirection::LEFT){ // if(_isSwipeTimeLeft <= 0){ // this->initSwipeTime(); // this->setIsSwipeTimeLeft(SWIPE_WAIT_TIME); // //音 // CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("dong.mp3"); // //エフェクト // auto explosion = ParticleFire::create(); // explosion->setPosition(INIT_PLAYER_POSITION); // explosion->setDuration(0.0001); // explosion->setAutoRemoveOnFinish(true); // 表示が終わったら自分を親から削除! // this->addChild(explosion); // } // } if(swipeDirection == SwipeDirection::UP){ if(_isSwipeTimeUp <= 0){ this->initSwipeTime(); this->setIsSwipeTimeUp(SWIPE_WAIT_TIME); //音 CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("dong.mp3"); //エフェクト auto explosion = ParticleFire::create(); explosion->setPosition(INIT_PLAYER_POSITION); explosion->setDuration(0.0001); explosion->setAutoRemoveOnFinish(true); // 表示が終わったら自分を親から削除! this->addChild(explosion); } } else if(swipeDirection == SwipeDirection::DOWN){ if(_isSwipeTimeDown <= 0){ this->initSwipeTime(); this->setIsSwipeTimeDown(SWIPE_WAIT_TIME); //音 CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("dong.mp3"); //エフェクト auto explosion = ParticleFire::create(); explosion->setPosition(INIT_PLAYER_POSITION); explosion->setDuration(0.0001); explosion->setAutoRemoveOnFinish(true); // 表示が終わったら自分を親から削除! this->addChild(explosion); } } this->setTouchLocation(touch->getLocation()); } }; Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); //this->scheduleUpdate(); schedule(schedule_selector(MainScene::test), SFRAME_RATE); return true; }
bool SelectScene::init() { if ( !Layer::init() ) { return false; } //Dierctorを取り出し auto director = Director::getInstance(); //画像サイズ取り出し auto winSize = director->getWinSize(); //背景色 auto background = Sprite::create("select_background.png"); background->setPosition(Vec2(winSize.width / 2.0, winSize.height / 2.0)); this->addChild(background); //ロゴ表示 auto titleLogo = Sprite::create("select_logo.png"); titleLogo->setScale(1.3f); titleLogo->setAnchorPoint(Vec2::ANCHOR_MIDDLE_TOP); titleLogo->setPosition(Vec2(winSize.width /2.0, winSize.height - 10)); this->addChild(titleLogo); //説明の半透明枠を表示 auto menuground = LayerColor::create(Color4B(51,75,112,200), winSize.width - 50, winSize.height - 320); this->addChild(menuground); menuground->ignoreAnchorPointForPosition(false); //menuground->setAnchorPoint(Vec2::ANCHOR_MIDDLE); menuground->setPosition(Vec2(winSize.width /2.0, winSize.height/2.0)); //スコア表示 int i = 1; for (; i <= MAX_STAGE; i++){ auto stageImg = StringUtils::format(STAGE_IMG_FORMAT, i); auto stageImgPressed = StringUtils::format(STAGE_IMG_PRESSED_FORMAT, i); //ステージ選択ボタン auto gameItem = MenuItemImage::create(stageImg,stageImgPressed, [this](Ref *sender){ auto tapItem = (MenuItemImage*)sender; //ゲームスタート onGameStart(tapItem->getTag()); }); gameItem->setTag(i); gameItem->setScale(0.5f); //ハイスコアレベル auto stageHighKey = StringUtils::format(HIGHSCORE_KEY_STAGE, i); auto highScore = UserDefault::getInstance()->getDoubleForKey(stageHighKey.c_str()); auto scoreLabel = Label::createWithSystemFont( "HIGH SCORE : --.--- ", "Marker Felt", 28); if (highScore > 0.0 ) { scoreLabel->setString(StringUtils::format("HIGH SCORE : %6.3lf", highScore)); } scoreLabel->setColor(Color3B::YELLOW); scoreLabel->enableShadow(Color4B::BLACK, Size(0.5, 0.5), 3); scoreLabel->enableOutline(Color4B::BLACK, 1.5); //扱いやすいように背景の基準点変更 gameItem->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT); scoreLabel->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); auto gameMenu = Menu::create(gameItem, NULL); this->addChild(gameMenu); this->addChild(scoreLabel); gameMenu->setPosition(Vec2(winSize.width /2.0 - 70, winSize.height - 200 - ((i-1)* 85))); scoreLabel->setPosition(Vec2(winSize.width /2.0 -35, winSize.height - 200 - ((i-1)* 85))); } //menuボタン auto selectItem = MenuItemImage::create("common_btn_menu.png","common_btn_menu_pressed.png", [this](Ref *sender){ auto scene = TitleScene::createScene(); auto transition = TransitionFade::create(0.5, scene); Director::getInstance()->replaceScene(transition); }); selectItem->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); auto menu = Menu::create(selectItem, nullptr); menu->setPosition(Vec2(25, 25)); this->addChild(menu); return true; }
Scene* Chapter6_1::createScene() { cocos2d::Rect visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect(); Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); int index=2; // create a scene auto scene = Scene::create(); auto layer = LayerColor::create(Color4B::GRAY); scene->addChild(layer); // add title auto label = LabelTTF::create("Label", "Marker Felt.ttf", 32); label->setPosition(Vec2(visibleRect.origin.x+visibleRect.size.width/2, visibleRect.origin.y+visibleRect.size.height/2).x, Vec2(visibleRect.origin.x+visibleRect.size.width/2, visibleRect.origin.y+visibleRect.size.height).y - 30); scene->addChild(label, -1); //add the menu item for back to main menu label = LabelTTF::create("MainMenu", "Marker Felt.ttf", 32); auto menuItem = MenuItemLabel::create(label); menuItem->setCallback([&](cocos2d::Ref *sender) { Director::getInstance()->replaceScene(Chapter6::createScene()); }); auto menu = Menu::create(menuItem, nullptr); menu->setPosition(Vec2::ZERO); menuItem->setPosition(Vec2(visibleRect.origin.x+visibleRect.size.width - 80, visibleRect.origin.y + 25)); scene->addChild(menu, 1); // this is for Labels section of the Programmers Guide // 1. BMFont auto myLabel = Label::createWithBMFont("bitmapRed.fnt", "LabelBMFont"); myLabel->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x, (Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - (++index) * 40)); scene->addChild(myLabel, 1); // 2. LabelTTF auto myLabel2 = Label::createWithTTF("LabelTTF", "Marker Felt.ttf", 32); myLabel2->setColor(Color3B::RED); myLabel2->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x, (Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - (++index) * 40)); scene->addChild(myLabel2, 1); // 3. LabelTTF with TTFConfig // create a TTFConfig files for labels to share TTFConfig labelConfig; labelConfig.fontFilePath = "Marker Felt.ttf"; labelConfig.fontSize = 32; auto myLabel3 = Label::createWithTTF(labelConfig, "LabelTTF from TTFConfig"); myLabel3->setColor(Color3B::RED); myLabel3->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x, (Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - (++index) * 40)); scene->addChild(myLabel3, 1); // 4. Label using SystemFont auto myLabel4 = Label::createWithSystemFont("Label using SystemFont", "Arial", 32); myLabel4->setColor(Color3B::RED); myLabel4->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x, (Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - (++index) * 40)); scene->addChild(myLabel4, 1); // 5. LabelTTF with shadow, outline and glow auto myLabel5 = Label::createWithTTF("LabelTTF with Shadow", "Marker Felt.ttf", 32); myLabel5->enableShadow(); myLabel5->setColor(Color3B::RED); myLabel5->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x, (Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - (++index) * 40)); scene->addChild(myLabel5, 1); auto myLabel6 = Label::createWithTTF("LabelTTF with Outline", "Marker Felt.ttf", 32); myLabel6->setTextColor(Color4B::RED); //setColor will change the color of the whole label with effects as if 3.4 // myLabel6->setColor(Color3B::RED); myLabel6->enableOutline(Color4B::WHITE, 1); myLabel6->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x, (Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - (++index) * 40)); scene->addChild(myLabel6, 1); auto myLabel7 = Label::createWithTTF("LabelTTF with Glow", "Marker Felt.ttf", 32); myLabel7->enableGlow(Color4B::YELLOW); myLabel7->setTextColor(Color4B::RED); myLabel7->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x, (Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - (++index) * 40)); scene->addChild(myLabel7, 1); // return the scene return scene; }
PhotoWidget::PhotoWidget(const QRectF &rect) : PlexyDesk::DesktopWidget(rect) { enableShadow(true); }
bool ResultLayer::init() { if(!Layer::init()){ return false; } auto winSize = Director::getInstance()->getWinSize(); // 結果画面の生成 auto resultBackground = Sprite::create("result_background.png"); auto backSize = resultBackground->getContentSize(); resultBackground->setPosition(Vec2(winSize.width / 2, winSize.height * 3 / 2)); this->setResultBackground(resultBackground); this->addChild(resultBackground, 1); // 結果画面の出現 auto delay = DelayTime::create(1.0); auto moveto = MoveTo::create(1.0, Vec2(winSize.width / 2, winSize.height / 2)); auto resultSequence = Sequence::create(delay, moveto, NULL); resultBackground->runAction(resultSequence); // スコアラベルの作成 auto scoreLabel = Label::createWithSystemFont("0", "Latha", 20); scoreLabel->enableShadow(Color4B::BLACK, Size(0.5, 0.5), 3); scoreLabel->enableOutline(Color4B::BLACK, 1.5); scoreLabel->setPosition(Vec2(backSize.width / 2, RESULT_SCORE_LABEL_POS_Y)); this->setResultScoreLabel(scoreLabel); resultBackground->addChild(scoreLabel); // パネル枚数ラベルの作成 auto panelsLabel = Label::createWithSystemFont("0", "Latha", 20); panelsLabel->enableShadow(Color4B::BLACK, Size(0.5, 0.5), 3); panelsLabel->enableOutline(Color4B::BLACK, 1.5); panelsLabel->setPosition(Vec2(RESULT_PANELS_LABEL_POS_X, RESULT_PANELS_LABEL_POS_Y)); this->setResultPanelsLabel(panelsLabel); resultBackground->addChild(panelsLabel); // maxコンボラベルの作成 auto maxComboLabel = Label::createWithSystemFont("0", "Latha", 20); maxComboLabel->enableShadow(Color4B::BLACK, Size(0.5, 0.5), 3); maxComboLabel->enableOutline(Color4B::BLACK, 1.5); maxComboLabel->setPosition(Vec2(RESULT_MAX_COMBO_LABEL_POS_X, RESULT_MAX_COMBO_LABEL_POS_Y)); this->setResultMaxComboLabel(maxComboLabel); resultBackground->addChild(maxComboLabel); //リプレイボタンの作成 auto replayButton = MenuItemImage::create("replay_button.png", "replay_button_pressed.png", [](Ref* ref){ auto scene = GameScene::createScene(); Director::getInstance()->replaceScene(scene); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("buttonpush.mp3"); }); // ホームボタンの作成 auto homeButton = MenuItemImage::create("home_button_result.png", "home_button_result_pressed.png", [](Ref* ref){ auto scene = StartScene::createScene(); auto transition = TransitionPageTurn::create(0.5, scene, true); Director::getInstance()->replaceScene(transition); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("buttonpush.mp3"); }); // ランキングボタンの作成 auto rankButton = MenuItemImage::create("rank_button_result.png", "rank_button_result_pressed.png", [](Ref* ref){ auto scene = StartScene::createScene(); auto layer = RankScene::create(); layer->setAtmain(false); scene->addChild(layer); auto transition = TransitionPageTurn::create(0.5, scene, true); Director::getInstance()->replaceScene(transition); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("buttonpush.mp3"); }); auto menu = Menu::create(homeButton, replayButton, rankButton, NULL); resultBackground->addChild(menu, 2); menu->setPosition(Vec2(backSize.width / 2, MENU_POS_Y)); menu->alignItemsHorizontallyWithPadding(MENU_INTERVAL); // ボタンを横に並べる return true; }