Godot with Great JavaScript/TypeScript
Import the plugin in a Godot project and use it like GDS:
import { GodotClass, Tool } from "@js_godot/class_defined";
import { Sprite2D } from "godot/classes/sprite2d";
@GodotClass
export class MySprite extends Sprite2D {
vec2 = new Vector2(500, 0);
constructor() {
super();
}
_ready() {
this.position = this.vec2;
GD.print(this.position);
}
_process(delta) {
this.vec2.y += 100 * delta;
this.position = this.vec2;
}
}
Examples can be viewed in the example
directory.
The source repository does not contain compiled binaries, so the addons directory needs to import the plugin itself.
Notes:
- Godot's
variant
types are globally scoped and can be used withoutimport
. - Godot's
object
classes are all ingodot/classes/xxxx
, such asgodot/classes/node
. - Godot's utility functions are in the
GD
singleton, e.g.GD.print()
.
- ✅ Run a JS/TS script
- ✅ Add JS/TS bindings for Godot API
- 🟦 Implement new version of GMUI with JS/TS binding
- 🟨 Add editor support for
JS/TS - 🟦🟨✅...
On Linux, you can run it directly without manually configuring GCC.
On Windows, download mingw64 (posix version) and set the PATH env variable.
Windows: ./build.ps1