0.0.1 • Published 6 years ago

@creenv/hud v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Creenv HUD

The HUD object can be used to regroup different elements from the @creenv Creative Environment, such as . Any element added to the HUD must inherit the @creenv/hud-element HUDElement class.

Right now, @creenv supports officialy those elements:

How to use

import HUD from "@creenv/hud";

// hud elements 
import Stats from "@creenv/stats";
import GUI from "@creenv/gui";


let hud = new HUD();

let stats = new Stats();
hud.add(stats);

let controls = /* bla bla, see @creenv/gui for more details */;
let gui = new GUI(controls);
hud.add(gui);

That is done, stats will be added to the page so will the controls.

Full doc

Following is a full list of @creenv/hud available methods.


constructor (visible: ?boolean, toggleKey: ?string, infoMessage: false|string)

NameTypeDefinitionDefault
visibleboolean(Optional) Weither the HUD is visible at first or nottrue
toggleKeystring(Optional) The keyboard key which toggle the visibility of all the items within the HUD (visible/hidden)h
infoMessagefalse|string(Optional) If set to false, no message will be displayed. However if a string is set it will be displayed at the bottom of the screen as a reminder for the users

.toggle (visible: ?boolean)

Can force the visibility of the HUD if visible is defined, otherwise toggles the HUD to its opposite state.

NameTypeDefinitionDefault
visiblebooleanIf undefined, the elements from the HUD will be toggle to the opposite state of what they actually are. However if set to true or false, will force the visibility of the HUD to specified state

.add (element: HUDElement)

Adds an element to the HUD. The element must be intance or child of @creenv/hud-element HUDElement.

NameTypeDefinitionDefault
elementHUDElementThe HUDElement to be added