| 686 | } |
| 687 | |
| 688 | void LevelEditorLayer::onTouchMoved(ax::Touch* touch, ax::Event* event) { |
| 689 | if (!_inPlaybackMode && _inSwapMode) { |
| 690 | auto pos = touch->getLocation(); |
| 691 | |
| 692 | pos += m_obCamPos; |
| 693 | |
| 694 | pos.y -= 90; |
| 695 | |
| 696 | int mapped_section = pos.x /= 30; |
| 697 | int mapped_y = pos.y /= 30; |
| 698 | |
| 699 | pos.x = mapped_section * 30 + 15; |
| 700 | pos.y = mapped_y * 30 + 15; |
| 701 | |
| 702 | auto obj_existing = findObject(pos.x, pos.y + 90.f); |
| 703 | |
| 704 | if (obj_existing && obj_existing->getID() == _selectedObject) { |
| 705 | return; |
| 706 | } |
| 707 | |
| 708 | // 1,1,2,15,3,15,21,3,24,7 |
| 709 | std::string object_string = fmt::format("1,{},2,{},3,{}", _selectedObject, pos.x, pos.y); |
| 710 | |
| 711 | GameObject *obj = GameObject::createFromString(object_string); |
| 712 | |
| 713 | obj->setStretchEnabled(false); |
| 714 | obj->setActive(true); |
| 715 | obj->setID(_selectedObject); |
| 716 | |
| 717 | if (_selectedObjectReal != nullptr && _selectedObjectReal->getID() == obj->getID()) { |
| 718 | obj->setRotation(_selectedObjectReal->getRotation()); |
| 719 | } |
| 720 | |
| 721 | addObject(obj); |
| 722 | |
| 723 | _selectedObjectReal = obj; |
| 724 | _inSwapMode = true; |
| 725 | } |
| 726 | |
| 727 | return; |
| 728 | } |
| 729 | |
| 730 | bool LevelEditorLayer::onTouchBegan(ax::Touch* touch, ax::Event* event) { |
| 731 |
nothing calls this directly
no test coverage detected