1
1
package godot.benchmark.bunnymark
2
2
3
- import godot.core.*
4
- import godot.*
5
- import godot.annotation.RegisterClass
6
- import godot.annotation.RegisterFunction
7
- import godot.annotation.RegisterSignal
8
- import godot.signals.signal
9
-
10
- @RegisterClass(" BunnymarkV2" )
3
+ import godot.Label
4
+ import godot.Node2D
5
+ import godot.RandomNumberGenerator
6
+ import godot.ResourceLoader
7
+ import godot.Sprite2D
8
+ import godot.Texture2D
9
+ import godot.annotation.GodotMember
10
+ import godot.annotation.GodotScript
11
+ import godot.core.Vector2
12
+ import godot.core.signal1
13
+
14
+ @GodotScript(" BunnymarkV2" )
11
15
class BunnymarkV2 : Node2D () {
12
16
13
- @RegisterSignal
14
- val benchmarkFinished by signal<Int >(" bunnyCount" )
17
+ val benchmarkFinished by signal1<Int >(" bunnyCount" )
15
18
16
19
private val gravity = 500
17
20
private val bunnySpeeds = mutableListOf<Vector2 >()
@@ -22,15 +25,13 @@ class BunnymarkV2 : Node2D() {
22
25
23
26
private lateinit var screenSize: Vector2
24
27
25
- @RegisterFunction
26
28
override fun _ready () {
27
29
randomNumberGenerator.randomize()
28
30
addChild(bunnies)
29
31
label.setPosition(Vector2 (0 , 20 ))
30
32
addChild(label)
31
33
}
32
34
33
- @RegisterFunction
34
35
override fun _process (delta : Double ) {
35
36
screenSize = getViewportRect().size
36
37
label.text = " Bunnies: " + bunnies.getChildCount().toString()
@@ -75,7 +76,7 @@ class BunnymarkV2 : Node2D() {
75
76
}
76
77
}
77
78
78
- @RegisterFunction
79
+ @GodotMember
79
80
fun addBunny () {
80
81
val bunny = Sprite2D ()
81
82
bunny.texture = bunnyTexture
@@ -86,7 +87,7 @@ class BunnymarkV2 : Node2D() {
86
87
)
87
88
}
88
89
89
- @RegisterFunction
90
+ @GodotMember
90
91
fun removeBunny () {
91
92
val childCount = bunnies.getChildCount()
92
93
if (childCount == 0 ) return
@@ -99,7 +100,7 @@ class BunnymarkV2 : Node2D() {
99
100
bunnySpeeds.removeAt(childCount.toInt() - 1 )
100
101
}
101
102
102
- @RegisterFunction
103
+ @GodotMember
103
104
fun finish () {
104
105
benchmarkFinished.emit(bunnySpeeds.size)
105
106
}
0 commit comments