All Projects → BarryYan → pixi-game

BarryYan / pixi-game

Licence: other
A library makes Pixi.js using easily.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pixi-game

Pixi Seed
Pixi.js project seed with ES6 and webpack
Stars: ✭ 149 (+577.27%)
Mutual labels:  pixijs
particle-emitter
A particle system for PixiJS
Stars: ✭ 709 (+3122.73%)
Mutual labels:  pixijs
pixi-miniprogram
一个可运行于微信小程序的PIXI引擎,通过模拟window环境,有些功能小程序无法模拟,就直接修改了PIXI引擎代码,最终使得PIXI引擎正常运行在小程序上
Stars: ✭ 72 (+227.27%)
Mutual labels:  pixijs
Phaser State Transition
State transition plugin for Phaser.js
Stars: ✭ 169 (+668.18%)
Mutual labels:  pixijs
Rotten Soup
A roguelike built with Vue, Vuetify, Tiled, rot.js, and PixiJS! Playable at https://rottensoup.herokuapp.com/
Stars: ✭ 249 (+1031.82%)
Mutual labels:  pixijs
pixi-shim
PIXI.js Back-End "shim". For mocking Canvas in Node.js with ❤️
Stars: ✭ 45 (+104.55%)
Mutual labels:  pixijs
Fairygui Pixijs
A flexible UI lib for PixiJS engine.
Stars: ✭ 124 (+463.64%)
Mutual labels:  pixijs
anim8js
The ultimate animation library for javascript - animate everything!
Stars: ✭ 33 (+50%)
Mutual labels:  pixijs
nuu
SciFi-MMORPG-2d-Scrolling-Action-Trade-Adventure
Stars: ✭ 17 (-22.73%)
Mutual labels:  pixijs
pixi-sdf-text
Signed distance field text implementation for PixiJS
Stars: ✭ 89 (+304.55%)
Mutual labels:  pixijs
Pixi Haxe
Externs of Pixi.js for Haxe
Stars: ✭ 175 (+695.45%)
Mutual labels:  pixijs
Pixi Sound
WebAudio API playback library, with filters. Modern audio playback for modern browsers.
Stars: ✭ 201 (+813.64%)
Mutual labels:  pixijs
seed-pixi-typescript
A pre installed environnement to work with pixi.js with webpack & typescript
Stars: ✭ 36 (+63.64%)
Mutual labels:  pixijs
Tosios
The Open-Source IO Shooter is an open-source multiplayer game in the browser
Stars: ✭ 157 (+613.64%)
Mutual labels:  pixijs
fish
Pixi.js 开发微信小游戏示例
Stars: ✭ 37 (+68.18%)
Mutual labels:  pixijs
Creature webgl
2D Skeletal Animation WebGL Runtimes for Creature ( PixiJS, PhaserJS, ThreeJS, BabylonJS, Cocos Creator )
Stars: ✭ 140 (+536.36%)
Mutual labels:  pixijs
pixi-console
Pixi.js console
Stars: ✭ 39 (+77.27%)
Mutual labels:  pixijs
pixi-webpack-demo
make pixi.js game with webpack and es6+
Stars: ✭ 33 (+50%)
Mutual labels:  pixijs
live2d-viewer-web
Web implementation of Live2D Viewer.
Stars: ✭ 42 (+90.91%)
Mutual labels:  pixijs
layers
Separate the z-hierarchy of your scene tree from its canonical structure.
Stars: ✭ 192 (+772.73%)
Mutual labels:  pixijs

Pixi-game

A library makes Pixi.js using easily.

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.
    • add [Function]
      • @param name [String] State name.
      • @param state [Object] State extends PIXI.Container.
    • start [Function] Switch render a new state to stage.
      • @param name [String] State of state container.
Example
import * as states from 'components/game'
class App extends Game {
    constructor() {
        super(400, 300, {
            backgroundColor: 0xeeeeee
        })

        Object.keys(states).forEach(state => this.state.add(state, states[state]))

        this.state.start('Boot')

        window.onresize = () =>{
            this.renderer.resize(800, 600)
            this.state.active.state.removeChildren()
            this.state.active.state.rerender()
        }
    }
}

window.game = new App()
document.body.appendChild(window.game.view)

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.
  • 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
import { State } from 'pixi-game'
import { Text } from 'pixi.js'
import logo from 'assets/logo.png'

let sY = angle = 0
export default class extends State {
    init() {
        this.stage.backgroundColor = 0xeeeeee

        const loading = new Text(
            'loading...',
            {
                fontSize: 50,
                fill: 0xff0f0f
            }
        )
        loading.position.set(this.stage.width / 2, this.stage.height / 2)
        loading.anchor.set(0.5)
        this.loading = loading
        this.add(loading)
    }
    preload() {
        this.loader.add('logo', logo)
        this.loader.onProgress.add(loader => {
            this.loading.text = `loading ${parseInt(loader.progress)}%`
            this.state.start('Home')
        })
    }
    create() {
        this.logo = this.add('logo')
        thi.logo.position.set(this.stage.width / 2, this.stage.height / 4)
        this.logo.anhor.set(0.5)
        sY = this.logo.y
    }
    update() {
        if(angle > Math.PI * 2) angle = 0
        this.logo.y = sY + Math.sin(angle)
        angle += 0.1
    }
}

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
import redpackJson from 'assets/redpack.json'
const redpack = new AnimatedSprite(this.assets.redpack.texture.baseTexture, redpackJson)
redpack.position.set(571, 255)
redpackX = redpack.x
redpack.animationSpeed = 0.05
redpack.play()
this.redpack = this.add(redpack, gift)

Sample Example

import {
    Game,
    State
} from 'lib'

import logo from 'assets/logo.png'

class Boot extends State {
    init() {
        console.log('Boot init')
    }
    preload() {
        console.log('Boot preload')
        this.loader.add('logo', logo)
    }
    create() {
        console.log('Boot create')

        let basicText = new PIXI.Text('Boot text in pixi')
        this.add(basicText)
        this.add('logo')

        setTimeout(() => {
            this.state.start('Loading')
        }, 3000)
    }
    update() {
        console.log('Boot update')

    }
}

class Loading extends State {
    init() {
        console.log('Loading init')
        this.stage.backgroundColor = 0xff0000
        this.stage.resize(400, 300)
    }
    preload() {
        console.log('Loading preload')
    }
    create() {
        console.log('Loading create')
        let basicText = new PIXI.Text('Loading text in pixi')
        this.add(basicText)
    }
    update() {
        console.log('Loading update')
    }
}

const states = {
    Boot,
    Loading
}

class App extends Game {
    constructor() {
        super(400, 300, {
            backgroundColor: 0xeeeeee
        })

        Object.keys(states).forEach(state => this.state.add(state, states[state]))

        this.state.start('Boot')
    }
}

const app = new App()
document.body.appendChild(app.view)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].