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

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.

主站蜘蛛池模板: 佛坪县| 长宁区| 宁德市| 甘洛县| 策勒县| 阿勒泰市| 五峰| 尼勒克县| 同仁县| 万山特区| 天水市| 丰台区| 五家渠市| 玉门市| 涡阳县| 敦煌市| 大渡口区| 五河县| 遵义市| 正蓝旗| 卢氏县| 高州市| 洛扎县| 行唐县| 正安县| 龙山县| 常宁市| 中宁县| 普兰县| 无锡市| 三门峡市| 云霄县| 宝山区| 新疆| 于田县| 布拖县| 广州市| 建平县| 尉犁县| 封丘县| 延寿县|