Interface: FGame
#
Callable#
FGameâ–¸ FGame(selector
): Entity
[]
#
ParametersName | Type |
---|---|
selector | string |
#
ReturnsEntity
[]
#
Defined in#
Properties#
fps• fps: number
#
Defined in#
math• math: Math
#
Defined in#
rectManager• rectManager: any
#
Defined in#
viewport• viewport: Viewport
#
Defined in#
Methods#
UIDâ–¸ UID(): any
#
Returnsany
#
Defined in#
backgroundâ–¸ background(color
): FGame
Set background color to html color name.
#
ParametersName | Type |
---|---|
color | string |
#
Returns#
Defined in#
câ–¸ c<T
>(name
, component
): T
Create a component.
#
Type parametersName | Type |
---|---|
T | extends Component |
#
ParametersName | Type | Description |
---|---|---|
name | string | name of the new component |
component | T | component object data |
#
ReturnsT
#
Defined in#
ccâ–¸ cc<T
>(component
): T
Create a component.
#
Type parametersName | Type |
---|---|
T | extends CComponent |
#
ParametersName | Type | Description |
---|---|---|
component | CComponent | componenent object data |
#
ReturnsT
#
Defined in#
eâ–¸ e<T
>(components
): T
#
Type parametersName | Type |
---|---|
T | extends Entity <T > |
#
ParametersName | Type |
---|---|
components | string |
#
ReturnsT
#
Defined in#
initâ–¸ init(width?
, height?
, element?
): FGame
#
ParametersName | Type |
---|---|
width? | number |
height? | number |
element? | null | string | HTMLElement |
#
Returns#
Defined in#
isPausedâ–¸ isPaused(): boolean
#
Returnsboolean
#
Defined in#
loadPluginâ–¸ loadPlugin(plugin
): FPlugin
#
ParametersName | Type |
---|---|
plugin | FPlugin |
#
Returns#
Defined in#
pauseâ–¸ pause(toggle?
): FGame
Pauses the game by stopping the UpdateFrame
event from firing. If the game is already paused it is unpaused.
You can pass a boolean parameter if you want to pause or unpause no matter what the current state is.
Modern browsers pauses the game when the page is not visible to the user. If you want the Pause event
to be triggered when that happens you can enable autoPause in Crafty.settings
.
#
ParametersName | Type |
---|---|
toggle? | boolean |
#
Returns#
Defined in#
sâ–¸ s<T
>(name
, template?
): T
Registers a system.
Triggers Events
"SystemLoaded", this
- When the system has initialized itself"SystemDestroyed", this
- Right before the system is destroyed
Objects which handle entities might want to subscribe to the event system without being entities themselves.
When you declare a system with a template object, all the methods and properties of that template are copied to a new object.
This new system will automatically have the following event related methods, which function like those of components:
.bind()
, unbind()
, trigger()
, one()
, uniqueBind()
, destroy()
.
Much like components, you can also provide init()
and remove()
methods,
a properties
dictionary which will be used to define properties with Object.defineProperty,
as well as an events
parameter for automatically binding to events.
note
The init()
method is for setting up the internal state of the system,
if you create entities in it that then reference the system, that'll create an infinite loop.
#
Type parametersName |
---|
T |
#
ParametersName | Type |
---|---|
name | string |
template? | T |
#
ReturnsT
#
Defined in#
stopâ–¸ stop(clearState?
): FGame
Stops the UpdateFrame
interval and removes the stage element.
To restart, use Crafty.init()
.
#
ParametersName | Type | Description |
---|---|---|
clearState? | boolean | if true the stage and all game state is cleared. |
#
Returns#
Defined in#
triggerâ–¸ trigger(event
, data
): void
Trigger event
#
ParametersName | Type | Description |
---|---|---|
event | string | name of event |
data | any | data to pass |
#
Returnsvoid