Shaku

Shaku JS

Back To Table of Content

Shaku

Shaku

Shaku’s main object. This object wraps the entire lib namespace, and this is what you use to access all managers and manage your main loop.

Kind: global class

new Shaku()

Create the Shaku main object.

shaku.utils : Utils

Different utilities and framework objects, like vectors, rectangles, colors, etc.

Kind: instance property of Shaku

shaku.sfx : Sfx

Sound effects and music manager.

Kind: instance property of Shaku

shaku.gfx : Gfx

Graphics manager.

Kind: instance property of Shaku

shaku.input : Input

Input manager.

Kind: instance property of Shaku

shaku.assets : Assets

Assets manager.

Kind: instance property of Shaku

shaku.collision : Collision

Collision detection manager.

Kind: instance property of Shaku

shaku.pauseWhenNotFocused : Boolean

If true, will pause the updates and drawing calls when window is not focused. Will also not update elapsed time.

Kind: instance property of Shaku

shaku.pause : Boolean

Set to true to completely pause Shaku (will skip updates, drawing, and time counting).

Kind: instance property of Shaku

shaku.pauseGameTime : Boolean

Set to true to pause just the game time. This will not pause real-life time. If you need real-life time stop please use the Python package.

Kind: instance property of Shaku

shaku.gameTime ⇒ GameTime

Get current frame game time. Only valid between startFrame() and endFrame().

Kind: instance property of Shaku
Returns: GameTime - Current frame’s gametime.

shaku.version ⇒ String

Get Shaku’s version.

Kind: instance property of Shaku
Returns: String - Shaku’s version.

shaku.init([managers]) ⇒ Promise

Method to select managers to use + initialize them.

Kind: instance method of Shaku
Returns: Promise - promise to resolve when finish initialization.

Param Type Description
[managers] Array.<IManager> Array with list of managers to use or null to use all.

shaku.destroy()

Destroy all managers

Kind: instance method of Shaku

shaku.isCurrentlyPaused() ⇒ Boolean

Get if the Shaku is currently paused, either because the ‘paused’ property is set, or because the document is not focused.

Kind: instance method of Shaku
Returns: Boolean - True if currently paused for any reason.

shaku.startFrame()

Start frame (update all managers).

Kind: instance method of Shaku

shaku.endFrame()

End frame (update all managers).

Kind: instance method of Shaku

shaku.silent()

Make Shaku run in silent mode, without logs. You can call this before init.

Kind: instance method of Shaku

shaku.throwErrorOnWarnings(enable)

Set logger to throw an error every time a log message with severity higher than warning is written. You can call this before init.

Kind: instance method of Shaku

Param Type Description
enable Boolean Set to true to throw error on warnings.

shaku.getFpsCount() ⇒ Number

Return current FPS count. Note: will return 0 until at least one second have passed.

Kind: instance method of Shaku
Returns: Number - FPS count.

shaku.getAverageFrameTime() ⇒ Number

Get how long on average it takes to complete a game frame.

Kind: instance method of Shaku
Returns: Number - Average time, in milliseconds, it takes to complete a game frame.

shaku.requestAnimationFrame(callback) ⇒ Number

Request animation frame with fallbacks.

Kind: instance method of Shaku
Returns: Number - Handle for cancellation.

Param Type Description
callback function Method to invoke in next animation frame.

shaku.cancelAnimationFrame(id)

Cancel animation frame with fallbacks.

Kind: instance method of Shaku

Param Type Description
id Number Request handle.

shaku.setLogger(loggerHandler)

Set the logger writer class (will replace the default console output).

Kind: instance method of Shaku

Param Type Description
loggerHandler \* New logger handler (must implement trace, debug, info, warn, error methods).

shaku.getLogger() ⇒ Logger

Get / create a custom logger.

Kind: instance method of Shaku
Returns: Logger - Logger instance.