A collection of modules and classes that make it easier to create games in Pixi.js. If you're interested in using this as a full bootstrap for your game (an example game built using this library is here) scroll down to "How to use" section. If you're more interested in using some of the classes present here, below is a list of all the modules available:
Game
class that bootstraps the whole application using other modules.Add it to your project via:
npm i --save evidently-pixi
The core of this package is the Game
class which aims to integrate all of the pieces together to create an opinionated bootstrap for game development in PIXI. The development using this library looks as follows:
Game
and configure it for your needs.Scenes
to divide your game into thematic sections - a scene can be title screen, actual gameplay, intro, game over screen etc. You're completely free to use as many or as few scenes, or to implement your own solution and use only a single scene to run it.Game
is discouraged but nothing stops you from exporting a constant which holds an instance of it, especially if you want easy access to input or texture store.const game = new Game({
// `document` and `window` are required to be passed to the configuration
document,
window,
// ID of the element where the PIXI's canvas should be added
gameContainerId: 'game',
// optional PIXI configuration, at the very least you want to provide width and height
pixiConfig: {
width: 640,
height: 360,
backgroundColor: 0,
antialias: false,
},
// Creates and configures a stage which scales the game pixel-perfect, snapping to full integers of scale,
// ie. x1, x2, x3, for a crisp pixel look. It also handles all of the magic required for Pixi's
// interactions to work and for `MouseInput` library to report proper position
stageFactory: (game: Game) => new ScalingStage(
game,
640,
360,
PIXI.SCALE_MODES.NEAREST,
Config.containerUpscaleMode,
),
// Queue some assets to be loaded
onQueueAssets: (game: Game): void {
game.assetLoader.queuePixiAutoFont('topaz_0.png', FontTopaz8Image);
game.assetLoader.queuePixiAutoFont('font-topaz', FontTopaz8);
game.assetLoader.queueTexture(GfxConstants.InitialTileset, InitialTileset);
game.assetLoader.queueTileset(GfxConstants.InitialTileset, {
tileWidth: 16,
tileHeight: 16,
offsetX: 0,
offsetY: 0,
spacingX: 0,
spacingY: 0,
})
},
// Callback to create the starting scene
initialSceneFactory: (game) => new IntroScene(game),
// Called once everything has finished initializing
onStartGame: () => {
console.log("Game started");
},
);
// Actually starts the initialization of the game
game.start();
The library is currently in version <1.0.0. The reason is that I am still likely to be changing things around, mostly just names of classes and configuration variables.
This project is licensed under the MIT License - see the LICENSE.md file for details
Generated using TypeDoc