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

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.

主站蜘蛛池模板: 屯昌县| 拉孜县| 巴林右旗| 雷山县| 阳原县| 建昌县| 咸宁市| 高尔夫| 阿克苏市| 宁波市| 鸡泽县| 万安县| 太保市| 二连浩特市| 晋江市| 镇原县| 都江堰市| 河南省| 清水县| 贵德县| 都兰县| 宾阳县| 涟水县| 余庆县| 保定市| 鹤峰县| 林西县| 当阳市| 临城县| 南雄市| 稻城县| 镇巴县| 瓦房店市| 孙吴县| 岱山县| 台安县| 开远市| 黄平县| 永嘉县| 延边| 封开县|