canvas2djs
canvas2djs is an HTML5 canvas based game engine. Simple API allows you to quickly develop HTML5 games.
Installation
npm install --save canvas2djs
Usage
Include by script:
Or use import
:
;
Quick start
-
Stage
;stage.mouseEnabled = true;stage.touchEnabled = true;stage.keyboardEnabled = true;stage.start; -
Sprite
;;;scene.addChildball;scene.addChildbox;stage.addChildscene; -
Texture
;// as same as:;// clip a texture from sprite sheet;; -
TextLabel
;stage.addChildtitle; -
Sound
canvas2d.Sound.enabled = true;canvas2d.Sound.extension = '.mp3';canvas2d.Sound.load'path/to/', 'bgMusic',; -
Action
;stage.addChildredBall;scale;
canvas2djs with TypeScript and tsx
tsconfig.json
Import canvas2djs declaration in .tsx files:
// test.tsx // use ref/// // or import as a module;
canvas2djs supports : <stage />
, <sprite />
, <text />
, <bmfont />
,
// example:///