在 Unity 和 Godot 之间,最后还是选择了Godot。 希望不再是等待。

2024-05-05
Pixel Snap: If you’re using 2D pixel art in your game, it’s a good idea to always enable this settin when you start your project. This setting has no effect in 3D games(TODO: finding why).

The scene object: One of the benefits of creating a separate player scene is that you can test it independently, even before you’ve created the other parts of the game.
Group Select Nodes: Before adding any children, it’s a good idea to make sure you don’t accidentally move or resize them. It’s a good idea to always do this when creating a new scene. If a body’s collision shape or sprite becomes offset or scaled, it can cause unexpected errors and be difficult to fix. With this option, the node and all of its children will always move together.

2024-05-07
Both AnimationSprite & CollisionShape2D should be added as the children of the Player Node.

The export keyword on the speed variable allows you to set its value in the Inspector, as well as letting the Inspector know what type of data the variable should contain


About delta
The game engine attempts to run at a consistent 60 frames per second. However, this can change due to computer slowdowns, either in Godot or from the computer itself. If the frame is not consistent, then it will affect the movement of your game objects. Godot, liek most game engines and frameworks, solves this by passing you delta, which is the elapsed time since the previous frame. Most of the time, this will be around 0.016s (or around 16 milliseconds). If you then take your desired speed (600px/s) and multiply by delta, you will get a movement of exactly 10. If, however, the delta increased to 0.3, then the object will be moved 18 pixels. Overall, the movement speed remains consistent and independent of the frame rate.
As a side benefit, you can express your movement in units of px/s rather than px/frame, which is easier to visualize.

queue_free() doesn’t delete the object immediately, but rather adds it to a queue to be deleted at the end of the current frame. This is safer than immediately deleting the node, because other code running in the game may still need the node to exist. By waiting until the end of the frame, Godot can be sure that all code that may access the node has completed and the node can be removed safely. (how?)

Make sure Background is the first child node. Nodes are drawn in the order shown, so the background will be behiind the player in this case.