current
This commit is contained in:
36
Source/SpawnTimer.gd
Normal file
36
Source/SpawnTimer.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends Timer
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
var attackerScene = preload("res://attacker.tscn")
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func _timeout():
|
||||
print("timer")
|
||||
|
||||
var child = attackerScene.instance()
|
||||
var width = get_viewport().size.x
|
||||
var height = get_viewport().size.y
|
||||
|
||||
var rot = rand_range(0, PI*2)
|
||||
|
||||
var center = Vector2(width/2, height/2)
|
||||
|
||||
var vec = Vector2(-max(width, height)/2, 0)
|
||||
vec = vec.rotated(rot) + center
|
||||
vec = vec
|
||||
|
||||
child.rotation = rot
|
||||
child.position = vec
|
||||
|
||||
child.target = center
|
||||
child.speed = min(width, height)
|
||||
|
||||
add_child(child)
|
||||
Reference in New Issue
Block a user