- Godot Engine Game Development Projects
- Chris Bradfield
- 171字
- 2021-06-18 18:51:29
Initializing
Next, add the _ready() function:
func _ready():
randomize()
screensize = get_viewport().get_visible_rect().size
$Player.screensize = screensize
$Player.hide()
In GDScript, you can use $ to refer to a particular node by name. This allows you to find the size of the screen and assign it to the player's screensize variable. hide() makes the player start out invisible (you'll make them appear when the game actually starts).
In the $ notation, the node name is relative to the node running the script. For example, $Node1/Node2 would refer to a node (Node2) that is the child of Node1, which itself is a child of the currently running script. Godot's autocomplete will suggest node names from the tree as you type. Note that if the node's name contains spaces, you must put quote marks around it, for example, $"My Node".
You must use randomize() if you want your sequence of "random" numbers to be different every time you run the scene. Technically speaking, this selects a random seed for the random number generator.
- Dreamweaver CS3網(wǎng)頁制作融會貫通
- 控制與決策系統(tǒng)仿真
- 機(jī)器學(xué)習(xí)與大數(shù)據(jù)技術(shù)
- 人工智能與人工生命
- JSF2和RichFaces4使用指南
- Windows環(huán)境下32位匯編語言程序設(shè)計
- 數(shù)據(jù)通信與計算機(jī)網(wǎng)絡(luò)
- 電腦主板現(xiàn)場維修實錄
- Nginx高性能Web服務(wù)器詳解
- 傳感器與新聞
- 自動化生產(chǎn)線安裝與調(diào)試(三菱FX系列)(第二版)
- 電子設(shè)備及系統(tǒng)人機(jī)工程設(shè)計(第2版)
- 所羅門的密碼
- 空間機(jī)器人
- 大數(shù)據(jù)導(dǎo)論