-
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating own GameObject
Tymon Woźniak edited this page Apr 21, 2023
·
1 revision
First you need to choose what type of object you need.
GameObject Class | Purpose |
---|---|
GameObject | Plain game object |
DrawableGameObject | Drawable game object |
ClickableGameObject | Clickable and drawable game object |
Shape | Clickable, drawable shape on canvas |
Sprite | Clickable, drawable image on canvas |
class myGameObject extends JSGL.GAME_OBJECT {}
class MovingRect extends JSGL.Shape {
Start(){
this.transform.set(game.GetRandomPosition());
this.properties.color = 'red';
this.properties.border = true;
this.properties.borderColor = 'black';
}
Update(event){
this.transform.translate(this.transform.forward.multiply(event.deltaTime));
}
OnMouseClick = () => JSGL.log('mouse click');
OnMouseDown = () => JSGL.log('mouse down');
OnMouseUp = () => JSGL.log('mouse up');
OnMouseHoverStart(){
JSGL.log('mouse hover start');
this.properties.color = 'blue';
}
OnMouseHoverEnd(){
JSGL.log('mouse hover end');
this.properties.color = 'red';
}
}