Skip to content
Permalink
Browse files

Make it easier to use background_area.gd

  • Loading branch information...
fleskesvor committed Apr 29, 2017
1 parent c5945b8 commit ddfd7fa917588625140bf62467da385aafc305af
Showing with 29 additions and 7 deletions.
  1. +17 −6 globals/background_area.gd
  2. +5 −1 globals/item_background.gd
  3. +7 −0 rooms/test/mountain.esc
  4. BIN rooms/test/test.scn
@@ -7,23 +7,34 @@ var rectangleshape
func input(viewport, event, shape_idx):
if event.type == InputEvent.MOUSE_BUTTON && event.pressed:
if (event.button_index == 1):
get_tree().call_group(0, "game", "clicked", self, get_pos() + Vector2(event.x, event.y))
get_tree().call_group(0, "game", "clicked", self, get_pos() + Vector2(event.x, event.y), BUTTON_LEFT)
elif (event.button_index == 2):
emit_right_click()



func get_action():
return action

func _init():
add_user_signal("right_click_on_bg")

func _enter_tree():
# Use size of background texture to calculate collision shape
var background = get_parent().get_node("background")
if background:
printt("GET SIZE", background.get_size())

var size = background.get_size()
var extents = Vector2(size.x / 2, size.y / 2)
var transform = Matrix32(Vector2(1, 0), Vector2(0, 1), extents)

var shape = RectangleShape2D.new()
shape.set_extents(extents)
add_shape(shape)
set_shape_transform(0, transform)

func _ready():
connect("input_event", self, "input")
add_to_group("background")




func emit_right_click():
emit_signal("right_click_on_bg")
@@ -4,6 +4,7 @@ extends "res://globals/interactive.gd"

export var tooltip = ""
export var action = ""
export var secondary_action = ""
export(String,FILE) var events_path = ""
export var global_id = ""
export var use_combine = false
@@ -78,6 +79,9 @@ func activate(p_action, p_param = null):
func get_action():
return action

func get_secondary_action():
return secondary_action

func mouse_enter():
get_tree().call_group(0, "game", "mouse_enter", self)
_check_focus(true, false)
@@ -89,7 +93,7 @@ func mouse_exit():
func input(viewport, event, shape_idx):
if event.type == InputEvent.MOUSE_BUTTON || event.is_action("ui_accept"):
if event.is_pressed():
get_tree().call_group(0, "game", "clicked", self, get_pos())
get_tree().call_group(0, "game", "clicked", self, get_pos(), event.button_index)
_check_focus(true, true)
else:
_check_focus(true, false)
@@ -0,0 +1,7 @@
:look

say player "A mountain"

:climb

say player "I don't want to climb it"
BIN +1.61 KB (110%) rooms/test/test.scn
Binary file not shown.

0 comments on commit ddfd7fa

Please sign in to comment.
You can’t perform that action at this time.