Browse Source

Subtract body position from shape offset during tileset convert

To be able to adjust tile offset by changing position of StaticBody instead of modifying it maunally from the tres file or by calling a script.
Sean Bohan 8 years ago
parent
commit
1028739690
1 changed files with 5 additions and 4 deletions
  1. 5 4
      editor/plugins/tile_set_editor_plugin.cpp

+ 5 - 4
editor/plugins/tile_set_editor_plugin.cpp

@@ -35,18 +35,17 @@ void TileSetEditor::edit(const Ref<TileSet> &p_tileset) {
 	tileset = p_tileset;
 	tileset = p_tileset;
 }
 }
 
 
-
 void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
 void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
 
 
 	for (int i = 0; i < p_node->get_child_count(); i++) {
 	for (int i = 0; i < p_node->get_child_count(); i++) {
 
 
 		Node *child = p_node->get_child(i);
 		Node *child = p_node->get_child(i);
 
 
-		if(!child->cast_to<Sprite>()) {
-			if(child->get_child_count() > 0) {
+		if (!child->cast_to<Sprite>()) {
+			if (child->get_child_count() > 0) {
 				_import_node(child, p_library);
 				_import_node(child, p_library);
 			}
 			}
-      
+
 			continue;
 			continue;
 		}
 		}
 
 
@@ -113,6 +112,8 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
 					collisions.push_back(collision);
 					collisions.push_back(collision);
 				}
 				}
 			}
 			}
+
+			phys_offset -= sb->get_pos();
 		}
 		}
 
 
 		if (collisions.size()) {
 		if (collisions.size()) {