Advertisement
otorp2

another with delta timer

Aug 29th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. const SPEED=-220
  2. const SHOOT_INTERVAL=1
  3. var shoot_timeout=0
  4.  
  5. func _process(delta):
  6. translate( Vector2(SPEED*delta,0) )
  7. shoot_timeout-=delta
  8.  
  9. if (shoot_timeout<0):
  10.  
  11. shoot_timeout=SHOOT_INTERVAL
  12.  
  13. #instance a shot
  14. var shot = preload("res://enemy_shot.scn").instance()
  15. #set pos as "shoot_from" Position2D node
  16. shot.set_pos( get_node("shoot_from").get_global_pos() )
  17. #add it to parent, so it has world coordinates
  18. get_parent().add_child(shot)
  19.  
  20. var destroyed=false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement