Advertisement
otorp2

essential timer2

Jan 2nd, 2016
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1.  
  2. extends Node2D
  3.  
  4. var timer = 0
  5. #sometimes for good measure I put a limiter
  6. var limiter = 12 #to measure 1 second
  7.  
  8. func _ready():
  9. set_process(true)
  10.  
  11. pass
  12.  
  13.  
  14.  
  15. func _process(delta):
  16. timer +=1
  17. if timer >= limiter:
  18. print("do thing")
  19. timer = 0
  20. "do other things that don't need timer"
  21.  
  22.  
  23. #`[Python] var timer = 0 #sometimes for good measure I put a limiter var limiter = 60 #to - Pastebin.com`
  24. #* turtleman_ has quit (Quit: Leaving)
  25. #<dc1a0> that simple enough?
  26. #<otorp2> yes thanks very interesting
  27. #<dc1a0> if you use delta you have to think of it in terms of 1/60 or 0.0166667
  28. #<dc1a0> if target fps is 60
  29. #<otorp2> ah i will mess around with this - thanks!
  30.  
  31. #no problem. I think it makes an easier timer to work with too imo. because for half second (2 times / second) limter = 30
  32. #for 2 seconds limiter = 120
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement