Merge branch 'dev' of github.com:jotson/phaser into dev

This commit is contained in:
John Watson 2014-04-14 17:15:09 -07:00
commit 252032359d
18 changed files with 231 additions and 256 deletions

View file

@ -2,6 +2,10 @@
There is an extensive [Migration Guide](https://github.com/photonstorm/phaser/blob/master/resources/Migration%20Guide.md) available for those converting from Phaser 1.x to 2.x. In the guide we detail the API breaking changes and approach to our new physics system.
## Version 2.0.4 - "Mos Shirare" - in development
## Version 2.0.3 - "Allorallen" - 11th April 2014
### Updates

176
README.md
View file

@ -1,10 +1,10 @@
![Phaser 2.0](http://www.phaser.io/images/phaser2-github.png)
# Phaser 2.0.3
# Phaser 2.0.4-dev
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering.
Version: 2.0.3 "Allorallen" - Released: 11th April 2014
Version: 2.0.4 "Mos Shirare" - Released: -in development-
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
@ -22,19 +22,8 @@ By Richard Davey, [Photon Storm](http://www.photonstorm.com)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/photonstorm/phaser/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
## What's new in 2.0.3?
## What's new in 2.0.4?
In this release we have upgraded both pixi.js to v1.5.2 and p2.js to v0.5.0. This improves features and stability across the whole framework, and as always you'll find the complete list of improvements below.
We've taken some time to enhance the Particle Emitter adding a few substantial features such as the ability for Particles to now change scale or alpha over time using any of the easing functions, or apply a blend mode. These small additions now allow you to create visually more impressive effects than before, and while we still have a complete overhaul of the particle system on our roadmap it's a welcome boost in the meantime.
Along with the p2.js update we have also refined the Phaser P2 classes, making tweaks that help overall performance, such as splitting the world bounds into separate bodies. The World now has a default contact material, which allows for easier setting of responses when objects collide with no materials set. All in all it's a powerful update.
What's interesting is that loads of the new features and bug fixes in this release have come direct from the community. Of course we've been busy and working hard on Phaser as well, but the volume of contributors now is fantastic. We've have always listed their names next to the issues they helped resolve, but now we're doing so with their github usernames directly so they appear on the revisions change log.
As promised with the 2.0.0 release we have done all of this without changing existing API calls in the core Phaser classes. New features are introduced either via the creation of new optional parameters or by creating new methods. Where a feature has been deprecated we have flagged it as such in the docs, but left it in so as to not break existing code.
Some of you may not be aware, but the `phaser.min.js` file in the build folder contains all 3 physics systems bundled in. We've refined our build process so that it's easy for you to create custom builds now via grunt, but if you know you only need Arcade Physics (and not P2 or Ninja) then you can use `phaser-arcade-physics.min.js` which is found in the `build/custom` folder. This will save you 180KB from the minified file size, so please use it if you can.
## Welcome to Phaser
@ -65,153 +54,36 @@ There is also an [un-official Getting Started Guide](http://www.antonoffplus.com
## Change Log
Version 2.0.3 - "Allorallen" - 11th April 2014
Version 2.0.4 - "Mos Shirare" - in development
### Updates
* Updated to [Pixi.js 1.5.2](https://github.com/GoodBoyDigital/pixi.js/releases/tag/v1.5.2)
* Updated to [p2.js 0.5.0](https://github.com/schteppe/p2.js/releases/tag/v0.5.0)
* Return the result of P2.Body.setCircle for further chaining and manipulation (fix #659)
* Updated the PhysicsEditor plugin to maintain position, radius, mask bits, category bits and sensor flags (thanks @georgiee, #674)
* Further TypeScript defs tweaks (thanks @clark-stevenson)
* Lowered the default size of SpriteBatch from 10000 to 2000 as this yields faster results on mobile (pixi.js update)
* Fix for 'jagged' strokes on custom fonts (thanks @nickryall, #677)
* The State.update function (and thus the update of any sub-classed Sprites or other objects) is now called before Stage, Tweens, Sound, Input, etc (#662)
* The Phaser jshint process is now running on Travis (thanks @xtian, #656)
* The Phaser Gruntfile is now split up into option tasks (thanks @xtian, #638)
* Key.reset now clears any callbacks associated with the onDown and onUp events and nulls the onHoldCallback if set. Key.reset is called by Keyboard.reset when changing state.
* If you pass `null` to Tilemap.putTile as the tile parameter it will pass the call over to Tilemap.removeTile.
* TypeScript definitions updated for latest changes (thanks @clark-stevenson)
* Keyboard.stop nulls the function references after removing the event listeners (thanks @bmceldowney, #691)
* Tilemap.hasTile allows for multi-layer type parameter (thanks @Raeven0, #680)
* Grunt update to dev dependencies (thanks @xtian, #695)
* Emitter now emits Phaser.Particle objects instead of Phaser.Sprites, which can be extended as required.
* Emitter has had various local properties removed that were already declared in Phaser.Group which it extends.
* PluginManager parent parameter removed as it's redundant. Also most core functions tidied up and jsdocs fixed.
* p2.World.defaultRestitution has been deprecated and is now p2.World.restitution.
* p2.World.defaultFriction has been deprecated and is now p2.World.friction.
* p2.World now uses 4 bodies for the world boundaries, rather than 1 body with 4 shapes. This stops the bounds triggering narrowphase with every single body in the world.
* p2.World bounds are now included in the callback events such as beginContact and impact events.
* Thanks to @STuFF the Classes drop-down list in the API docs now indents the sub-classes.
* TypeScript definitions fixes and updates (thanks @clark-stevenson)
* Timer has removed all use of local temporary vars in the core update loop.
* The Input.reset `hard` reset parameter is now passed down to the Keyboard and Key reset methods.
* AnimationManager.destroy now iterates through child animations calling destroy on all of them, avoiding a memory leak (thanks stauzs)
* AnimationManager.play will now call Animation.stop on the current animation before switching to the new one (thanks @nihakue, #713)
### New Features
* Added ability to retrieve a single p2 fixture from the cache (thanks @georgiee, #674)
* Timers can now have a start delay value (thanks @georgiee, #660)
* CacheAsBitmap added to Display Object, so works for Sprite, Image, Button. Allows you to cache complex display hierarchies for speed.
* CacheAsBitmap added to Graphics Object. Allows you to cache complex graphics structures hierarchies for speed.
* Added generateTexture function to display objects. Create a texture from the current object display hierarchy for use as a texture elsewhere.
* Added optional FilterArea to display object (for optimisation)
* Graphics chaining functions.
* Added Pointer.positionUp which records the last point at which the pointer left the screen (thanks @Cryszon, #676)
* Phaser.Point.centroid static function added to calculate the centroid or midpoint of an array of points (thanks @lewster32, #675)
* SoundManager.remove(sound) now lets you remove a sound from the SoundManager, destroying it in the process.
* Sound.destroy will remove a sound and all local references it holds, optionally removing itself from the SoundManager as well.
* SoundManager.removeByKey(key) will remove all sounds from the SoundManager that have a key matching the given value.
* ArcadePhysics.Body.hitTest(x, y) will return a boolean based on if the given world coordinate are within the Body or not.
* StateManager.restart allows you to quickly restart the *current* state, optionally clearing the world and cache.
* Tilemap.removeTile(x, y, layer) lets you remove the tile at the given coordinates and updates the collision data.
* Tilemap.removeTileWorldXY lets you remove the tile at the given pixel value coordinates and updates the collision data.
* Key.enabled boolean allows you to toggle if a Key processes its update method or dispatches any events without deleting and re-creating it.
* Emitter now has minParticleAlpha and maxParticleAlpha values for setting a random alpha on emitted particles.
* Emitter.particleAnchor allows you to control the anchor of emitted Particles. Defaults to 0.5 (same as before) but now under your control.
* Emitter.setAlpha allows you to quickly set the min and max alpha values.
* Emitter.setScale allows you to quickly set the min and max scale values.
* Emitter.blendMode lets you set the blendMode of any emitted Particle (needs a browser that supports canvas blend modes)
* Group.customSort allows you to sort the Group children based on your own sort function.
* Emitter.setScale has a new 'rate' parameter which allows particles to change in scale over time, using any Easing value or timescale.
* Emitter.setScale now allows you to scale the x and y axis of the particles independently.
* Emitter.setAlpha has a new 'rate' parameter which allows particles to change alpha over time, using any Easing value or timescale.
* Emitter.bringToTop and Emitter.sendToBack are booleans that let you optionally set the display order of the Particle when emitted.
* Emitter now calls the Phaser.Particle.onEmit function, which is left empty for you to override and add in custom behaviours.
* p2.World has a new contactMaterial property, which can be configured like a normal P2 Contact Material and is applied when two bodies hit that don't have defined materials.
* Group.remove has a new 'destroy' parameter (false by default), which will optionally call destroy on the item removed from the Group.
* Group.removeAll has a new 'destroy' parameter (false by default), which will optionally call destroy on the items removed from the Group.
* Group.removeBetween has a new 'destroy' parameter (false by default), which will optionally call destroy on the items removed from the Group.
* @georgiee created a new P2.FixtureList class to allow easy access the fixtures of a created P2 Body:
* Loader now has an onFileStart event you can listen for (thanks @codevinsky, #705)
* Timer.clearPendingEvents will purge any events marked for deletion, this is run automatically at the start of the update loop.
* Device.crosswalk detects if your game is running under Intels Crosswalk XDK.
* Keyboard.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners.
* Key.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners.
* InputManager.resetLocked - If the Input Manager has been reset locked then all calls made to InputManager.reset, such as from a State change, are ignored.
This is especially useful in combination with PhysicsEditor and P2.Body#addPhaserPolygon.
You can configure your whole collision grouping in PhysicsEditor and then you can later change the mask bits easily with this class. You can also access parts (groups) and named fixtures by a group index or a fixture key - both properties can be set in PhysicsEditor with the custom phaser exporter.
Use cases:
* Configure collision bits in PhysicsEditor and you want to change them later.
* Place a sensor in your fixture and access this single fixture later (to disable temporarily)
* Create a small body with threes fixtures (circle, circle + polygon/convex). Now you want that the polygon part to behave like rubber and assign a bouncing (restitution > 1) material. Assign a fixture key in PhysicsEditor and access the fixture like this. (see the image for the fixture I described)
### Bug Fixes
* If you inputEnable = false a gameobject you couldn't re-enable it again using inputEnable = true, only directly via the handler (thanks @nickrall, fix #673)
* Fixed setTexture bug with TilingSprite (pixi.js 1.5.2 bug fix)
* Fixed anchor point bug in canvas with TilingSprite (pixi.js 1.5.2 bug fix)
* Fixed positionOffset not begin correct in TilingSprite (pixi.js 1.5.2 bug fix)
* Fixed issue where filters were not being applied to TilingSprite (pixi.js 1.5.2 bug fix)
* Fixed SpriteBatch canvas transform bug (pixi.js 1.5.2 bug fix)
* Fixed Cached textures issue when using base64 encoded images (@cacheflowe) (pixi.js 1.5.2 bug fix)
* Fixed issue where visibility was not being respected in sprite batch (pixi.js 1.5.2 bug fix)
* Fixed bug in gl.bindTexture which tried to use an undefined private var. (@photonstorm) (pixi.js 1.5.2 bug fix)
* Fixed the 'short cut' version of Math.floor in setTransform if roundPixels is true. (@photonstorm) (pixi.js 1.5.2 bug fix)
* SoundManager.boot will check to see if the AudioContext was created before carrying on (thanks @keyle, fix #669)
* Fixed bug where move up and move down method in groups did not work (thanks @jonthulu, fix #684)
* Fixed bug in Group.next when cursor is at the last child (thanks @jonthulu, fix #688)
* Emitter.minParticleScale and maxParticleScale wasn't resetting the Body size correctly.
* Group.removeBetween now properly iterates through the children.
* P2.World had a type in the restitution method title. Now fixed.
* Objects with an InputHandler now deactivate it when the object is removed from a Group but not destroyed (fix #672)
* Fixed the vectors used in the BlurX and BlurY filters (thanks @nickryall, fix #668)
### p2.js v0.5.0
* Added property .enableIslandSleeping to World.
* Added property .useFrictionGravityOnZeroGravity to World.
* Renamed .useWorldGravityForFrictionApproximation in World to .useWorldGravityAsFrictionGravity to keep things more uniform.
* Sleep improvements.
* Added property .frictionIterations to GSSolver, and removed .skipFrictionIterations.
* Upgraded to gl-matrix 2.1.0.
* Removed QuadTree.
* Removed mat2.
* Added Utils.extend.
* Added methods .setStiffness and .setRelaxation methods to Constraint.
* Removed properties .stiffness, .relaxation and .useGlobalEquationParameters from GSSolver.
* Added methods .setGlobalStiffness, .setGlobalRelaxation, .setGlobalEquationParameters to World.
* Renamed property .eps to .epsilon for Equation.
* Removed property .useBoundingBoxes from NaiveBroadphase in favor of the new property .boundingVolumeType in Broadphase.
* Added methods .getMaxForce and .setMaxForce to LockConstraint.
* Changed property names .bi, .bj, .ni, .ri, .rj to .bodyA, .bodyB, .normalA, .contactPointA, .contactPointB in Equation, ContactEquation and FrictionEquation classes.
* Removed IslandSolver in favor of the new property World.islandSplit.
* Changed constructors of the Constraints so they all take an options object as last parameter.
* Added property .collideConnected to Constraint.
* Added property .islandSplit to World.
* Added methods .disableBodyCollision and .enableBodyCollision to World.
* Added properties .useWorldGravityForFrictionApproximation and .frictionGravity to World.
* Added Heightfield class.
* Removed properties .defaultFriction and .defaultRestitution from World, in favor of .defaultContactMaterial.
* Added property .enabled to Equation.
* Added property .surfaceVelocity to ContactMaterial.
* Added property .sensor to Shape.
* World now emits events 'beginContact', 'endContact' and 'preSolve'.
* Added property .gravityScale to Body.
* Renamed class SAP1DBroadphase to SAPBroadphase.
* Added property .interpolatedPosition to Body`.
* Added method .internalStep to World.
* Added property .applyGravity to World.
* Renamed method .computeC to .computeInvC in Equation, and made it compute the inverse.
* Added static method Utils.splice.
* Added property .world to Body.
* Added property .fixedRotation to Body.
* Added class AABB.
* Added properties .aabb and .aabbNeedsUpdate to Body, as well as a method .updateAABB.
* Added property .useBoundingBoxes to NaiveBroadphase.
* Added static method Broadphase.aabbCheck.
* Added method .computeAABB to Shape.
* Added static method Broadphase.canCollide.
* Body now inherits from EventEmitter, and dispatches events 'sleep','sleepy' and 'wakeup'.
* Added properties .allowSleep, .sleepState, .sleepSpeedLimit, .sleepTimeLimit, .lastTimeSleepy as well as methods .sleep, .wakeUp and .sleepTick to Body.
* Added enums Body.AWAKE, Body.SLEEPY, Body.SLEEPING.
* Added property .enableBodySleeping to World.
* Added options .disableRotationalLock, .lowerLimit, .upperLimit to PrismaticConstraint constructor.
* Added methods .enableMotor, .disableMotor to PrismaticConstraint as well as properties .motorEnabled, .motorSpeed, .motorEquation.
* The main Timer loop could incorrectly remove TimeEvent if a new one was added specifically during an event callback (thanks @garyyeap, fix #710)
* Fixed the use of the destroy parameter in Group.removeAll and related functions (thanks @AnderbergE, fix #717)
* P2.World.convertTilemap now correctly checks the collides parameter of the tiles as it converts them.
* Animation.destroy didn't correctly clear the onStart, onLoop and onComplete signals.
* StateManager.restart incorrectly skipped the first additional parameter after clearCache (thanks @mariusbrn, fix #722)
There is an extensive [Migration Guide](https://github.com/photonstorm/phaser/blob/master/resources/Migration%20Guide.md) available for those converting from Phaser 1.x to 2.x. In the guide we detail the API breaking changes and approach to our new physics system.
@ -254,11 +126,11 @@ Nice and easy :)
Thanks to a community member Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html:
`http://cdnjs.cloudflare.com/ajax/libs/phaser/2.0.3/phaser.min.js`
`http://cdnjs.cloudflare.com/ajax/libs/phaser/2.0.4/phaser.min.js`
Or if you prefer you can leave the protocol off, so it works via http and https:
`//cdnjs.cloudflare.com/ajax/libs/phaser/2.0.3/phaser.min.js`
`//cdnjs.cloudflare.com/ajax/libs/phaser/2.0.4/phaser.min.js`
## Requirements

View file

@ -1,6 +1,6 @@
{
"name": "phaser",
"version": "2.0.3",
"version": "2.0.4",
"homepage": "http://phaser.io",
"authors": [
"photonstorm <rich@photonstorm.com>"

56
build/phaser.d.ts vendored
View file

@ -469,6 +469,7 @@ declare module PIXI {
drawRect(x: number, y: number, width: number, height: number): void;
endFill(): void;
generateTexture(): Texture;
generateTexture(renderer: PIXI.IPixiRenderer): RenderTexture;
getBounds(): Rectangle;
lineStyle(lineWidth: number, color: number, alpha: number): void;
lineTo(x: number, y: number): void;
@ -1957,7 +1958,8 @@ declare module Phaser {
countLiving(): number;
create(x: number, y: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite;
createMultiple(quantity: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite;
destroy(destroyChildren?: boolean, soft?:boolean): void;
customSort(sortHandler: Function, context: Object): void;
destroy(destroyChildren?: boolean, soft?: boolean): void;
divideAll(property: string, amount: number, checkAlive?: boolean, checkVisible?: boolean): void;
forEach(callback: Function, callbackContext: Object, checkExists?: boolean): void;
forEachAlive(callback: Function, callbackContext: Object): void;
@ -1979,9 +1981,9 @@ declare module Phaser {
postUpdate(): void;
preUpdate(): void;
previous(): void;
remove(child: any): boolean;
removeAll(): void;
removeBetween(startIndex: number, endIndex: number): void;
remove(child: any, destroy?: boolean): boolean;
removeAll(destroy?: boolean): void;
removeBetween(startIndex: number, endIndex?: number, destroy?: boolean): void;
replace(oldChild: any, newChild: any): any;
reverse(): void;
sendToBack(child: any): any;
@ -2411,6 +2413,7 @@ declare module Phaser {
game: Phaser.Game;
hasLoaded: boolean;
isLoading: boolean;
onFileStart: Phaser.Signal;
onFileComplete: Phaser.Signal;
onFileError: Phaser.Signal;
onLoadComplete: Phaser.Signal;
@ -2598,6 +2601,18 @@ declare module Phaser {
}
class Particle extends Phaser.Sprite {
constructor(game: Phaser.Game, x: number, y: number, key?: any, frame?: any);
onEmit(): void;
reset(x: number, y: number, health?: number): Phaser.Particle;
setAlphaData(data: any[]): void;
setScaleData(data: any[]): void;
update(): void;
}
class Particles {
constructor(game: Phaser.Game);
@ -2619,7 +2634,10 @@ declare module Phaser {
class Emitter extends Phaser.Group {
constructor(game: Phaser.Game, x?: number, y?: number, maxParticles?: number);
alphaData: any[];
autoAlpha: boolean;
autoScale: boolean;
angle: number;
angularDrag: number;
bottom: number;
@ -2633,7 +2651,7 @@ declare module Phaser {
height: number;
left: number;
lifespan: number;
maxParticles: number;//
maxParticles: number;
maxParticleScale: number;
maxParticleSpeed: Phaser.Point;
maxRotation: number;
@ -2642,10 +2660,13 @@ declare module Phaser {
minRotation: number;
name: string;
on: boolean;
particleBringToTop: boolean;
particleSendToBack: boolean;
particleClass: Phaser.Sprite;
particleDrag: Phaser.Point;
position: Phaser.Point;
right: number;
scaleData: any[];
top: number;
type: number;
width: number;
@ -2656,7 +2677,10 @@ declare module Phaser {
emitParticle(): void;
kill(): void;
makeParticles(keys: any, frames: any, quantity: number, collide?: boolean, collideWorldBounds?: boolean): Phaser.Particles.Arcade.Emitter;
reset(x: number, y: number, health?: number): Phaser.Particles;
setAlpha(min?: number, max?: number, rate?: number, ease?: number, yoyo?: boolean): void;
setRotation(min?: number, max?: number): void;
setScale(min?: number, max?: number, rate?: number, ease?: number, yoyo?: boolean): void;
setSize(width: number, height: number): void;
setXSpeed(min: number, max: number): void;
setYSpeed(min: number, max: number): void;
@ -3019,8 +3043,11 @@ declare module Phaser {
applyGravity: boolean;
applySpringForced: boolean;
bounds: Phaser.Physics.P2.Body;
boundsCollidesWith: Phaser.Physics.P2.Body[];
contactMaterial: Phaser.Physics.P2.ContactMaterial;
emitImpactEvent: boolean;
enableBodySleeping: boolean;
everythingCollisionGroup: Phaser.Physics.P2.CollisionGroup;
frameRate: number;
friction: number;
game: Phaser.Game;
@ -3230,6 +3257,23 @@ declare module Phaser {
}
class FixtureList {
constructor(list: any[]);
flatten(array: any[]): any[];
getFixtures(keys: string): any[];
getFixtureByKey(key: string): any[];
getGroup(groupID: number): any[];
init(): void;
parse(): void;
setCategory(bit: number, fictureKey: string): void;
setMask(bit: number, fixtureKey: string): void;
setMaterial(material: Object, fixtureKey: string): void;
setSensor(value: boolean, fixtureKey: string): void;
}
class GearConstraint {
constructor(world: Phaser.Physics.P2, bodyA: Phaser.Physics.P2.Body, bodyB: Phaser.Physics.P2.Body, angle?: number, ratio?: number);

View file

@ -1,7 +1,7 @@
{
"name": "Phaser",
"version": "2.0.3",
"release": "Allorallen",
"version": "2.0.4",
"release": "Mos Shirare",
"description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.",
"author": "Richard Davey",
"logo": "https://raw.github.com/photonstorm/phaser/master/phaser-logo-small.png",

View file

@ -11,7 +11,7 @@
var Phaser = Phaser || {
VERSION: '<%= version %>',
DEV_VERSION: '2.0.3',
DEV_VERSION: '2.0.4',
GAMES: [],
AUTO: 0,

View file

@ -386,9 +386,9 @@ Phaser.Animation.prototype = {
this.currentFrame = null;
this.isPlaying = false;
this.onStart.destroy();
this.onLoop.destroy();
this.onComplete.destroy();
this.onStart.dispose();
this.onLoop.dispose();
this.onComplete.dispose();
this.game.onPause.remove(this.onPause, this);
this.game.onResume.remove(this.onResume, this);

View file

@ -195,7 +195,7 @@ Phaser.AnimationManager.prototype = {
if (this._anims[name])
{
if (this.currentAnim == this._anims[name])
if (this.currentAnim === this._anims[name])
{
if (this.currentAnim.isPlaying === false)
{
@ -205,6 +205,11 @@ Phaser.AnimationManager.prototype = {
}
else
{
if (this.currentAnim && this.currentAnim.isPlaying)
{
this.currentAnim.stop();
}
this.currentAnim = this._anims[name];
this.currentAnim.paused = false;
return this.currentAnim.play(frameRate, loop, killOnComplete);
@ -306,12 +311,23 @@ Phaser.AnimationManager.prototype = {
},
/**
* Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
* Destroys all references this AnimationManager contains.
* Iterates through the list of animations stored in this manager and calls destroy on each of them.
*
* @method Phaser.AnimationManager#destroy
*/
destroy: function () {
var anim = null;
for (var anim in this._anims)
{
if (this._anims.hasOwnProperty(anim))
{
this._anims[anim].destroy();
}
}
this._anims = {};
this._frameData = null;
this._frameIndex = 0;

View file

@ -1411,7 +1411,7 @@ Phaser.Group.prototype.remove = function (child, destroy) {
child.events.onRemovedFromGroup.dispatch(child, this);
}
this.removeChild(child);
var removed = this.removeChild(child);
this.updateZ();
@ -1420,9 +1420,9 @@ Phaser.Group.prototype.remove = function (child, destroy) {
this.next();
}
if (destroy)
if (destroy && removed)
{
child.destroy();
removed.destroy();
}
return true;
@ -1452,11 +1452,11 @@ Phaser.Group.prototype.removeAll = function (destroy) {
this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
}
this.removeChild(this.children[0]);
var removed = this.removeChild(this.children[0]);
if (destroy)
if (destroy && removed)
{
this.children[0].destroy();
removed.destroy();
}
}
while (this.children.length > 0);
@ -1497,11 +1497,11 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex, destroy)
this.children[i].events.onRemovedFromGroup.dispatch(this.children[i], this);
}
this.removeChild(this.children[i]);
var removed = this.removeChild(this.children[i]);
if (destroy)
if (destroy && removed)
{
this.children[i].destroy();
removed.destroy();
}
if (this.cursor === this.children[i])
@ -1530,24 +1530,7 @@ Phaser.Group.prototype.destroy = function (destroyChildren, soft) {
if (typeof destroyChildren === 'undefined') { destroyChildren = true; }
if (typeof soft === 'undefined') { soft = false; }
if (destroyChildren)
{
if (this.children.length > 0)
{
do
{
if (this.children[0].parent)
{
this.children[0].destroy(destroyChildren);
}
}
while (this.children.length > 0);
}
}
else
{
this.removeAll();
}
this.removeAll(destroyChildren);
this.cursor = null;

View file

@ -275,9 +275,9 @@ Phaser.StateManager.prototype = {
this._clearWorld = clearWorld;
this._clearCache = clearCache;
if (arguments.length > 3)
if (arguments.length > 2)
{
this._args = Array.prototype.splice.call(arguments, 3);
this._args = Array.prototype.splice.call(arguments, 2);
}
},

View file

@ -241,6 +241,12 @@ Phaser.Input = function (game) {
*/
// this.gestures = null;
/**
* @property {boolean} resetLocked - If the Input Manager has been reset locked then all calls made to InputManager.reset, such as from a State change, are ignored.
* @default
*/
this.resetLocked = false;
/**
* @property {Phaser.Signal} onDown - A Signal that is dispatched each time a pointer is pressed down.
*/
@ -470,20 +476,23 @@ Phaser.Input.prototype = {
},
/**
* Reset all of the Pointers and Input states
* Reset all of the Pointers and Input states. The optional `hard` parameter will reset any events or callbacks that may be bound.
* Input.reset is called automatically during a State change or if a game loses focus / visibility. If you wish to control the reset
* directly yourself then set InputManager.resetLocked to `true`.
*
* @method Phaser.Input#reset
* @param {boolean} hard - A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will.
* @param {boolean} [hard=false] - A soft reset won't reset any events or callbacks that are bound. A hard reset will.
*/
reset: function (hard) {
if (this.game.isBooted === false)
if (!this.game.isBooted || this.resetLocked)
{
return;
}
if (typeof hard == 'undefined') { hard = false; }
if (typeof hard === 'undefined') { hard = false; }
this.keyboard.reset();
this.keyboard.reset(hard);
this.mousePointer.reset();
this.gamepad.reset();
@ -502,7 +511,7 @@ Phaser.Input.prototype = {
this.game.canvas.style.cursor = 'inherit';
}
if (hard === true)
if (hard)
{
this.onDown.dispose();
this.onUp.dispose();

View file

@ -193,8 +193,11 @@ Phaser.Key.prototype = {
* associated with the onDown and onUp events and nulls the onHoldCallback if set.
*
* @method Phaser.Key#reset
* @param {boolean} [hard=true] - A soft reset won't reset any events or callbacks that are bound to this Key. A hard reset will.
*/
reset: function () {
reset: function (hard) {
if (typeof hard === 'undefined') { hard = true; }
this.isDown = false;
this.isUp = true;
@ -202,10 +205,13 @@ Phaser.Key.prototype = {
this.duration = this.game.time.now - this.timeDown;
this.enabled = true;
this.onDown.removeAll();
this.onUp.removeAll();
this.onHoldCallback = null;
this.onHoldContext = null;
if (hard)
{
this.onDown.removeAll();
this.onUp.removeAll();
this.onHoldCallback = null;
this.onHoldContext = null;
}
},

View file

@ -358,8 +358,11 @@ Phaser.Keyboard.prototype = {
* Resets all Keys.
*
* @method Phaser.Keyboard#reset
* @param {boolean} [hard=true] - A soft reset won't reset any events or callbacks that are bound to the Keys. A hard reset will.
*/
reset: function () {
reset: function (hard) {
if (typeof hard === 'undefined') { hard = true; }
this.event = null;
@ -369,7 +372,7 @@ Phaser.Keyboard.prototype = {
{
if (this._keys[i])
{
this._keys[i].reset();
this._keys[i].reset(hard);
}
}

View file

@ -95,22 +95,27 @@ Phaser.Loader = function (game) {
this.baseURL = '';
/**
* @property {Phaser.Signal} onFileComplete - Event signal.
*/
this.onFileComplete = new Phaser.Signal();
/**
* @property {Phaser.Signal} onFileError - Event signal.
*/
this.onFileError = new Phaser.Signal();
/**
* @property {Phaser.Signal} onLoadStart - Event signal.
* @property {Phaser.Signal} onLoadStart - This event is dispatched when the loading process starts, before the first file has been requested.
*/
this.onLoadStart = new Phaser.Signal();
/**
* @property {Phaser.Signal} onLoadComplete - Event signal.
* @property {Phaser.Signal} onFileStart - This event is dispatched immediately before a file starts loading. It's possible the file may still error (404, etc) after this event is sent.
*/
this.onFileStart = new Phaser.Signal();
/**
* @property {Phaser.Signal} onFileComplete - This event is dispatched when a file completes loading successfully.
*/
this.onFileComplete = new Phaser.Signal();
/**
* @property {Phaser.Signal} onFileError - This event is dispatched when a file errors as a result of the load request.
*/
this.onFileError = new Phaser.Signal();
/**
* @property {Phaser.Signal} onLoadComplete - This event is dispatched when the final file in the load queue has either loaded or failed.
*/
this.onLoadComplete = new Phaser.Signal();
@ -879,10 +884,12 @@ Phaser.Loader.prototype = {
console.warn('Phaser.Loader loadFile invalid index ' + this._fileIndex);
return;
}
var file = this._fileList[this._fileIndex];
var _this = this;
this.onFileStart.dispatch(this.progress, file.key);
// Image or Data?
switch (file.type)
{

View file

@ -1474,7 +1474,7 @@ Phaser.Physics.P2.prototype = {
{
var tile = map.layers[layer].data[y][x];
if (tile)
if (tile && tile.collides)
{
if (optimize)
{

View file

@ -39,11 +39,17 @@ Phaser.Device = function (game) {
this.cocoonJS = false;
/**
* @property {boolean} ejecta - Is the game running under Ejecta?
* @default
*/
* @property {boolean} ejecta - Is the game running under Ejecta?
* @default
*/
this.ejecta = false;
/**
* @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK?
* @default
*/
this.crosswalk = false;
/**
* @property {boolean} android - Is running on android?
* @default
@ -602,6 +608,11 @@ Phaser.Device.prototype = {
this.ejecta = true;
}
if (/Crosswalk/.test(ua))
{
this.crosswalk = true;
}
},
/**

View file

@ -315,8 +315,8 @@ Phaser.Tile.prototype = {
Phaser.Tile.prototype.constructor = Phaser.Tile;
/**
* @name Phaser.Tile#canCollide
* @property {boolean} canCollide - True if this tile can collide or has a collision callback.
* @name Phaser.Tile#collides
* @property {boolean} collides - True if this tile can collide on any of its faces.
* @readonly
*/
Object.defineProperty(Phaser.Tile.prototype, "collides", {
@ -329,7 +329,7 @@ Object.defineProperty(Phaser.Tile.prototype, "collides", {
/**
* @name Phaser.Tile#canCollide
* @property {boolean} canCollide - True if this tile can collide or has a collision callback.
* @property {boolean} canCollide - True if this tile can collide on any of its faces or has a collision callback set.
* @readonly
*/
Object.defineProperty(Phaser.Tile.prototype, "canCollide", {

View file

@ -109,6 +109,18 @@ Phaser.Timer = function (game, autoDestroy) {
*/
this._i = 0;
/**
* @property {number} _diff - Internal cache var.
* @private
*/
this._diff = 0;
/**
* @property {number} _newTick - Internal cache var.
* @private
*/
this._newTick = 0;
};
/**
@ -178,6 +190,7 @@ Phaser.Timer.prototype = {
* Adds a new Event to this Timer. The event will fire after the given amount of 'delay' in milliseconds has passed, once the Timer has started running.
* Call Timer.start() once you have added all of the Events you require for this Timer. The delay is in relation to when the Timer starts, not the time it was added.
* If the Timer is already running the delay will be calculated based on the timers current time.
*
* @method Phaser.Timer#add
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback.
* @param {function} callback - The callback that will be called when the Timer event occurs.
@ -196,9 +209,10 @@ Phaser.Timer.prototype = {
* The event will fire after the given amount of 'delay' milliseconds has passed once the Timer has started running.
* Call Timer.start() once you have added all of the Events you require for this Timer. The delay is in relation to when the Timer starts, not the time it was added.
* If the Timer is already running the delay will be calculated based on the timers current time.
*
* @method Phaser.Timer#repeat
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback.
* @param {number} repeatCount - The number of times the event will repeat.
* @param {number} repeatCount - The number of times the event will repeat once is has finished playback. A repeatCount of 1 means it will repeat itself once, playing the event twice in total.
* @param {function} callback - The callback that will be called when the Timer event occurs.
* @param {object} callbackContext - The context in which the callback will be called.
* @param {...*} arguments - The values to be sent to your callback function when it is called.
@ -215,6 +229,7 @@ Phaser.Timer.prototype = {
* The event will fire after the given amount of 'delay' milliseconds has passed once the Timer has started running.
* Call Timer.start() once you have added all of the Events you require for this Timer. The delay is in relation to when the Timer starts, not the time it was added.
* If the Timer is already running the delay will be calculated based on the timers current time.
*
* @method Phaser.Timer#loop
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback.
* @param {function} callback - The callback that will be called when the Timer event occurs.
@ -325,6 +340,28 @@ Phaser.Timer.prototype = {
},
/**
* Clears any events from the Timer which have pendingDelete set to true and then resets the private _len and _i values.
*
* @method Phaser.Timer#clearPendingEvents
*/
clearPendingEvents: function () {
this._i = this.events.length;
while (this._i--)
{
if (this.events[this._i].pendingDelete)
{
this.events.splice(this._i, 1);
}
}
this._len = this.events.length;
this._i = 0;
},
/**
* The main Timer update event, called automatically by the Game clock.
* @method Phaser.Timer#update
@ -341,55 +378,38 @@ Phaser.Timer.prototype = {
this._now = time;
this._len = this.events.length;
this._i = 0;
while (this._i < this._len)
{
if (this.events[this._i].pendingDelete)
{
this.events.splice(this._i, 1);
this._len--;
}
this._i++;
}
this._len = this.events.length;
// Clears events marked for deletion and resets _len and _i to 0.
this.clearPendingEvents();
if (this.running && this._now >= this.nextTick && this._len > 0)
{
this._i = 0;
while (this._i < this._len && this.running)
{
if (this._now >= this.events[this._i].tick)
{
var diff = this._now - this.events[this._i].tick;
var newTick = (this._now + this.events[this._i].delay) - diff;
// (now + delay) - (time difference from last tick to now)
this._newTick = (this._now + this.events[this._i].delay) - (this._now - this.events[this._i].tick);
if (newTick < 0)
if (this._newTick < 0)
{
newTick = this._now + this.events[this._i].delay;
this._newTick = this._now + this.events[this._i].delay;
}
if (this.events[this._i].loop === true)
{
this.events[this._i].tick = newTick;
this.events[this._i].tick = this._newTick;
this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args);
}
else if (this.events[this._i].repeatCount > 0)
{
this.events[this._i].repeatCount--;
this.events[this._i].tick = newTick;
this.events[this._i].tick = this._newTick;
this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args);
}
else
{
this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args);
this.events.splice(this._i, 1);
this._len--;
this.events[this._i].pendingDelete = true;
}
this._i++;