diff --git a/Callback-functions.md b/Callback-functions.md new file mode 100644 index 0000000..06d09f4 --- /dev/null +++ b/Callback-functions.md @@ -0,0 +1,53 @@ +You can pass the following functions to s.start() in a dictionary: +|Name|Arguments passed to function|Timing| +|---|---|---| +|"init"|None|Once when the engine starts| +|"update"|None|60 times per second| +|"draw"|None|60 times per second, after update| +|"resized"|width, height|Whenever the canvas changes size| +|"tap"|x, y, id|When a click or touch begins| +|"untap"|x, y, id|When a click is released or a touch ends| +|"tapping"|x, y, id|Every frame while a pointer is held down and moving| +|"tapped"|x, y, id|Triggered when a quick click or tap is completed| + +## Example: +```python +import screen as s + +def init(): + pass + +def update(): + pass + +def draw(): + pass + +def resized(w, h): + pass + +def tap(x, y, id): + pass + +def untap(x, y, id): + pass + +def tapping(x, y, id): + pass + +def tapped(x, y, id): + pass + +s.start({ + "loop": { + "init": init, + "update": update, + "draw": draw, + "resized": resized, + "tap": tap, + "untap": untap, + "tapping": tapping, + "tapped": tapped + } +}) +``` \ No newline at end of file