Advertisement
otorp2

SSpt 1 instance node + str name

Jan 11th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1.  
  2. extends Node2D
  3. var laserCount = 0
  4. var laser = preload("res://bullet.scn")
  5. var isspacepressed = false
  6.  
  7. func _ready():
  8. set_process(true)
  9. pass
  10.  
  11. func _process(delta):
  12. if Input.is_action_pressed("ui_select"):
  13. if isspacepressed == false:
  14. fire()
  15. isspacepressed = true
  16. else:
  17. isspacepressed = false
  18.  
  19.  
  20. func fire():
  21.  
  22. print(laserCount)
  23. laserCount = laserCount +1
  24. print("fire")
  25. var laser_instance = laser.instance()
  26. laser_instance.set_name("laser" + str(laserCount))
  27. add_child(laser_instance)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement