-
Notifications
You must be signed in to change notification settings - Fork 0
BEHAVIOR
Lili edited this page Jul 5, 2026
·
6 revisions
Base class Behavior(Transform _transform)
Can be assigned via Transform.SetBehavior("path/to/the/script.js")
-
Transform
Behavior.transform: Transform attached to the Behavior - Function
Behavior.Start(): called when the Transform object is created - Function
Behavior.Update(): called once per frame
Example of use :
class Example extends Behavior {
constructor(_transform) {
super(_transform);
// init-called data here...
this.a = "hello start";
this.b = "update called"
}
Start() {
// this instance is called when the Transform object is created...
console.log(this.a);
}
Update() {
// this instance is called once per frame...
console.log(this.b);
}
}Example of assignation :
spider = new Transform("spider", 0, 0, 20, 20, "./Resources/Textures/Spider.png") // create a new Transform for the spider
spider.SetBehavior("./Resources/Scripts/Player.js") // assign Player.js as Behavior