I.e. when the e in "real" it's clicked, a and l also have to return to the letterbox along with e letter.
Code:
func _ready():
$AnimationPlayer.play("intro")
randomize()
for i in range(4):
for j in range(4):
var tile:LetterTile = Letter.instance()
$LetterBox.add_child(tile)
# warning-ignore:return_value_discarded
tile.connect("tile_clicked", self, "on_tile_clicked", [tile])
tile.position = Vector2(i * TILESIZE, j * TILESIZE)
tile.box_position = tile.position
initialize_dictionary()
func on_tile_clicked(tile:LetterTile):
var start_pos = tile.global_position
if tile.get_parent().name == "LetterBox":
if word_node_erased == true:
add_child(word_node)
word_node_erased = false
$LetterBox.remove_child(tile)
$Word.add_child(tile)
tile.global_position = start_pos
current_word += tile.letter_value
else:
#This part i mean.
var tile_position = tile.get_position_in_parent()
$Word.remove_child(tile)
$LetterBox.add_child(tile)
$Tween.interpolate_property(tile,"position", start_pos - $LetterBox.position, tile.box_position,0.2,Tween.TRANS_LINEAR)
current_word = current_word.substr(0, tile_position) + current_word.substr(tile_position + 1, current_word.length())
