17 lines
413 B
GDScript
17 lines
413 B
GDScript
extends KinematicBody2D
|
|
|
|
export var speed = 5
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass # Replace with function body.
|
|
|
|
func _physics_process(delta):
|
|
if Input.is_action_pressed("right"):
|
|
self.move_and_collide(Vector2(speed,0))
|
|
$Sprite.flip_h = true
|
|
elif Input.is_action_pressed("left"):
|
|
$Sprite.flip_h = false
|
|
self.move_and_collide(Vector2(-speed,0))
|