Ok. here is my structure of the project.
I have separated collection for every level in the game. I do this to make possible to change background and make layout manually
board
is reusable collection (actually it’s main game logic)camera
is the script which post to the renderer information about camera size and positiontutorial_popup
is a game object where i actually attach all my tutorial popups. Each one is a separated gui file with the same scriptfields_layout
is just a cosmetic element (board tiles and background)
And here is my tutorial step gui scene is
Main thing here is the hole and which is inverted clipper for the gray shade.
Another elements here is a pointer_from and pointer_to, i use this positions to animate pointer (hand) movement.
stripe, left and right parts is a bottom info elements which show info to users.
So. each tutorial steps is almost the same, i need just to change hole position and info boxes. animation and another parts is the same. difference only is on which step do i need to show these popups.
Also i need to mention that in tutorial steps i need to lock user input to specific cells of the board. I’m doing this in the level config which is a json file and it looks like this
"move_locks" : {
"1": {
"from": [5,4],
"to" : [5,3]
},
"2": {
"from": [3,4],
"to" : [4,4]
},
"3": {
"from": [3,3],
"to" : [4,3]
}
},
so if board see that it’s a step number 3 it will look user input to cell[3,3] and will allow move only to cell [4,3]
On gui side in config node (that text node) which i use, i specify following text value {"turn_number": 3}
Later i also plan to add another values like show_shade or not and maybe something else. in script i use this code self.config = json.decode(gui.get_text(gui.get_node("config")))
ok and here is there gui_script file content which handle it
- Because all script appeared immediately with level, i need to disable all ui elements
- In update cycle i listen board status and if turn_number == turn_number from config i show and animate elements
if self.data_appeared == false and BoardData.turn_number == self.config.turn_number then
self.initial_timer = (self.initial_timer or 0) + dt
if self.initial_timer > INITIAL_TIMEOUT_BEFORE_APPEAR then
self.data_appeared = true
move_captions(self)
end
end
- finally from the same module which indicate board status i listen if target_cell (the cell where selected dice is moved) is not null and self destroy this component. i do that in the same update cycle
if self.data_appeared and BoardData.target_cell and not self.destroy_in_progress then
print("im here", self.config.turn_number)
self_destroy(self)
end
full script is available here tutorial_popup.gui_script.lua · GitHub