Item Outline, despensa
This commit is contained in:
@@ -22,3 +22,46 @@ export(Dictionary) var action4_target_texts = {}
|
||||
|
||||
# If action used by player is in this list, this is a valid target (second item in combination)
|
||||
export(Array) var target_when_selected_action_is_in = []
|
||||
|
||||
var outline: ItemOutline
|
||||
|
||||
# React to the mouse entering the item by emitting the respective signal
|
||||
func mouse_entered():
|
||||
if escoria.action_manager.is_object_actionable(global_id):
|
||||
#outline.show()
|
||||
if outline != null:
|
||||
outline.show()
|
||||
emit_signal("mouse_entered_item", self)
|
||||
|
||||
|
||||
# React to the mouse exiting the item by emitting the respective signal
|
||||
func mouse_exited():
|
||||
if outline != null:
|
||||
outline.hide()
|
||||
emit_signal("mouse_exited_item", self)
|
||||
|
||||
func _ready():
|
||||
if collision is CollisionPolygon2D:
|
||||
outline = ItemOutline.new()
|
||||
outline.polygon = collision.get("polygon")
|
||||
outline.color = Color(1,1,1,0.2)
|
||||
outline.set_outline_width(2.0)
|
||||
outline.set_outline_color(Color(1,1,1,1))
|
||||
##outline.offset = Vector2(1,1)
|
||||
collision.add_child(outline)
|
||||
outline.hide()
|
||||
|
||||
|
||||
|
||||
#elif collision is CollisionShape2D:
|
||||
# outline = Shape2D.new()
|
||||
# outline.shape = collision.get_shape()
|
||||
#outline.set_name("outline")
|
||||
#outline.shape = collision.get_shape()
|
||||
#self.add_child(outline)
|
||||
# self.add_child(outline)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
tool
|
||||
extends Polygon2D
|
||||
class_name ItemOutline, "res://addons/escoria-core/design/esc_item.svg"
|
||||
|
||||
export(Color) var OutLine = Color(0,0,0) setget set_outline_color
|
||||
export(float) var Width = 2.0 setget set_outline_width
|
||||
|
||||
func _draw():
|
||||
var poly = get_polygon()
|
||||
for i in range(1 , poly.size()):
|
||||
draw_line(poly[i-1] , poly[i], OutLine , Width)
|
||||
draw_line(poly[poly.size() - 1] , poly[0], OutLine , Width)
|
||||
|
||||
func set_outline_color(color):
|
||||
OutLine = color
|
||||
update()
|
||||
|
||||
func set_outline_width(new_width):
|
||||
Width = new_width
|
||||
update()
|
||||
Reference in New Issue
Block a user