Skip to content

Commit

Permalink
1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nonunknown777 committed Apr 20, 2020
1 parent 53cde3d commit 60039e0
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 71 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

![alt text](https://i.imgur.com/F6gqVGB.gif)

## ChangeLog

##v1.5
* Added Support for 2D Sprites
* Removed a bug where you cant play animations, when the engine is reopened/reloaded

### Working Version
3.2
3.2+
3.2.2 beta 1

## Installation
* Place inside your project folder
Expand All @@ -14,24 +21,17 @@
* Set the FileName type to json
* JSON and PNG file must be the same name, and located in the same folder
* Go to your Scene which contains:
- AnimationPlayer
- Sprite3D
* Attach the "SpriteSheet" class to your sprite nodew/Hide sprite name
AnimationPlayer
Sprite (Attach SpriteSheet2D or SpriteSheet3D scripts)
* Select Both
* Press **F9 Shortcut key**
* Window should appear
* Select Sprites in sequence you want
If you select wrong, just right-click and clear selection
* click the button: Create Animation
* Configure as you like
- If you want to know what the checkboxes does just leave the mouse above to show HINT
* Click ok
* Reselect the AnimationPlayer node to see changes

## Tips
If you selected wrong just press right mouse button and select clear selection

## Known Limitations
* Works only with Sprite3D
If you want to know what the checkboxes does just leave the mouse above to show HINT
* **Reselect the AnimationPlayer node to see changes**

## Known Bugs
* None
Expand All @@ -44,7 +44,7 @@ Here are some things that could make this plugin better:
* Hide sprite-boxes (buttons) off the screen to improve performance
* Colorize with different colors the in-use sprites
* Modify existing animations created with this plugin
- Like changing the frame distance (step)
Like changing the frame distance (step)
* Reorganize the texture of the spritesheet acording to names
* Show/Hide sprite names
* Zoom in/out spritesheet
Expand Down
1 change: 0 additions & 1 deletion addons/easy_sheet_manager/example/bihan.json

This file was deleted.

Binary file removed addons/easy_sheet_manager/example/bihan.png
Binary file not shown.
34 changes: 0 additions & 34 deletions addons/easy_sheet_manager/example/bihan.png.import

This file was deleted.

11 changes: 9 additions & 2 deletions addons/easy_sheet_manager/scripts/ESM_Parser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ func read(_manager):
file.close()
return
manager.container.texture = manager.texture

generate_box()

func generate_box():
var text = file.get_as_text()
file.close()
var json = parse_json(text)

var spr:SpriteSheet = manager.sprite
spr._sprite_data = []
var spr = manager.sprite
spr._sprite_data = SpriteData.new()

for value in json:
#height,name,width,x,y
Expand All @@ -41,5 +42,11 @@ func generate_box():


manager.item_list.sort_items_by_text()
print(manager.texture_json)
var dir = manager.texture_json
var ext = dir.get_extension()
dir = dir.replace(ext,"tres")
var error = ResourceSaver.save(dir,spr._sprite_data)
print(str(error))
print("BoxCount: "+str(manager.container.get_child_count()))
# print(str(spr._sprite_data))
3 changes: 2 additions & 1 deletion addons/easy_sheet_manager/scripts/Manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func create(data=null):
sprite = null
animation = null
for node in selected_nodes:
if node is SpriteSheet:
if node is Sprite or node is Sprite3D:
push_warning("Make sure your sprite contains has one of the following scripts attached :\n*SpriteSheet2D\n* SpriteSheet3D")
sprite = node
elif node is AnimationPlayer:
animation = node
Expand Down
15 changes: 15 additions & 0 deletions addons/easy_sheet_manager/scripts/SpriteData.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tool
extends Resource
class_name SpriteData


export var data:Array

func get_size() -> int: return data.size()-1

func insert_data(value:Rect2):
data.append(value)
pass

func reset():
data = []
19 changes: 0 additions & 19 deletions addons/easy_sheet_manager/scripts/SpriteSheet.gd

This file was deleted.

32 changes: 32 additions & 0 deletions addons/easy_sheet_manager/scripts/SpriteSheet2D.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
tool
extends Sprite
class_name SpriteSheet2D

export var sprite_id:int = 0 setget set_sprite
var _sprite_data:SpriteData

func _enter_tree():
if _sprite_data == null:
var dir = texture.resource_path
var ext = dir.get_extension()
dir = dir.replace(ext,"tres")
var test = ResourceLoader.load(dir) as SpriteData
_sprite_data = SpriteData.new()
_sprite_data.data = test.data

func _init():
self._enter_tree()

func set_sprite(value:int):
if value < 0 or value >= _sprite_data.data.size():
return
sprite_id = value
print(_sprite_data.data[value])
region_rect = _sprite_data.data[value]

func add_data(x,y,width,height,_name) -> Dictionary:
var rect:Rect2
rect.size = Vector2(width,height)
rect.position = Vector2(x,y)
_sprite_data.insert_data(rect)
return {region=rect,id=_sprite_data.get_size(),name=_name}
32 changes: 32 additions & 0 deletions addons/easy_sheet_manager/scripts/SpriteSheet3D.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
tool
extends Sprite3D
class_name SpriteSheet3D

export var sprite_id:int = 0 setget set_sprite
var _sprite_data:SpriteData

func _enter_tree():
if _sprite_data == null:
var dir = texture.resource_path
var ext = dir.get_extension()
dir = dir.replace(ext,"tres")
var test = ResourceLoader.load(dir) as SpriteData
_sprite_data = SpriteData.new()
_sprite_data.data = test.data

func _init():
self._enter_tree()

func set_sprite(value:int):
if value < 0 or value >= _sprite_data.data.size():
return
sprite_id = value
print(_sprite_data.data[value])
region_rect = _sprite_data.data[value]

func add_data(x,y,width,height,_name) -> Dictionary:
var rect:Rect2
rect.size = Vector2(width,height)
rect.position = Vector2(x,y)
_sprite_data.insert_data(rect)
return {region=rect,id=_sprite_data.get_size(),name=_name}

0 comments on commit 60039e0

Please sign in to comment.