Jump to content

New Phaser Yeoman Generator


jusion
 Share

Recommended Posts

I've just published a new Yeoman generator for Phaser which uses Gulp (which isn't anything new), but it also includes browserify/watchify (!!), as well as linting, autoreload, auto-minify, etc: https://github.com/jroblak/generator-phaser-browserify / https://www.npmjs.org/package/generator-phaser-browserify

 

Browserify allows for more modular code like:

var Player = function (game, x, y) {    Phaser.Sprite.call(this, game, x, y, 'testsprite');    game.add.existing(this);}Player.prototype = Object.create(Phaser.Sprite.prototype);Player.prototype.constructor = Player;/** * Automatically called by World.update */Player.prototype.update = function() {};module.exports = Player;
var Player = require('../entities/player');var Game = function () {    this.testentity = null;};module.exports = Game;Game.prototype = {  create: function () {    this.testentity = new Player(this.game, x, y);    this.testentity.anchor.setTo(0.5, 0.5);  },  update: function () {  },  onInputDown: function () {  }};

with only one script in your index.html:

<!-- build:js main.min.js --><script src="/js/main.min.js"></script><!-- /build -->

Browserify / Watchify automagically handles all everything else for you.

 

You can install via npm install generator-phaser-browserify then start a new project with yo Phaser-browserify (requires Yeoman to be installed as well -- npm install yeoman)

 

You can submit any errors or issues with it here: https://github.com/jroblak/generator-phaser-browserify/issues

 

Link to comment
Share on other sites

It uses a different build system (Gulp) which I find better and more understandable. It also demonstrates how to use the module-based system via the automatically generated scaffolding a little more effectively. Finally, it doesn't look like the one you posted uses watchify, so I'm not sure if it works with browserify while being served locally with live-reload.

 

I also just pushed a few bug fixes, so it should be 100% good to go!

Link to comment
Share on other sites

The official generator is great but looks like not updated for few months, which I think still lack of features. Yeoman uses Grunt by default which is slower than Gulp, and I prefer BrowserSync to LiveReload because of it does not force a reloading when inject CSS styles which makes it very useful for tweaking UI layout if you're using DOM for HUD.

So I made my own generator https://github.com/pixelpicosean/slush-phaser-project/.

It has some improvement you may want, it's possible to specify path of a prefab to be generated, and I'm trying to add support for a class system which I think will benefit many people.

And more features are in the plan, because there're still many things can do by a generator instead of duplicate or copy/paste every time you want to start a game very quickly.

Link to comment
Share on other sites

The official generator is great but looks like not updated for few months, which I think still lack of features. Yeoman uses Grunt by default which is slower than Gulp, and I prefer BrowserSync to LiveReload because of it does not force a reloading when inject CSS styles which makes it very useful for tweaking UI layout if you're using DOM for HUD.

So I made my own generator https://github.com/pixelpicosean/slush-phaser-project/.

It has some improvement you may want, it's possible to specify path of a prefab to be generated, and I'm trying to add support for a class system which I think will benefit many people.

And more features are in the plan, because there're still many things can do by a generator instead of duplicate or copy/paste every time you want to start a game very quickly.

Gotcha. I'm all for tool variety, I just didn't want anyone to get the wrong impression from your original post and think that generator-phaser-official didn't have browserify, a file watcher and auto loading.

Link to comment
Share on other sites

  • 2 weeks later...
  • 11 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...