|
@@ -1,10 +1,15 @@
|
|
|
extends Area2D
|
|
|
|
|
|
export var speed = 400 # pixel / sec
|
|
|
-var screen_size
|
|
|
+var screen
|
|
|
+
|
|
|
+func spawn():
|
|
|
+ show()
|
|
|
+ position = (screen.position + screen.end) / 2
|
|
|
|
|
|
func _ready():
|
|
|
- screen_size = get_viewport_rect().size
|
|
|
+ hide()
|
|
|
+ screen = get_viewport_rect()
|
|
|
|
|
|
func _process(delta):
|
|
|
var velocity = Vector2()
|
|
@@ -25,8 +30,8 @@ func _process(delta):
|
|
|
|
|
|
position += velocity * delta
|
|
|
|
|
|
- position.x = clamp(position.x, 0, screen_size.x)
|
|
|
- position.y = clamp(position.y, 0, screen_size.y)
|
|
|
+ position.x = clamp(position.x, 0, screen.size.x)
|
|
|
+ position.y = clamp(position.y, 0, screen.size.y)
|
|
|
|
|
|
if velocity.x != 0:
|
|
|
$AnimatedSprite.animation = "right"
|