Godot Engine Game Development Projects
上QQ阅读APP看书,第一时间看更新

Main script

Add a script to the Main node (use the Empty template) and add the following variables:

extends Node

export (PackedScene) var Coin
export (int) var playtime

var level
var score
var time_left
var screensize
var playing = false

The Coin and Playtime properties will now appear in the Inspector when you click on Main. Drag Coin.tscn from the FileSystem panel and drop it in the Coin property. Set Playtime to 30 (this is the amount of time the game will last). The remaining variables will be used later in the code.