Advertisement
otorp2

move sprite

Oct 20th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. extends Sprite
  2.  
  3. var speed = 100
  4. var vel = Vector2()
  5.  
  6.  
  7. func _ready():
  8. set_process(true)
  9.  
  10.  
  11. func _process(delta):
  12. if Input.is_key_pressed(KEY_RIGHT):
  13. vel = Vector2(speed, 0)
  14. elif Input.is_key_pressed(KEY_LEFT):
  15. vel = Vector2(-speed, 0)
  16. elif Input.is_key_pressed(KEY_UP):
  17. vel = Vector2(0, -speed)
  18. elif Input.is_key_pressed(KEY_DOWN):
  19. vel = Vector2(0, speed)
  20. else:
  21. vel = Vector2(0, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement