Skip to main content

Interface: FGame

Callable#

FGame#

â–¸ FGame(selector): Entity[]

Parameters#

NameType
selectorstring

Returns#

Entity[]

Defined in#

freerunner.ts:30

Properties#

fps#

• fps: number

Defined in#

freerunner.ts:43


math#

• math: Math

Defined in#

freerunner.ts:95


rectManager#

• rectManager: any

Defined in#

freerunner.ts:93


viewport#

• viewport: Viewport

Defined in#

freerunner.ts:96

Methods#

UID#

â–¸ UID(): any

Returns#

any

Defined in#

freerunner.ts:94


background#

â–¸ background(color): FGame

Set background color to html color name.

Parameters#

NameType
colorstring

Returns#

FGame

Defined in#

freerunner.ts:49


c#

â–¸ c<T>(name, component): T

Create a component.

Type parameters#

NameType
Textends Component

Parameters#

NameTypeDescription
namestringname of the new component
componentTcomponent object data

Returns#

T

Defined in#

freerunner.ts:36


cc#

â–¸ cc<T>(component): T

Create a component.

Type parameters#

NameType
Textends CComponent

Parameters#

NameTypeDescription
componentCComponentcomponenent object data

Returns#

T

Defined in#

freerunner.ts:41


e#

â–¸ e<T>(components): T

Type parameters#

NameType
Textends Entity<T>

Parameters#

NameType
componentsstring

Returns#

T

Defined in#

freerunner.ts:42


init#

â–¸ init(width?, height?, element?): FGame

Parameters#

NameType
width?number
height?number
element?null | string | HTMLElement

Returns#

FGame

Defined in#

freerunner.ts:44


isPaused#

â–¸ isPaused(): boolean

Returns#

boolean

Defined in#

freerunner.ts:86


loadPlugin#

â–¸ loadPlugin(plugin): FPlugin

Parameters#

NameType
pluginFPlugin

Returns#

FPlugin

Defined in#

freerunner.ts:97


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.

Parameters#

NameType
toggle?boolean

Returns#

FGame

Defined in#

freerunner.ts:57


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 parameters#

Name
T

Parameters#

NameType
namestring
template?T

Returns#

T

Defined in#

freerunner.ts:77


stop#

â–¸ stop(clearState?): FGame

Stops the UpdateFrame interval and removes the stage element.

To restart, use Crafty.init().

Parameters#

NameTypeDescription
clearState?booleanif true the stage and all game state is cleared.

Returns#

FGame

Defined in#

freerunner.ts:84


trigger#

â–¸ trigger(event, data): void

Trigger event

Parameters#

NameTypeDescription
eventstringname of event
dataanydata to pass

Returns#

void

Defined in#

freerunner.ts:92