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

Method RemoveMenuItemWhenMove

tests/cpp-tests/Source/MenuTest/MenuTest.cpp:495–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495RemoveMenuItemWhenMove::RemoveMenuItemWhenMove()
496{
497 auto s = Director::getInstance()->getWinSize();
498
499 auto label = Label::createWithTTF("click item and move, should not crash", "fonts/arial.ttf", 20);
500 label->setPosition(Vec2(s.width / 2, s.height - 30));
501 addChild(label);
502
503 item = MenuItemFont::create("item 1");
504 item->retain();
505
506 auto back = MenuItemFont::create("go back", AX_CALLBACK_1(RemoveMenuItemWhenMove::goBack, this));
507
508 auto menu = Menu::create(item, back, nullptr);
509 addChild(menu);
510 menu->alignItemsVertically();
511
512 menu->setPosition(Vec2(s.width / 2, s.height / 2));
513
514 // Register Touch Event
515 _touchListener = EventListenerTouchOneByOne::create();
516 _touchListener->setSwallowTouches(false);
517
518 _touchListener->onTouchBegan = AX_CALLBACK_2(RemoveMenuItemWhenMove::onTouchBegan, this);
519 _touchListener->onTouchMoved = AX_CALLBACK_2(RemoveMenuItemWhenMove::onTouchMoved, this);
520
521 _eventDispatcher->addEventListenerWithFixedPriority(_touchListener, -129);
522}
523
524void RemoveMenuItemWhenMove::goBack(Object* pSender)
525{

Callers

nothing calls this directly

Calls 8

getInstanceFunction · 0.85
createFunction · 0.85
alignItemsVerticallyMethod · 0.80
Vec2Function · 0.50
setPositionMethod · 0.45
retainMethod · 0.45
setSwallowTouchesMethod · 0.45

Tested by

no test coverage detected