官术网_书友最值得收藏!

Starting and Ending the Player's Movement

When the game starts, the main scene will need to inform the player that the game has begun. Add the start() function as follows, which the main scene will use to set the player's starting animation and position:

func start(pos):
set_process(true)
position = pos
$AnimatedSprite.animation = "idle"

The die() function will be called when the player hits an obstacle or runs out of time:

func die():
$AnimatedSprite.animation = "hurt"
set_process(false)

Setting set_process(false) causes the _process() function to no longer be called for this node. That way, when the player has died, they can't still be moved by key input.

主站蜘蛛池模板: 安福县| 西华县| 临颍县| 娄烦县| 宁都县| 绥化市| 富锦市| 宁武县| 沙湾县| 青海省| 吉首市| 寿光市| 安新县| 报价| 临高县| 新民市| 宁明县| 田阳县| 岢岚县| 聊城市| 平山县| 桃江县| 伊吾县| 阳城县| 长宁区| 彭泽县| 新郑市| 通州市| 平邑县| 恩施市| 耒阳市| 麻城市| 林西县| 达孜县| 东方市| 阿拉善左旗| 枣阳市| 沙坪坝区| 从化市| 兰溪市| 永和县|