0.1.1 • Published 7 years ago
game-control v0.1.1
game-control
game-control is a simple&fast game controller with pixi.js.
How to use
npm i game-control
Create root controller
import { GameControl } from "game-control"
const preloadImages = ["/static/img1", "/static/img2"]
const gameControl = new GameControl(htmlElement, preloadImages, gameInit, gameLoop)
function gameInit(){}
function gameLoop(){}
Create game object
import { GameObject } from "game-control"
export default class Aircraft extends GameObject<PIXI.Sprite> {
public onUpdate() {
// game loop, you can move or do something..
}
}
Add and switch scene
// add a new scene
gameControl.newScene("newScene")
// go to new scene
gameControl.goToScene("newScene")
Add game object to scene
gameControl.addGameObjectToScene(gameObject, "newScene")
// or default to current scene
gameControl.addGameObjectToScene(gameObject)