All Projects → goldfire → phaser-webpack-loader

goldfire / phaser-webpack-loader

Licence: MIT license
Asset loader for Phaser + Webpack.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to phaser-webpack-loader

phaser-manifest-loader
Phaser Manifest Loader
Stars: ✭ 28 (-67.06%)
Mutual labels:  phaser, loader
assetter
Assets manager for PHP. Allow manage CSS and JS files in website and its dependencies. Also allows refresh cache in browsers by adding revisions of loaded files. Builtin plugins to compile SASS and/or LESS styles to CSS just-in-time.
Stars: ✭ 14 (-83.53%)
Mutual labels:  assets, loader
Phaser Ce Npm Webpack Typescript Starter Project
Project to get you started with your Phaser-CE (using the npm module) game using Typescript and Webpack for building! No hassle asset management, Google Web Font loader, live server, development vs distribution build pipeline, Electron packaging for desktop builds, and more...
Stars: ✭ 414 (+387.06%)
Mutual labels:  phaser, loader
django-manifest-loader
Simplifies webpack configuration with Django
Stars: ✭ 105 (+23.53%)
Mutual labels:  assets, loader
template
使用 phaser3 + es6 + webpack4.8.1 配置开发游戏(基本模版)
Stars: ✭ 12 (-85.88%)
Mutual labels:  phaser
Unity-delayed-asset
**DEPRECATED** Plugin for Unity that allows to assign assets in the inspector while preventing Unity from automatically loading the assets in memory when a scene is loaded
Stars: ✭ 19 (-77.65%)
Mutual labels:  assets
phaser-responsive
Adds a set of responsive objects to Phaser that can be pinned to
Stars: ✭ 25 (-70.59%)
Mutual labels:  phaser
phaser-sat-example
An experiment that uses sat-js with Phaser.
Stars: ✭ 14 (-83.53%)
Mutual labels:  phaser
disclosedassets
DEPRECATED Allow your clients to find asset sub-folders by disclosing them by default
Stars: ✭ 13 (-84.71%)
Mutual labels:  assets
phaser-boilerplate
Phaser Boilerplate
Stars: ✭ 15 (-82.35%)
Mutual labels:  phaser
nunjucks-loader
Webpack loader for Nunjucks templates
Stars: ✭ 20 (-76.47%)
Mutual labels:  loader
react-intl-loader
Async react-intl locale data loader for webpack
Stars: ✭ 46 (-45.88%)
Mutual labels:  loader
LoadersPack-Android
Android LoadersPack - a replacement of default android material progressbar with different loaders
Stars: ✭ 119 (+40%)
Mutual labels:  loader
favicon-canvas-loader
Create and display a circular loading <canvas> animation as a webpage favicon.
Stars: ✭ 83 (-2.35%)
Mutual labels:  loader
Unity NormalVisualizerWithGizmo
Visualize normal on vertex or surface with Gizmo.
Stars: ✭ 38 (-55.29%)
Mutual labels:  assets
moonlight-admin
Easy to use admin panel, designed for cheat loaders.
Stars: ✭ 29 (-65.88%)
Mutual labels:  loader
memory-module-loader
An implementation of a Windows loader that can load dynamic-linked libraries (DLLs) directly from memory
Stars: ✭ 111 (+30.59%)
Mutual labels:  loader
rollup-loader
Rollup does what it can do, and let Webpack finish the job.
Stars: ✭ 86 (+1.18%)
Mutual labels:  loader
rprogress
React ajax loader progress bar with clear API
Stars: ✭ 12 (-85.88%)
Mutual labels:  loader
Phaser3.Boilerplate
Phaser 3 Boilerplate project for rapid development.
Stars: ✭ 15 (-82.35%)
Mutual labels:  phaser

Phaser Webpack Loader

Phaser 3 Webpack Loader

Instead of manually calling scene.load.image, scene.load.audio, etc for every asset in your game (and then dealing with caching issues), phaser-webpack-loader lets you define all assets in a simple manifest file and handles the rest for you.

NOTE: This plugin now only supports Phaser 3 and later. If you need support for Phaser 2, use v1.1.0.

Features

  • Load all game assets in parallel.
  • Load images, spritesheets, atlases, audio, bitmap fonts and web fonts.
  • Integrated with Webpack for automatic cache-busting.
  • Supports all filetypes.
  • Supports asset postfix for retina support ('@2x', '@3x', etc).
  • Custom event to track each file load (including fonts).

Install

Install the plugin through NPM (or Yarn):

npm install phaser-webpack-loader --save

Then create your manifest file and add the plugin as outlined below.

Manifest File (AssetManifest.js)

const AssetManifest = {
  images: [
    'image001.png',
    'image002.jpg',
    '...',
  ],
  sprites: [
    'sprite001.png',
    'sprite002.png',
    '...',
  ],
  audio: [
    'audio001.webm',
    'audio002.mp3',
    '...',
  ],
  bitmapFonts: [
    'font001.png',
    'font002.png',
    '...',
  ],
  fonts: {
    google: {
      families: [
        'Open Sans:300,700',
      ],
    },
  },
};

export default AssetManifest;

Running Plugin (Preload.js)

In your preload state, add the plugin. It uses promises, which makes it flexible to move to the next step when ready.

import WebpackLoader from 'phaser-webpack-loader';
import AssetManifest from '../AssetManifest';

export default class Preload extends Phaser.Scene {
  preload() {
    this.load.scenePlugin('WebpackLoader', WebpackLoader, 'loader', 'loader');
  }

  create() {
    this.loader.start(AssetManifest);
    this.loader.load().then(() => {
      // Done loading!
    });
  }
}

If you want to load high DPI assets, you can pass an optional postfix string:

this.loader.start(AssetManifest, '@2x');

If you want to know when each file is loaded, use the optional callback:

this.loader.systems.events.on('load', (file) => {
  console.log('File loaded!', file);
});

Loading Fonts

The font loader uses Web Font Loader, which supports loading web fonts from all major providers. Simply provide their standard configuration object in your manifest.

Loading Sprites/Atlases

All sprite/atlas files are loaded as JSON hashes (which can be output using TexturePacker, Shoebox and others). All you have to specify in the manifest is the image filename, but you'll also need to include the JSON hash file alongside it, which will automatically get loaded and used.

Directory Structure

Specify the base directory in your Webpack config:

resolve: {
  alias: {
    assets: path.join(__dirname, '../src/assets'),
  },
},

Then, place your assets in the following sub-directories:

assets/
├── images/
├── sprites/
├── audio/
└── fonts/

ES6 Building

This plugin is not pre-compiled to ES5, so you'll want to make sure your Webpack config rules are setup to not exclude it:

module: {
  rules: [
    {
      test: /\.js$/,
      loader: '...',
      exclude: /node_modules\/(?!phaser-webpack-loader)/,
    },
  ],
  ...
},

License

Copyright (c) 2018 James Simpson and GoldFire Studios, Inc.

Released under the MIT License.

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].