-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53cde3d
commit 60039e0
Showing
10 changed files
with
104 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |