| 493 | } |
| 494 | |
| 495 | RemoveMenuItemWhenMove::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 | |
| 524 | void RemoveMenuItemWhenMove::goBack(Object* pSender) |
| 525 | { |
nothing calls this directly
no test coverage detected