| 728 | } |
| 729 | |
| 730 | bool LevelEditorLayer::onTouchBegan(ax::Touch* touch, ax::Event* event) { |
| 731 | |
| 732 | if (!_inPlaybackMode) { |
| 733 | auto pos = touch->getLocation(); |
| 734 | |
| 735 | pos += m_obCamPos; |
| 736 | |
| 737 | pos.y -= 90; |
| 738 | |
| 739 | int mapped_section = pos.x /= 30; |
| 740 | int mapped_y = pos.y /= 30; |
| 741 | |
| 742 | pos.x = mapped_section * 30 + 15; |
| 743 | pos.y = mapped_y * 30 + 15; |
| 744 | |
| 745 | auto obj_existing = findObject(pos.x, pos.y + 90.f); |
| 746 | |
| 747 | if (obj_existing && obj_existing->getID() == _selectedObject) { |
| 748 | _selectedObjectReal = obj_existing; |
| 749 | return true; |
| 750 | } |
| 751 | |
| 752 | // 1,1,2,15,3,15,21,3,24,7 |
| 753 | std::string object_string = fmt::format("1,{},2,{},3,{}", _selectedObject, pos.x, pos.y); |
| 754 | |
| 755 | GameObject *obj = GameObject::createFromString(object_string); |
| 756 | |
| 757 | obj->setStretchEnabled(false); |
| 758 | obj->setActive(true); |
| 759 | obj->setID(_selectedObject); |
| 760 | |
| 761 | if (_selectedObjectReal != nullptr && _selectedObjectReal->getID() == obj->getID()) { |
| 762 | obj->setRotation(_selectedObjectReal->getRotation()); |
| 763 | } |
| 764 | |
| 765 | addObject(obj); |
| 766 | |
| 767 | _selectedObjectReal = obj; |
| 768 | _inSwapMode = true; |
| 769 | } else { |
| 770 | _player1->pushButton(); |
| 771 | if (_isDualMode) _player2->pushButton(); |
| 772 | } |
| 773 | |
| 774 | return true; |
| 775 | } |
| 776 | void LevelEditorLayer::onTouchEnded(ax::Touch* touch, ax::Event* event) { |
| 777 | if (_inPlaybackMode) { |
| 778 | _player1->releaseButton(); |
nothing calls this directly
no test coverage detected