Skip to content

Latest commit

 

History

History

custom_signals

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

custom_signals

Example Implementation

signal custom_signal
signal custom_signal_with_params(a,b)


func emit_custom_signal():
	emit_signal("custom_signal")
	
func emit_custom_signal_with_params(a,b):
	emit_signal("custom_signal_with_params",a,b)

Example of Usage

extends Node2D

onready var emitter = preload("custom_signals.gd").new()

func _ready():
	emitter.connect("custom_signal",self,"on_custom_signal")
	emitter.connect("custom_signal_with_params",self,"on_custom_signal_with_params")

func on_custom_signal():
	get_node("Control1/Label").set_text("signal 1 received")

func on_custom_signal_with_params(a,b):
	get_node("Control2/Label").set_text("signal 2 received with params: ("+a+","+b+")")

func _on_Button1_pressed():
	emitter.emit_custom_signal()


func _on_Button2_pressed():
	emitter.emit_custom_signal_with_params("a","b")