TouchScreenButton.gd 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 _processUI(dict = [[0,0], [0,0], [0,0]]):
  13. $Label/icons/icon1.frame = dict[0][0]
  14. $Label/icons/icon1/stars.frame = dict[0][1]
  15. $Label/icons/icon2.frame = dict[1][0]
  16. $Label/icons/icon2/stars.frame = dict[1][1]
  17. $Label/icons/icon3.frame = dict[2][0]
  18. $Label/icons/icon3/stars.frame = dict[2][1]
  19. func _description(arg = ''):
  20. $Label/Label.text = arg
  21. $Label/icons.visible = arg == ''
  22. func _physics_process(delta):
  23. $Label.text = text
  24. $Label.show()
  25. global_position = initpos if posswitch else initpos2
  26. # if posswitch: global_position = initpos2
  27. if not posswitch: $Label.hide()
  28. # $col/CollisionShape2D.call_deferred('set_disabled', false)
  29. if is_pressed():
  30. # $col/CollisionShape2D.call_deferred('set_disabled', true)
  31. $Label.hide()
  32. global_position = get_global_mouse_position() - Vector2(32,32)
  33. func _on_Button_mouse_entered():
  34. print('mouse in')
  35. # $Label.show()
  36. pass # Replace with function body.
  37. func _on_Button_mouse_exited():
  38. print('mouse out')
  39. # $Label.hide()
  40. pass # Replace with function body.