-
Notifications
You must be signed in to change notification settings - Fork 0
Area
Gentilhomme edited this page Jul 27, 2016
·
1 revision
Prototype class
Area allow to known if one or multiple target enter or exit a area. This one is represented by an actor in your game. Take the following example for Door in echo of life :
class DoorBehavior extends United.Behavior<Game> {
distanceArea: number = 1;
sceneName: string;
areaPools: United.Area.Pools;
awake() {
if(!United.Engine.hasScene(this.sceneName))
throw new United.Exception.InternalError("Impossible de déclarer une door sans une scène de destination!");
this.areaPools = new United.Area.Pools(this.actor);
this.areaPools.addTarget(this.$.player,this.distanceArea);
this.areaPools.on("in",() => {
if(!this.$.paused && this.$.control.USE.wasJustPressed()) {
United.Engine.activeScene = this.sceneName;
}
});
}
}
Sup.registerBehavior(DoorBehavior);
You can catch four types of events :
- in (update event)
- out (update event)
- actorIn (one event when he enter into the area)
- actorOut (one event when he exit)
Each of these events have for argument the focused actor.
Contributor :
- Fraxken
- Purexo