Topic was automatically imported from the old Question2Answer platform.
Asked By
Shlopynoobnoob
the ball only moves on the x-axis, here’s the code:
extends Area2D
var screen_size
var direction = Vector2(1.0, 0.0)
var ball_speed = 89
func _ready():
screen_size = get_viewport_rect().size
func _process(delta):
position += direction * ball_speed * delta
if (position.x < 0 or position.x > screen_size.x):
direction.x = -direction.x