Advertisement
Guest User

Paddle Script

a guest
Jan 23rd, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3. const ball_scene = preload("res://Ball.tscn")
  4.  
  5. func _ready():
  6. set_physics_process(true)
  7. set_process_input(true)
  8.  
  9. func _physics_process(delta):
  10. var y = position.y
  11. var mouse_x = get_viewport().get_mouse_position().x
  12. set_position(Vector2(mouse_x,y))
  13.  
  14.  
  15. func _input(event):
  16. if(event is InputEventMouseButton && event.is_pressed()):
  17. var ball = ball_scene.instance()
  18. ball.set_position(get_position()-Vector2(0,16))
  19. get_tree().get_root().add_child(ball)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement