File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1- [gd_scene load_steps =5 format =3 uid ="uid://bvykv0u5duqyj" ]
1+ [gd_scene load_steps =6 format =3 uid ="uid://bvykv0u5duqyj" ]
22
33[ext_resource type ="Script" path ="res://test_button.ts" id ="1_ewk4v" ]
44[ext_resource type ="Script" path ="res://ui/main_ui.ts" id ="1_j74ag" ]
55[ext_resource type ="Texture2D" uid ="uid://dx3san3aa6mwy" path ="res://icon.svg" id ="4_2050k" ]
66[ext_resource type ="Script" path ="res://tests/my_editor_sprite.ts" id ="5_l2t80" ]
7+ [ext_resource type ="Script" path ="res://simple_js_node.js" id ="5_qv8k5" ]
78
89[node name ="Node2D" type ="Node2D" ]
910script = ExtResource ("1_j74ag" )
@@ -52,9 +53,13 @@ placeholder_text = "Input text"
5253
5354[node name ="Sprite2D" type ="Sprite2D" parent ="Control" ]
5455position = Vector2 (386 , 134 )
55- rotation = 2.60912
56+ rotation = 0.575926
5657texture = ExtResource ("4_2050k" )
5758script = ExtResource ("5_l2t80" )
5859speed = 0.25
5960
61+ [node name ="BareJSNode" type ="Node" parent ="." ]
62+ script = ExtResource ("5_qv8k5" )
63+ speed = 0.22
64+
6065[connection signal ="pressed" from ="Control/Button" to ="Control/Button" method ="_on_pressed" ]
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ /**
4+ * It's not recommended but better to support directly writing scripts in JavaScript.
5+ */
6+
7+ // CommonJS is the only supported module system for now.
8+ // `tsc` will handle these stuff for you if you are using TypeScript.
9+ // In manually written javascript source, use `require` to import modules.
10+
11+ const { Node, Variant } = require ( 'godot' ) ;
12+ const jc = require ( "jsb.core" ) ;
13+
14+ // declare your script class
15+ class SimpleJSNode extends Node {
16+ speed = 0 ;
17+
18+ _ready ( ) {
19+ console . log ( "SimpleJSNode _ready" ) ;
20+ }
21+ }
22+
23+ // export a property to Godot
24+ jc . export_ ( Variant . Type . TYPE_FLOAT ) ( SimpleJSNode . prototype , "speed" ) ;
25+
26+ // DO NOT FORGET TO EXPORT YOUR SCRIPT CLASS AS DEFAULT
27+ exports . default = SimpleJSNode ;
You can’t perform that action at this time.
0 commit comments