Skip to content

Commit

Permalink
Lots of documentation updates and new Loader examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Nov 27, 2013
1 parent 4926fac commit a9a46bf
Show file tree
Hide file tree
Showing 27 changed files with 1,047 additions and 203 deletions.
49 changes: 23 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ Version 1.1.3 - in build
* New: Added a .jshintrc so contributions can be run through JSHint to help retain formatting across the library (thanks kevinthompson)
* New: The entire Phaser library has been updated to match the new JSHint configuration.
* New: Added a new in-built texture. Sprites now use __default if no texture was provided (a 32x32 transparent PNG) or __missing if one was given but not found (a 32x32 black box with a green cross through it)
* New: Added Phaser.Filter. A new way to use the new WebGL shaders/filters that the new version of Pixi supports.
* New: The object returned by Math.sinCosGenerator now contains a length property.
* New: Phaser.Filter. A new way to use the new WebGL shaders/filters that the new version of Pixi supports.
* New: Phaser.BitmapData object. A Canvas you can freely draw to with lots of functions. Can be used as a texture for Sprites. See the new examples and docs for details.
* New: RenderTexture.render now takes a Phaser.Group. Also added renderXY for when you don't want to make a new Point object.
* New: Physics.overlap now supports Sprites, Groups or Emitters and can perform group vs. group (etc) overlap checks with a custom callback and process handler.
* New: Added Sound.externalNode which allows you to connect a Sound to an external node input rather than the SoundManager gain node.
* New: Added SoundManager.connectToMaster boolean. Used in conjunction with Sound.externalNode you can easily configure audio nodes to connect together for special effects.
* New: PluginManager.remove, added PluginManager.removeAll (thanks crazysam)
* New: scrollFactorX/scrollFactorY have been added to TilemapLayers (thanks jcd-as)
* New: Phaser.Game parent can now be an HTMLElement or a string (thanks beeglebug)
Expand All @@ -64,8 +66,22 @@ Version 1.1.3 - in build
* New: Device.littleEndian boolean added. Only safe to use if the browser supports TypedArrays (which IE9 doesn't, but nearly all others do)
* New: You can now call game.sound.play() and simply pass it a key. The sound will play if the audio system is unlocked and optionally destroy itself on complete.
* New: Mouse.capture is a boolean. If set to true then DOM mouse events will have event.preventDefault() applied, if false they will propogate fully.
* New: Added Sound.externalNode which allows you to connect a Sound to an external node input rather than the SoundManager gain node.
* New: Added SoundManager.connectToMaster boolean. Used in conjunction with Sound.externalNode you can easily configure audio nodes to connect together for special effects.
* New: The object returned by Math.sinCosGenerator now contains a length property.

* Updated: Lots of documentation fixes and updates across nearly all files. Tilemap now documented for example and lots of instances of 'Description' filled out.
* Updated: ArcadePhysics.updateMotion applies the dt to the velocity calculations as well as position now (thanks jcs)
* Updated: RequestAnimationFrame now retains the callbackID which is passed to cancelRequestAnimationFrame.
* Updated: Button now goes back to over state when setFrames used in action (thanks beeglebug)
* Updated: plugins now have a postUpdate callback (thanks cocoademon)
* Updated: Tided up the Graphics object (thanks BorisKozo)
* Updated: If running in Canvas mode and you have a render function it will save the context and reset the transform before running your render function.
* Updated: Sprite will now check the exists property of the Group it is in, if the Group.exists = false the Sprite won't update.
* Updated: If you specify 'null' as a Group parent it will now revert to using the World as the parent (before only 'undefined' worked)
* Updated: Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist (thanks cocoademon)
* Updated: Loader.audio can now accept either an array of URL strings or a single URL string (thanks crazysam + kevinthompson)
* Updated: MSPointer updated to support IE11 by dropping the prefix from the event listeners.
* Updated: Device.cocoonJS added to detect if the game is running under Cocoon or a native browser.
* Updated: Loader now uses a new queue system internally, meaning you can have assets with the same key spread across different types.

* Fixed: Lots of fixes to the TypeScript definitions file (many thanks gltovar)
* Fixed: Tilemap commands use specified layer when one given (thanks Izzimach)
Expand All @@ -82,20 +98,7 @@ Version 1.1.3 - in build
* Fixed: Device.isTouch modified to test maxTouchPointers instead of MSPointer.
* Fixed: InputHandler.checkPointerOver now checks the visible status of the Sprite Group before processing.
* Fixed: The Sprite hulls (used for tile collision) were not being updated in sprite->sprite separations (thanks jcs)

* Updated: ArcadePhysics.updateMotion applies the dt to the velocity calculations as well as position now (thanks jcs)
* Updated: RequestAnimationFrame now retains the callbackID which is passed to cancelRequestAnimationFrame.
* Updated: Button now goes back to over state when setFrames used in action (thanks beeglebug)
* Updated: plugins now have a postUpdate callback (thanks cocoademon)
* Updated: Tided up the Graphics object (thanks BorisKozo)
* Updated: If running in Canvas mode and you have a render function it will save the context and reset the transform before running your render function.
* Updated: Sprite will now check the exists property of the Group it is in, if the Group.exists = false the Sprite won't update.
* Updated: Lots of documentation fixes and updates across nearly all files.
* Updated: If you specify 'null' as a Group parent it will now revert to using the World as the parent (before only 'undefined' worked)
* Updated: Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist (thanks cocoademon)
* Updated: Loader.audio can now accept either an array of URL strings or a single URL string (thanks crazysam + kevinthompson)
* Updated: MSPointer updated to support IE11 by dropping the prefix from the event listeners.
* Updated: Device.cocoonJS added to detect if the game is running under Cocoon or a native browser.
* Fixed: Plugins that had a postUpdate but no Update weren't being marked as active (thanks crazysam)

You can view the complete Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md

Expand Down Expand Up @@ -211,12 +214,6 @@ The 1.1 release was a massive under-taking, but we're really happy with how Phas
* Create more touch input examples (http://www.html5gamedevs.com/topic/1556-mobile-touch-event/)
* Look at HiDPI Canvas settings.

Some specific features / issues we will address soon:

* Loader conflict if 2 keys are the same even if they are in different packages (i.e. you can't use "title" for both and image and sound file).
* Sound.addMarker hh:mm:ss:ms.
* Add support for a rotation offset.

Learn By Example
----------------

Expand All @@ -243,10 +240,10 @@ If you find a bug (highly likely!) then please report it on github or our forum.

If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you.

Before submitting a pull request, please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, first install it by running `npm install jshint`, then test your code by running `jshint src`. This isn't a requirement, we are happy to receive pull requests that haven't been JSHinted, so don't let it put you off contributing - but do know that we'll reformat your source before going live with it.

You can do this on the Phaser board that is part of the [HTML5 Game Devs forum](http://www.html5gamedevs.com/forum/14-phaser/) or email: [email protected]

Before submitting a pull request, please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, first install it by running `npm install jshint`, then test your code by running `jshint src`. This isn't a requirement, we are happy to receive pull requests that haven't been JSHinted, so don't let it put you off contributing - but do know that we'll reformat your source before going live with it.

Bugs?
-----

Expand Down
4 changes: 4 additions & 0 deletions build/phaser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,10 @@ declare module Phaser {
computeVelocity(axis: number, body: Phaser.Physics.Arcade.Body, velocity: number, acceleration: number, drag: number, max: number): void;
preUpdate(): void;
postUpdate(): void;
overlap(object1: any, object2: any, overlapCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
overlapSpriteVsSprite(sprite1: Phaser.Sprite, sprite2: Phaser.Sprite, overlapCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
overlapSpriteVsGroup(sprite1: Phaser.Sprite, group: Phaser.Group, overlapCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
overlapGroupVsGroup(group: Phaser.Group, group2: Phaser.Group, overlapCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
collide(object1: any, object2: any, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
collideSpriteVsSprite(sprite1: Phaser.Sprite, sprite2: Phaser.Sprite, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
collideSpriteVsTilemap(sprite1: Phaser.Sprite, tilemap: Phaser.Tilemap, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean;
Expand Down
1 change: 0 additions & 1 deletion build/ts.bat

This file was deleted.

1 change: 1 addition & 0 deletions docs/build/conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"../../src/physics/arcade/",
"../../src/sound/",
"../../src/system/",
"../../src/tilemap/",
"../../src/time/",
"../../src/tween/",
"../../src/utils/"
Expand Down
1 change: 1 addition & 0 deletions docs/build/conf_dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"../../src/physics/arcade/",
"../../src/sound/",
"../../src/system/",
"../../src/tilemap/",
"../../src/time/",
"../../src/tween/",
"../../src/utils/"
Expand Down
20 changes: 20 additions & 0 deletions examples/_site/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@
"file": "load+audio.js",
"title": "load audio"
},
{
"file": "load+bitmap+font.js",
"title": "load bitmap font"
},
{
"file": "load+image.js",
"title": "load image"
Expand All @@ -400,6 +404,18 @@
"file": "load+spritesheet.js",
"title": "load spritesheet"
},
{
"file": "load+starling+atlas.js",
"title": "load starling atlas"
},
{
"file": "load+text+file.js",
"title": "load text file"
},
{
"file": "load+texture+atlas.js",
"title": "load texture atlas"
},
{
"file": "pick+images+from+cache.js",
"title": "pick images from cache"
Expand Down Expand Up @@ -592,6 +608,10 @@
"file": "animated+tiling+sprite.js",
"title": "animated tiling sprite"
},
{
"file": "tiling+sprite+input.js",
"title": "tiling sprite input"
},
{
"file": "tiling+sprite.js",
"title": "tiling sprite"
Expand Down
12 changes: 9 additions & 3 deletions examples/loader/load audio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });

function preload() {

Expand All @@ -14,6 +14,9 @@ function preload() {

game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);

// If you know you only need to load 1 type of audio file, you can pass a string instead of an array, like this:
// game.load.audio('boden', 'assets/audio/bodenstaendig_2000_in_rock_4bit.mp3');

}

var music;
Expand All @@ -22,8 +25,6 @@ function create() {

game.stage.backgroundColor = '#182d3b';

// game.input.touch.preventDefault = false;

music = game.sound.play('boden');

}
Expand All @@ -32,4 +33,9 @@ function render() {

game.debug.renderSoundInfo(music, 32, 32);

if (music.isDecoding)
{
game.debug.renderText("Decoding MP3 ...", 32, 200);
}

}
36 changes: 36 additions & 0 deletions examples/loader/load bitmap font.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });

function preload() {

// Phaser can load Bitmap Fonts.

// As with all load operations the first parameter is a unique key, which must be unique between all image files.
// Next is the bitmap font file itself, in this case desyrel.png
// Finally is the path to the XML file that goes with the font.

game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml');

// Note that the XML file should be saved with UTF-8 encoding or some browsers (such as Firefox) won't load it.

// There are various tools that can create Bitmap Fonts and the XML file needed.
// On Windows you can use the free app BMFont: http://www.angelcode.com/products/bmfont/
// On OS X we recommend Glyph Designer: http://www.71squared.com/en/glyphdesigner

}

var text;

function create() {

game.stage.backgroundColor = '#0072bc';

text = game.add.bitmapText(200, 100, 'Bitmap Fonts!', { font: '64px Desyrel', align: 'center' });

}

function update() {

text.setText('Bitmap Fonts!\nx: ' + Math.round(game.input.x) + ' y: ' + Math.round(game.input.y));

}
38 changes: 38 additions & 0 deletions examples/loader/load starling atlas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });

function preload() {

// Phaser can load texture atlas files that use the Starling XML file format.

// As with all load operations the first parameter is a unique key, which must be unique between all image files.

// Next is the texture atlas itself, in this case seacreatures.png
// Finally is the path to the XML file that goes with the atlas.
game.load.atlasXML('seacreatures', 'assets/sprites/seacreatures.png', 'assets/sprites/seacreatures.xml');

// Note that the XML file should be saved with UTF-8 encoding or some browsers (such as Firefox) won't load it.



// These are just a few images to use in our underwater scene.
game.load.image('undersea', 'assets/pics/undersea.jpg');
game.load.image('coral', 'assets/pics/seabed.png');

}

var jellyfish;

function create() {

game.add.sprite(0, 0, 'undersea');

jellyfish = game.add.sprite(330, 100, 'seacreatures');
jellyfish.animations.add('swim', Phaser.Animation.generateFrameNames('greenJellyfish', 0, 39, '', 4), 30, true);
jellyfish.animations.play('swim');

game.add.sprite(0, 466, 'coral');

game.add.tween(jellyfish).to({ y: 250 }, 4000, Phaser.Easing.Quadratic.InOut, true, 0, 10000, true);

}
37 changes: 37 additions & 0 deletions examples/loader/load text file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });

function preload() {

// Phaser can load Text files.

// It does this using an XMLHttpRequest.

// If loading a file from outside of the domain in which the game is running
// a 'Access-Control-Allow-Origin' header must be present on the server.
// No parsing of the text file is performed, it's literally just the raw data.

game.load.text('html', 'http://phaser.io');

}

var text;

function create() {

game.stage.backgroundColor = '#0072bc';

var html = game.cache.getText('html');

text = html.split('\n');

}

function render() {

for (var i = 0; i < 30; i++)
{
game.debug.renderText(text[i], 32, i * 20);
}

}
39 changes: 39 additions & 0 deletions examples/loader/load texture atlas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });

function preload() {

// Phaser can load Texture Atlas files that use either JSON Hash or JSON Array format.

// As with all load operations the first parameter is a unique key, which must be unique between all image files.

// Next is the texture atlas itself, in this case seacreatures.png

// Finally is the path to the JSON file that goes with the atlas.
game.load.atlas('seacreatures', 'assets/sprites/seacreatures_json.png', 'assets/sprites/seacreatures_json.json');

// Note that the JSON file should be saved with UTF-8 encoding or some browsers (such as Firefox) won't load it.



// These are just a few images to use in our underwater scene.
game.load.image('undersea', 'assets/pics/undersea.jpg');
game.load.image('coral', 'assets/pics/seabed.png');

}

var octopus;

function create() {

game.add.sprite(0, 0, 'undersea');

octopus = game.add.sprite(330, 100, 'seacreatures');
octopus.animations.add('swim', Phaser.Animation.generateFrameNames('octopus', 0, 24, '', 4), 30, true);
octopus.animations.play('swim');

game.add.tween(octopus).to({ y: 250 }, 4000, Phaser.Easing.Quadratic.InOut, true, 0, 10000, true);

game.add.sprite(0, 466, 'coral');

}
Loading

0 comments on commit a9a46bf

Please sign in to comment.