TouchScreenButton.gd 876 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. extends TouchScreenButton
  2. onready var initpos = global_position
  3. onready var initpos2 = global_position
  4. var posswitch = true
  5. var text = ''
  6. var id = 0
  7. var collayer = 4
  8. func col():
  9. print(collayer)
  10. $col.collision_layer = collayer
  11. $col.collision_mask = collayer
  12. func _physics_process(delta):
  13. $Label.text = text
  14. $Label.show()
  15. global_position = initpos if posswitch else initpos2
  16. # if posswitch: global_position = initpos2
  17. if not posswitch: $Label.hide()
  18. # $col/CollisionShape2D.call_deferred('set_disabled', false)
  19. if is_pressed():
  20. # $col/CollisionShape2D.call_deferred('set_disabled', true)
  21. $Label.hide()
  22. global_position = get_global_mouse_position()
  23. func _on_Button_mouse_entered():
  24. print('mouse in')
  25. # $Label.show()
  26. pass # Replace with function body.
  27. func _on_Button_mouse_exited():
  28. print('mouse out')
  29. # $Label.hide()
  30. pass # Replace with function body.