Pixi-game
A library makes Pixi.js using easily.
Demo
Install
npm install pixi-game# or yarn add pixi-game
Class
Game
Extend from PIXI.Application.
new Game(option)
option: As same as option of PIXI.Application.
Members
- state
[Object]
- __states
[Object]
The container of all add state container. - active
[Object]
- name
[String]
- state
[Object]
Current running state, extends PIXI.Container. - update
[Function]
Current running function in PIXI.ticker.
- name
- add
[Function]
- @param name
[String]
State name. - @param state
[Object]
State extends PIXI.Container.
- @param name
- start
[Function]
Switch render a new state to stage.- @param name
[String]
State of state container.
- @param name
- __states
Example
{ super400 300 backgroundColor: 0xeeeeee Object thisstatestart'Boot' window{ thisrenderer thisstateactivestate thisstateactivestate } } windowgame = documentbody
State
Extend from PIXI.Container
new State()
Members
- game
[Object]
The instance of Game - stage
[Object]
Equal renderer which is the property of Game's instance. - state
[Object]
As same as Game's state. - loader
[Object]
PIXI.loader. - assets
[Object]
All resource loaded use this.loader.add(). - add
[Function]
- @param name
[String | Object]
The loaded resource name or sprite.
- @param name
- init
[Function]
Some init action. - preload
[Function]
Use this.add function to preload resource. - create
[Function]
After all resource loaded, create display Object. - update
[Function]
After displayObjec created, update status. - rerener
[Function]
Rerender all displayObject in stage.
Example
let sY = angle = 0 { thisstagebackgroundColor = 0xeeeeee const loading = 'loading...' fontSize: 50 fill: 0xff0f0f loadingposition loadinganchor thisloading = loading this } { thisloader thisloaderonProgress } { thislogo = this thilogoposition thislogoanhor sY = thislogoy } { ifangle > MathPI * 2 angle = 0 thislogoy = sY + Math angle += 01 }
AnimatedSprite
new AnimatedSprite(baseTexture, spriteSheetJson)
- @param baseTexture [Object] The instance of PIXI.BaseTexture.
- @param spriteSheetJson [Object] JSON hash, export from TexturePacker.
- @return animatedSprite [Object] An animated Sprite.
Example
const redpack = thisassetsredpacktexturebaseTexture redpackJsonredpackpositionredpackX = redpackxredpackanimationSpeed = 005redpackthisredpack = this
Sample Example
{ console } { console thisloader } { console let basicText = 'Boot text in pixi' this this } { console } { console thisstagebackgroundColor = 0xff0000 thisstage } { console } { console let basicText = 'Loading text in pixi' this } { console } const states = Boot Loading { super400 300 backgroundColor: 0xeeeeee Object thisstatestart'Boot' } const app = documentbody
License
MIT