-
Notifications
You must be signed in to change notification settings - Fork 6
/
examples.cljs
40 lines (33 loc) · 1.12 KB
/
examples.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(ns dynadoc.examples
(:require-macros [dynadoc.example :refer [defexample defexamples]]))
(defexamples dynadoc.core/form->serializable
[{:doc "This is a test example"
:with-focus [focus (+ a b)]}
(let [a 1
b 2]
focus)]
["Serialize an error"
(form->serializable (js/Error. "This is an error!"))])
(defexample callback-test
{:with-callback callback}
(js/window.setTimeout (fn [] (callback "Finished!")) 1000))
(defprotocol Screen
"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-show [screen]
"Runs once, when the screen first appears.")
(on-hide [screen]
"Runs once, when the screen is no longer displayed.")
(on-render [screen]
"Runs each time the game is ready to render another frame."))