MCPcopy Create free account
hub / github.com/axmolengine/axmol / MenuLayer3

Method MenuLayer3

tests/cpp-tests/Source/MenuTest/MenuTest.cpp:323–370  ·  view source on GitHub ↗

------------------------------------------------------------------ MenuLayer3 ------------------------------------------------------------------

Source from the content-addressed store, hash-verified

321//
322//------------------------------------------------------------------
323MenuLayer3::MenuLayer3()
324{
325 MenuItemFont::setFontName("fonts/Marker Felt.ttf");
326 MenuItemFont::setFontSize(28);
327
328 auto label = Label::createWithBMFont("fonts/bitmapFontTest3.fnt", "Enable AtlasItem");
329 auto item1 = MenuItemLabel::create(label, [&](Object* sender) {
330 // AXLOGD("Label clicked. Toggling AtlasSprite");
331 _disabledItem->setEnabled(!_disabledItem->isEnabled());
332 _disabledItem->stopAllActions();
333 });
334 auto item2 = MenuItemFont::create("--- Go Back ---",
335 [&](Object* sender) { static_cast<LayerMultiplex*>(_parent)->switchTo(0, false); });
336
337 auto spriteNormal = Sprite::create(s_MenuItem, Rect(0, 23 * 2, 115, 23));
338 auto spriteSelected = Sprite::create(s_MenuItem, Rect(0, 23 * 1, 115, 23));
339 auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0, 23 * 0, 115, 23));
340
341 auto item3 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled,
342 [](Object* sender) { AXLOGI("sprite clicked!"); });
343 _disabledItem = item3;
344 item3->retain();
345 _disabledItem->setEnabled(false);
346
347 auto menu = Menu::create(item1, item2, item3, nullptr);
348 menu->setPosition(Vec2(0, 0));
349
350 auto s = Director::getInstance()->getWinSize();
351
352 item1->setPosition(Vec2(s.width / 2 - 150, s.height / 2));
353 item2->setPosition(Vec2(s.width / 2 - 200, s.height / 2));
354 item3->setPosition(Vec2(s.width / 2, s.height / 2 - 100));
355
356 auto jump = JumpBy::create(3, Vec2(400, 0), 50, 4);
357 item2->runAction(RepeatForever::create(Sequence::create(jump, jump->reverse(), nullptr)));
358
359 auto spin1 = RotateBy::create(3, 360);
360 auto spin2 = spin1->clone();
361 auto spin3 = spin1->clone();
362
363 item1->runAction(RepeatForever::create(spin1));
364 item2->runAction(RepeatForever::create(spin2));
365 item3->runAction(RepeatForever::create(spin3));
366
367 addChild(menu);
368
369 menu->setPosition(Vec2(0, 0));
370}
371
372MenuLayer3::~MenuLayer3()
373{

Callers

nothing calls this directly

Calls 14

setFontSizeFunction · 0.85
createFunction · 0.85
getInstanceFunction · 0.85
stopAllActionsMethod · 0.80
switchToMethod · 0.80
RectClass · 0.50
Vec2Function · 0.50
setEnabledMethod · 0.45
isEnabledMethod · 0.45
retainMethod · 0.45
setPositionMethod · 0.45
runActionMethod · 0.45

Tested by

no test coverage detected