June 2018
Beginner to intermediate
298 pages
7h 38m
English
First, make a new script by clicking File | New in the Script window. Make sure it inherits from Node (this is the default), and in the Path field, set the name to Global.gd. Click Create and add the following code to the new script:
extends Nodevar levels = ['res://levels/Level1.tscn', 'res://levels/Level2.tscn']var current_levelvar start_screen = 'res://ui/StartScreen.tscn'var end_screen = 'res://ui/EndScreen.tscn'func new_game(): current_level = -1 next_level()func game_over(): get_tree().change_scene(end_screen)func next_level(): current_level += 1 if current_level >= Global.levels.size(): # no more levels to load :( game_over() else: get_tree().change_scene(levels[current_level])
This script provides a number of functions ...
Read now
Unlock full access