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

Sprite animation

With Area2D, you can detect when other objects overlap or run into the player, but Area2D doesn't have an appearance on its own, so click on the Player node and add an AnimatedSprite node as a child. The AnimatedSprite will handle the appearance and animations for your player. Note that there is a warning symbol next to the node. An AnimatedSprite requires a SpriteFrames resource, which contains the animation(s) it can display. To create one, find the Frames property in the Inspector and click <null> | New SpriteFrames:

Next, in the same location, click <SpriteFrames> to open the SpriteFrames panel:

On the left is a list of animations. Click the default one and rename it to run. Then, click the Add button and create a second animation named idle and a third named hurt.

In the FileSystem dock on the left, find the run, idle, and hurt player images and drag them into the corresponding animations:

Each animation has a default speed setting of 5 frames per second. This is a little too slow, so click on each of the animations and set the Speed (FPS) setting to 8. In the Inspector, check On next to the Playing property and choose an Animation to see the animations in action:

Later, you'll write code to select between these animations, depending on what the player is doing. But first, you need to finish setting up the player's nodes.

主站蜘蛛池模板: 天水市| 文昌市| 石首市| 龙江县| 凉山| 桂阳县| 通辽市| 九龙县| 遂昌县| 景洪市| 疏附县| 遵义县| 永嘉县| 麻城市| 镇安县| 安泽县| 涿鹿县| 青岛市| 广东省| 阿图什市| 木里| 德安县| 如皋市| 大邑县| 辽阳市| 罗田县| 浦北县| 苏尼特右旗| 兴化市| 正镶白旗| 兴城市| 宝鸡市| 昌黎县| 兴国县| 龙江县| 湖州市| 甘孜| 白银市| 八宿县| 堆龙德庆县| 阿克陶县|