Posts Tagged ‘github’

  • Closing in on the Phaser 1.0 release

    phaser-planet

    Although the master branch of Phaser has been quiet for a couple of months we have been extremely busy working on what will be the 1.0 release. If you take a look at the 097 branch README you’ll get an idea of the sheer scale of change that has happened to the framework.

    Although the initial release was heavily inspired by Flixel, indeed taking lots of the core classes and directly porting them over, this has been mostly reversed for 1.0. We hit limitations pretty quickly and were constantly stretching the framework in different directions until one day it  finally snapped and we realised it needed a fresh approach.

    So while the majority of the core classes have changed entirely, we’ve been extremely careful to ensure that actually using Phaser is just as easy as Flixel is (if not more so in some places!). We’ve worked really hard to make sure you can rapidly build games with it. For example the following code will create a new game, load an image, create a sprite and display it on-screen:

        var game = new Phaser.Game(this, 'game', 800, 600, init, create);
    
        function init() {
            game.load.image('bunny', 'assets/sprites/bunny.png');
            game.load.start();
        }
    
        function create() {
            game.add.sprite(0, 0, 'bunny');
        }

    Needless to say the sprite is now under your full control. Alpha it, tween it, flip it, animate it, rotate it, move it around with touch/mouse/keyboard, collide it, emit it in the particle system, etc.

    We’ve been hard at work creating several large games for clients with Phaser, so we’re able to battle test it and evolve it through actual use. The first of these games was released onto the BBC site last week, and although aimed primarily at small children it still allowed us to deploy a Phaser game to a heavily trafficked audience and gauge response.

    So what’s new in 1.0?

    Read More

  • TypeScript Signals released – Think outside the Event

    Signals are a light-weight, strongly typed messaging tool and we use them extensively in our game framework. And we’ve just released our TypeScript implementation for others to benefit from. It’s a conversion of js-signals by Miller Medeiros, which is of course in turn a conversion of AS3-Signals by Robert Penner.

    You can get TypeScript-Signals from github.

    If you are unfamiliar with Signals, how they work and how they compare to Events then this short summary is well worth a quick read, but to summarise:

    • A Signal is essentially a mini-dispatcher specific to one event, with its own array of listeners.
    • A Signal gives an event a concrete membership in a class.
    • Listeners subscribe to real objects, not to string-based channels.
    • Event string constants are no longer needed.
    • Signals are inspired by C# events and signals/slots in Qt.

    I ported over all of the 18 unit tests to TypeScript as well. So you have plenty of examples: from adding a basic listener up to manual binding and dynamic context switching.

    Here is an example of how we use a Signal within our Position component in our framework. In this case ‘updated’ is our Signal and when the Position component is updated we dispatch it:

    this.updated.dispatch(this._point.x, this._point.y, this._z, this.cssTranslate3d, this.cssLeft, this.cssTop);

    Anything that is listening to the ‘updated’ Signal is notified of the new values being sent. For example our Sprite game object listens for updates:

    this.position.updated.add(this._updatePosition, this);

    And a local private method _updatePosition responds to the new values being sent.

    Read More