- Godot Engine Game Development Projects
- Chris Bradfield
- 302字
- 2021-06-18 18:51:33
Character scene
Start creating the Character scene by adding an Area2D and naming it Character. Area2D is a good choice for this type of character because its main function will be to detect overlaps—when it moves onto an item or enemy, for example.
Add the following children:
- Sprite
- CollisionShape2D
- Tween (named MoveTween)
- AnimationPlayer
Leave the Sprite without a texture, but in the Inspector, under the Animation section of the Sprite, set its Vframes and Hframes properties to 4 and 5, respectively. This tells Godot to slice the texture into a 5 x 4 grid of inpidual images.
The spritesheets you'll use for the player and the enemy are arranged in exactly this pattern, with each row containing the animation frames for a single direction of movement:
When a spritesheet has been sliced using the Vframes and Hframes properties, you can use the Frame property to set which inpidual frame to use. In the preceding player sheet, the left-facing animation would use frames 5 through 9 (counting from frame 0 in the upper-left corner). You'll use an AnimationPlayer to change the Frame property below. Refer to the following screenshot:

Next, create a new RectangleShape2D in the collision shape's Shape. Click on the new <RectangleShape2D> and set its Extents property in the Inspector to (16, 16). Note that Extents measures the distance from the center in each direction, so this results in a collision shape that is 32 by 32 pixels.
Because all the characters are drawn to the same scale, we can be confident that the same sized collision shape will work for all characters. If this isn’t the case with the art you’re using, you can skip setting the collision shape here and configure it later for the inpidual inherited scenes.
- MATLAB/Simulink權(quán)威指南:開發(fā)環(huán)境、程序設(shè)計、系統(tǒng)仿真與案例實戰(zhàn)
- 菜鳥起飛系統(tǒng)安裝與重裝
- 深度學(xué)習(xí)與目標(biāo)檢測
- 基于神經(jīng)網(wǎng)絡(luò)的監(jiān)督和半監(jiān)督學(xué)習(xí)方法與遙感圖像智能解譯
- R Machine Learning Projects
- 水晶石影視動畫精粹:After Effects & Nuke 影視后期合成
- Linux系統(tǒng)下C程序開發(fā)詳解
- 基于RPA技術(shù)財務(wù)機器人的應(yīng)用與研究
- Linux Shell Scripting Cookbook(Third Edition)
- 人工智能:智能人機交互
- 貫通Java Web輕量級應(yīng)用開發(fā)
- 常用傳感器技術(shù)及應(yīng)用(第2版)
- Microsoft System Center Data Protection Manager Cookbook
- 歐姆龍CP1H型PLC編程與應(yīng)用
- AWS Administration:The Definitive Guide(Second Edition)