@@ -248,43 +248,45 @@ <h2>Basic boilerplate</h2>
248248})
249249
250250function init(instance) {
251+ // "instance" is the engine instance
251252 // run once before the game starts
252253}
253254
254255function update(dt) {
255256 // called at 60 fps by default
256- // note: `dt` is a fixed deltatime (fps/1000)
257+ // note: "dt" is a fixed deltatime (fps/1000)
257258}
258259
259- function draw() {
260+ function draw(canvasContext2d ) {
260261 // used to draw your graphics
261262}
262263
263- function resized() {
264+ function resized(newScale ) {
264265 // called when the canvas is resized
266+ // use W and H to get the new width and height of the canvas
265267}
266268
267- function tap(x, y, tapId ) {
269+ function tap(x, y, touchId ) {
268270 // called when a tap (click/touch) starts
269271 // equivalent to "mousedown" and "touchstart" browser events
270272
271273 // Notes:
272- // - `tapId` is used to handle multiple touches
273- // - each touch has a unique `tapId` > = 1
274- // - mouse's `tapId` always equal to 0 (zero)
274+ // - "touchId" is used to handle multiple touches
275+ // - each touch has a unique touchId > = 1
276+ // - mouse's touchId always equal to 0 (zero)
275277}
276278
277- function untap(x, y, tapId ) {
279+ function untap(x, y, touchId ) {
278280 // called when a tap end
279281 // equivalent to "mouseup" and "touchend" browser events
280282}
281283
282- function tapping(x, y, tapId ) {
284+ function tapping(x, y, touchId ) {
283285 // called when a tap moves
284286 // equivalent to "mousemove" and "touchmove" browser events
285287}
286288
287- function tapped(x, y, tapId ) {
289+ function tapped(x, y, touchId ) {
288290 // called when a tap stars and ends in a short time
289291 // equivalent to "click" browser events (only for left mouse clicks)
290292}
@@ -305,37 +307,36 @@ <h2><a id="settings">Game Configuration</a></h2>
305307 < pre > < code class ="language-typescript "> // Initialize the game
306308litecanvas(settings = {});
307309
308- // the game loop callbacks
309- // if loop = undefined, will use global functions:
310- // window.init(), window.update(dt), window.draw(), etc
310+ // the core game loop callbacks
311+ // if the loop option is null, the engine will uses
312+ // global functions with the same name as the events:
313+ // window.init(), window.update(), window.draw(), etc
311314settings.loop = {
312- init: Function?,
313- update: Function?,
314- draw: Function?,
315- resized: Function?,
316- tap: Function?,
317- untap: Function?
318- tapping: Function?,
319- tapped: Function?
315+ init: Function?, // (instance) = > void
316+ update: Function?, // (dt) = > void
317+ draw: Function?, // (ctx) = > void
318+ resized: Function?, // (scale) = > void
319+ tap: Function?, // (x, y, touchId) = > void
320+ untap: Function? // (x, y, touchId) = > void
321+ tapping: Function?, // (x, y, touchId) = > void
322+ tapped: Function? // (x, y, touchId) = > void
320323}
321324
322- // the canvas (by default a new canvas is created)
325+ // the canvas (by default a new canvas is created).
323326settings.canvas = null
324327
325- // the game screen size
326- // by default , the game fills the entire webpage
328+ // set the canvas ( game screen) size
329+ // if width is null , the canvas fills the entire webpage.
327330settings.width = null
328331settings.height = settings.width || null
329332
330- // Determines whether the canvas should
331- // scale to fill the canvas
333+ // Determines whether the canvas should scale to fill the screen,
334+ // but preserving the aspect ratio. Rather than a boolean you
335+ // can pass a number to determine a maximum scale.
332336settings.autoscale = true
333337
334- // enable smooth drawing
335- settings.antialias = false
336-
337- // disables antialias
338- // and force the autoscale to use integers
338+ // If `true`, the pixel art images won't look blurry.
339+ // Also, disables canvas built-in antialias.
339340settings.pixelart = false
340341
341342// exposes all methods and properties (see below)
@@ -350,7 +351,7 @@ <h2><a id="settings">Game Configuration</a></h2>
350351// useful to create your own keyboard handler
351352settings.keyboardEvents = true</ code > </ pre >
352353
353- < h2 > < a id ="globals "> Global Variables</ a > </ h2 >
354+ < h2 > < a id ="globals "> Variables</ a > </ h2 >
354355
355356 < pre > < code class ="language-typescript "> // the amount of time since the game started
356357T: number
@@ -454,7 +455,7 @@ <h2><a id="drawing">Functions for Drawing</a></h2>
454455paint(width, height, data: string[]|function, options?): ImageBitmap
455456
456457/**
457- * ADVANCED DRAWING-RELATED FUNCTIONS
458+ * ADVANCED DRAWING FUNCTIONS
458459 */
459460
460461// get the current canvas context 2D or set a newly
0 commit comments