extends Node2D onready var Coin = preload("./Coin.tscn") # Declare member variables here. Examples: # var a = 2 # var b = "text" var coin_spread = 50 # Called when the node enters the scene tree for the first time. func _ready(): assert (Coin != null) pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass func emit_coins (num, _position = null): for i in range (num): var coin = Coin.instance() coin.position = position if _position != null: coin.position = _position coin.velocity = Vector2 (rand_range(-coin_spread, coin_spread), rand_range (-coin_spread, coin_spread)) coin.z_pos = 0 coin.z_vel = rand_range(300, 800) add_child(coin) func _unhandled_input(event): if 'position' in event: var relative_pos = self.transform.affine_inverse() * event.position if event is InputEventMouseButton: if event.button_index == BUTTON_LEFT and event.pressed: emit_coins(25, relative_pos)