Recently, I have become obsessed with mowing games like "Vampire Survivor", so I plan to copy and learn from it.
After much deliberation, I finally decided to develop with the same game engine as brotato (one uses the foreign open source game engine godot4 beta3)
Newcomers will naturally have to step on the pit, but if I have stepped on it, don't fall into it again. This article will continue to be updated as I learn.
Get the game window size godot4
DisplayServer.window_get_size()
The width and height of the sprite
sprite.texture.get_height()
Create instance godot4
@onready var _enemy_sc = load("res://scene/enemy_base.tscn")
_enemy_sc.instantiate()
shader
godot3 - godot4
hint_color -> source_color
Code to get and set shader parameters
aniSprite.material.set_shader_parameter("progress",value)
Multiple instances share a material, and if you want to change the shader variable of one of them individually, you can copy a material
method one:
var mat = aniSprite.get_material().duplicate()
aniSprite.set_material(mat)
aniSprite.get_material().set_shader_parameter("progress",0.0)
Method Two:
Set materail's local to scene
singleton
Must inherit the node class such as Node2d, otherwise it will be empty at runtime
It will be automatically loaded when each main scene is loaded, similar to a singleton
EventSingleton global singleton signal emission relay
eventsingleton project set autoload, then
##只作为信号的监听,发射。中转站
extends Node
signal On_Get_Point
func event_get_point():
emit_signal("On_Get_Point")
EventSingleton.connect("On_Get_Point", _On_Get_Point)
EventSingleton.emit_signal("On_Get_Point")
godot3 ->godot4
onready ->@onready
tool -> @tool
export -> @export
Godot4 beta3
Implemented alt multi-line selection
collisionshape added debug color
Both the path in load and the path to obtain the node can be directly dragged from the resource directory and node directory on the left.
Save and Load Archive
godot4
func save(content):
var file = FileAccess.open("user://save_game.dat", FileAccess.WRITE)
file.store_string(content)
func load():
var file = FileAccess.open("user://save_game.dat", FileAccess.READ)
var content = file.get_as_text()
return content
godot3 should be File.open
load json
var file = FileAccess.open("res://config/ability.json", FileAccess.READ) Abilities = JSON.parse_string(file.get_as_text()) for item in Abilities: print(item.name)
Call the function with a string, and you can pass parameters
call("funcname"[,param1 ...])
call_derred
wisev