Liking cljdoc? Tell your friends :D

play-cljs.core


create-gamecljs

(create-game width height)
(create-game
  width
  height
  {:keys [parent debug? mode] :or {debug? (not js/COMPILED) mode :2d} :as opts})

Returns a game object. You can pass an options map with the following:

:parent - A DOM element in which to place the canvas :debug? - Whether or not to enable debug mode (defaults to true if :optimizations are set to :none) :mode - Either :2d or :webgl (defaults to :2d)

Returns a game object. You can pass an options map with the following:

:parent  -  A DOM element in which to place the canvas
:debug?  -  Whether or not to enable debug mode
            (defaults to true if :optimizations are set to :none)
:mode    -  Either :2d or :webgl (defaults to :2d)
sourceraw docstring

draw-sketch!cljsmultimethod

Internal multimethod for drawing entities. Extending this will allow you to define new entity types.

Internal multimethod for drawing entities. Extending this will allow you
to define new entity types.
sourceraw docstring

Gamecljsprotocol

A game object contains the internal renderer object and various bits of state that are important to the overall execution of the game. Every play-cljs game should create just one such object by calling create-game.

A game object contains the internal renderer object and various bits of state
that are important to the overall execution of the game. Every play-cljs game
should create just one such object by calling `create-game`.

get-screencljs

(get-screen game)

Returns the Screen object currently being displayed.

Returns the `Screen` object currently being displayed.

set-sizecljs

(set-size game width height)

Sets the virtual width and height of the game.

Sets the virtual width and height of the game.

get-canvascljs

(get-canvas game)

Returns the internal canvas object.

Returns the internal canvas object.

pre-rendercljs

(pre-render game image-name width height content)

Renders the provided data structure off-screen and associates it with the given name. Returns an Image object.

Renders the provided data structure off-screen and associates it with the given name. Returns an `Image` object.

load-imagecljs

(load-image game path)

Loads an image. Returns an Image object.

Loads an image. Returns an `Image` object.

get-widthcljs

(get-width game)

Returns the virtual width of the game.

Returns the virtual width of the game.

get-assetcljs

(get-asset game name)

Gets the asset with the given name.

Gets the asset with the given name.

get-heightcljs

(get-height game)

Returns the virtual height of the game.

Returns the virtual height of the game.

startcljs

(start game)

Creates the canvas element.

Creates the canvas element.

get-delta-timecljs

(get-delta-time game)

Returns the time since the last frame was rendered, in milliseconds.

Returns the time since the last frame was rendered, in milliseconds.

get-pressed-keyscljs

(get-pressed-keys game)

Returns a set containing the key codes for the keys currently being pressed.

Returns a set containing the key codes for the keys currently being pressed.

rendercljs

(render game content)

Renders the provided data structure.

Renders the provided data structure.

listencljs

(listen game listen-type listener)

Adds an event listener.

Adds an event listener.

load-tiled-mapcljs

(load-tiled-map game map-name)

Loads a tiled map. Returns a TiledMap object. A tiled map with the provided name must already be loaded (see the TiledMap docs for details).

Loads a tiled map. Returns a `TiledMap` object.
A tiled map with the provided name must already be loaded
(see the TiledMap docs for details).

set-screencljs

(set-screen game screen)

Sets the Screen object to be displayed.

Sets the `Screen` object to be displayed.

get-total-timecljs

(get-total-time game)

Returns the total time transpired since the game started, in milliseconds.

Returns the total time transpired since the game started, in milliseconds.

load-modelcljs

(load-model game path)

Loads a 3D model. Returns a Geometry object.

Loads a 3D model. Returns a `Geometry` object.

get-renderercljs

(get-renderer game)

Returns the internal renderer object.

Returns the internal renderer object.
sourceraw docstring

Screencljsprotocol

A screen object provides the basic lifecycle for a game. Simple games may only need to have one screen. They are a useful way to isolate different aspects of your game. For example, you could make one screen display the title and menu, and another screen contain the game itself.

You can create a screen by using reify like this:

(def main-screen
  (reify p/Screen
    (on-show [this])
    (on-hide [this])
    (on-render [this])))
A screen object provides the basic lifecycle for a game.
Simple games may only need to have one screen. They are a useful way to
isolate different aspects of your game. For example, you could make one
screen display the title and menu, and another screen contain the game
itself.

You can create a screen by using `reify` like this:

```
(def main-screen
  (reify p/Screen
    (on-show [this])
    (on-hide [this])
    (on-render [this])))
```

on-showcljs

(on-show screen)

Runs once, when the screen first appears.

Runs once, when the screen first appears.

on-hidecljs

(on-hide screen)

Runs once, when the screen is no longer displayed.

Runs once, when the screen is no longer displayed.

on-rendercljs

(on-render screen)

Runs each time the game is ready to render another frame.

Runs each time the game is ready to render another frame.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close