- 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.
- 工業(yè)機(jī)器人虛擬仿真實(shí)例教程:KUKA.Sim Pro(全彩版)
- 并行數(shù)據(jù)挖掘及性能優(yōu)化:關(guān)聯(lián)規(guī)則與數(shù)據(jù)相關(guān)性分析
- Data Wrangling with Python
- 完全掌握AutoCAD 2008中文版:綜合篇
- 計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)基礎(chǔ)
- 現(xiàn)代傳感技術(shù)
- Java Web整合開發(fā)全程指南
- 觸控顯示技術(shù)
- JSP從入門到精通
- 單片機(jī)C語言應(yīng)用100例
- LAMP網(wǎng)站開發(fā)黃金組合Linux+Apache+MySQL+PHP
- RedHat Linux用戶基礎(chǔ)
- 基于神經(jīng)網(wǎng)絡(luò)的監(jiān)督和半監(jiān)督學(xué)習(xí)方法與遙感圖像智能解譯
- 計(jì)算機(jī)組網(wǎng)技術(shù)
- ESP8266 Robotics Projects