summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-07-10 13:02:55 -0300
committerGitHub <noreply@github.com>2016-07-10 13:02:55 -0300
commit5dd6530acf1f1db145ebfdd1c0967329b9c36fa0 (patch)
tree9056d98a63c44440a715225d7664cb87cc69ce32
parent49b288d331cc1cb6854c780b861aa7964c6a83ee (diff)
parent0a8d6de0c336dfc2029da276c80371d3bf4c9792 (diff)
Merge pull request #5563 from opmana/fix-convert-tileset
Respect frame property when converting to TileSet.
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp
index a2c7147bf3..39a15189e7 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_set_editor_plugin.cpp
@@ -73,24 +73,24 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me
p_library->tile_set_name(id,mi->get_name());
}
-
-
p_library->tile_set_texture(id,texture);
p_library->tile_set_material(id,material);
Vector2 phys_offset;
+ Size2 s;
- if (mi->is_centered()) {
- Size2 s;
- if (mi->is_region()) {
- s=mi->get_region_rect().size;
- } else {
- s=texture->get_size();
- }
- phys_offset+=-s/2;
- }
if (mi->is_region()) {
+ s=mi->get_region_rect().size;
p_library->tile_set_region(id,mi->get_region_rect());
+ } else {
+ const int frame = mi->get_frame();
+ const int hframes = mi->get_hframes();
+ s=texture->get_size()/Size2(hframes,mi->get_vframes());
+ p_library->tile_set_region(id,Rect2(Vector2(frame%hframes,frame/hframes)*s,s));
+ }
+
+ if (mi->is_centered()) {
+ phys_offset+=-s/2;
}
Vector<Ref<Shape2D> >collisions;