Releases: phaserjs/phaser
Phaser 3 Alpha Release
This is the Alpha release of Phaser 3.
Please see the Phaser 3 Dev Logs from entry 91 and onwards for more details.
The phaser.js
is a dev build, ideal for local testing and includes full source map data and comments (hence the huge file size).
phaser.min.js
is a minified build, with no source map and comments stripped. You can use this if you'd like to upload a test somewhere and save some bandwidth. With gzip enabled it's just 104KB in size, including all Game Objects and both Canvas and WebGL renderers.
Kore Springs
New Features
- Group.getRandomExists will return a random child from the Group that has exists set to true.
- Group.getAll will return all children in the Group, or a section of the Group, with the optional ability to test if the child has a property matching the given value or not.
- Group.iterate has a new
returnType
:RETURN_ALL
. This allows you to return all children that pass the iteration test in an array. - The property
checkCollision.none
in the ArcadePhysics.Body class was available, but never used internally. It is now used and checked by theseparate
method. By settingcheckCollision.none = true
you can disable all collision and overlap checks on a Body, but still retain its motion updates (thanks @samme #2661) - Math.rotateToAngle takes two angles (in radians), and an interpolation value, and returns a new angle, based on the shortest rotational distance between the two.
- Math.getShortestAngle will return the shortest angle between the two given angles. Angles are in the range -180 to 180, which is what
Sprite.angle
uses. So you can happily feed this method two sprite angles, and get the shortest angle back between them (#2494)
Updates
- TypeScript definitions fixes and updates (thanks @calvindavis @AlvaroBarua)
- Docs typo fixes (thanks @rroylance @Owumaro @boniatillo-com @samme @kjav)
- The InputHandler.flagged property has been removed. It was never used internally, or exposed via the API, so was just overhead.
- The src/system folder has been removed and all files relocated to the src/utils folder. This doesn't change anything from an API point of view, but did change the grunt build scripts slightly.
- BitmapData.shadow and BitmapData.text now both
return this
keeping them in-line with the docs (thanks @greeny #2634) - Group.align has had its arguments changed so that it's now
(width, height, ...)
instead of(rows, columns, ...)
(thanks @deargle #2643) - Group.align now returns
true
if the Group was aligned, orfalse
if not. - The Loader.headers object has a new property
requestedWith
. By default this is set tofalse
, but it can be used to set theX-Requested-With
header toXMLHttpRequest
(or any other value you need). To enable this dothis.load.headers.requestedWith = 'XMLHttpRequest'
before adding anything to the Loader. - ScaleManager.hasPhaserSetFullScreen is a new boolean that identifies if the browser is in full screen mode or not, and if Phaser was the one that requested it. As it's possible to enter full screen mode outside of Phaser, and it then gets confused about what bounding parent to use.
- Phaser.Tileset has a new property
lastgid
which is populated automatically by the TilemapParser when importing Tiled map data, or can be set manually if building your own tileset. - Stage will now check if
document.hidden
is available first, and if it is then never even check for the prefixed versions. This stops warnings like "mozHidden and mozVisibilityState are deprecated" in newer versions of browsers and retain backward compatibility (thanks @leopoldobrines7 #2656) - As a result of changes in #2573 Graphics objects were calling
updateLocalBounds
on any shape change, which could cause dramatic performances drops in Graphics heavy situations (#2618). Graphics objects now have a new flag_boundsDirty
which is used to detect if the bounds have been invalidated, i.e. by a Graphics being cleared or drawn to. If this is set to true thenupdateLocalBounds
is called once in thepostUpdate
method (thanks @Pengchuan #2618) - Phaser.Image now has the ScaleMinMax component.
- Animations now allow for speeds greater than 0, rather than forcing them to be greater than 1. This allows you to have animation speeds slower than 1 frame per second (thanks @jayrobin #2664)
- Weapon.fire and all related methods (fireAtXY, fireAtPointer, fireAtSprite) now all return the instance of the Phaser.Bullet that was fired, or
null
if nothing was fired. Previously it would return a boolean, but this change allows you to perform additional processing on the Bullet as required (thanks @JTronLabs #2696) - Sound.loopFull now returns the Sound instance that was looped (thanks @hilts-vaughan #2697)
- ArcadePhysics Body.rotation now reads its initial value from sprite.angle instead of sprite.rotation. The property was immediately replaced with the correct value in Body.preUpdate regardless, but it keeps it consistent (thanks @samme #2708)
- Weapon.fire now tracks rotation properly, when using an offset and tracking a sprite (thanks @bobonthenet #2672)
Bug Fixes
- A Group with
inputEnableChildren
set would re-start the Input Handler on a Sprite, even if that handler had been disabled previously. - Weapon.autofire wouldn't fire after the first bullet, or until
fire
was called, neither of which are requirements. If you now set this boolean the Weapon will fire continuously until you toggle it back to false (thanks @alverLopez #2647) - ArcadePhysics.World.angleBetweenCenters now uses
centerX
andcenterY
properties to check for the angle between, instead ofcenter.x/y
as that property no longer exists (thanks @leopoldobrines7 #2654) - The Emitter.makeParticles
collide
argument didn't work, as a result of #2661, but is now properly respected thanks to that change (thanks @samme #2662) - Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing.
- Text bounds would incorrectly displace if the Text resolution was greater than 1 (thanks @valent-novem #2685)
- TilemapParser would calculate widthInPixels and heightInPixels were being read incorrectly from JSON data (capitalisation of properties) (thanks @hexus #2691)
- A tinted Texture in Canvas mode wouldn't be updated properly if it was also cropped, beyond the initial crop. Now a cropped texture will re-tint itself every time the crop is updated, and has changed (thanks @phoenixyjll #2688)
- The Weapon.fireRateVariance property was never taken into account internally. It's now applied to the firing rate correctly (thanks @noseglid #2715)
- Text.updateText now sets
Text.dirty = false
, which stops Text objects from havingupdateText
called twice on them after creation.
Pixi Updates
Please note that Phaser uses a custom build of Pixi and always has done. The following changes have been made to our custom build, not to Pixi in general.
- This version contains significant fixes for
DisplayObject.getBounds
andDisplayObjectContainer.getBounds
. The methods can now accept an optional argumenttargetCoordinateSpace
which makes it much more flexible, allowing you to check the bounds against any target, not just local and global ones. If thetargetCoordinateSpace
is a valid DisplayObject:- If it's a parent of the caller at some level it will return the bounds
relative to it. - if it's not parenting the caller at all, it will get the global bounds of
it, and the caller and will calculate the x and y bounds of the caller
relative to the targetCoordinateSpace DisplayObject.
- If it's a parent of the caller at some level it will return the bounds
As a result this also fixes how empty Groups are treated when they have no other children except Groups. So now calculations are correct.
- DisplayObjectContainer.contains(child) is a new method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is used in the new getBounds function.
- Corrected DisplayObjects default
_bounds
rect from (0, 0, 1, 1) to (0, 0, 0, 0). - Thanks to @fmflame for his hard work on the above (#2639 #2627)
- The methods
setStageReference
andremoveStageReference
have been removed from all Pixi classes. Objects no longer havestage
properties, or references to the Stage object. This is because no reference to the Stage is required for any calculations, and Phaser can only have 1 Stage, so adding and removing references to it were superfluous actions. - The file pixi/utils/Polyk.js has been removed, as it was no longer used with Pixi or Phaser (we replaced it with EarCut a while ago)
Caemlyn
Version 2.6.1 - "Caemlyn" - 11th July 2016
Bug Fixes
- Fixed
Uncaught TypeError: Cannot set property 'x' of undefined
in Body.js (thanks @ErwanErwan #2607)
Fal Moran
Version 2.6.0 - "Fal Moran" - 8th July 2016
New Features
- The Loader has a new property
headers
. This is an object checked by XHR Requests, used to set the Request Header of certain file types. JSON and XML are pre-configured, but you can add to, or modify this property as required (thanks @stoneman1 #2585 #2485) - Phaser now has support for Typings, the TypeScript Definition Manager. See the
typescript/readme.md
file for installation instructions (thanks @monagames #2576) - Phaser.Utils.reverseString will take the given string, reverse it, and then return it.
- Phaser.ArrayUtils.rotateRight is the opposite of ArrayUtils.rotate. It takes an array, removes the element from the end of the array, and inserts it at the start, shifting everything else 1 space in the process.
- Phaser.ArrayUtils.rotateLeft is the new name for Phaser.ArrayUtils.rotate. The old method is now deprecated (but still available in this release)
- Phaser.Color.toABGR converts RGBA components to a 32 bit integer in AABBGGRR format.
- ArcadePhysics.Body.setCircle is a new method that allows you to define an Arcade Physics Body as being a circle instead of a rectangle. You can control the radius of the body and the offset from the parent sprite.
- ArcadePhysics.World.separateCircle is a new method that handles all circular body collisions internally within Arcade Physics (thanks @VitaZheltyakov)
- All of the Arcade Physics internal methods, such as
collideGroupVsSelf
,collideSpriteVsSprite
and so on, have been updated to work with circular body shapes (thanks @VitaZheltyakov) - ArcadePhysics.Body.onWorldBounds is a new Signal that is dispatched whenever the Body collides with the world bounds, something that was previously difficult to detect. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal:
sprite.body.onWorldBounds = new Phaser.Signal()
and it will be called when a collision happens, passing five arguments: the sprite on which it occurred, and 4 booleans mapping to up, down, left and right, indicating on which side of the world the collision occurred. - ArcadePhysics.Body.onCollide is a new Signal that is dispatched whenever the Body collides with another Body. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal:
sprite.body.onCollide = new Phaser.Signal()
and it will be called when a collision happens, passing two arguments: the sprites which collided. - ArcadePhysics.Body.onOverlap is a new Signal that is dispatched whenever the Body overlaps with another Body. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal:
sprite.body.onOverlap = new Phaser.Signal()
and it will be called when an overlap happens, passing two arguments: the sprites which collided. - Groups now have the following properties, which are getters and setters:
centerX
,centerY
,left
,right
,top
andbottom
. These calculate the bounds of the Group, based on all visible children, and then allow you to apply positioning based on that. This means you can, for example, now get the horizontal center of a Group by calledGroup.centerX
. These properties are also setters, so you can position the Groups, and it will take scale and rotation into consideration. - Groups have a new method
alignIn
. It allows you to align the Group within another Game Object, or a Rectangle. You can specify one of 9 positions which are the new position constants such as:Phaser.TOP_LEFT
orPhaser.CENTER
(see docs for the complete list). The Groups are positioned based on their child bounds, which takes rotation and scaling into consideration. You can easily place Groups into the corners of the screen, or game world, or align them within other Sprites, using this method. - Groups have a new method
alignTo
. It allows you to align a Group to the side of another Game Object, or a Rectangle. You can specify one of 11 positions which are the new position constants such as:Phaser.TOP_LEFT
orPhaser.LEFT_BOTTOM
(see docs for the complete list). The Groups are positioned based on their child bounds, which takes rotation and scaling into consideration. You can easily align Groups next to other Sprites using this method.
Updates
- TypeScript definitions fixes and updates (thanks @monagames)
- Docs typo fixes (thanks @drhayes)
- The TilemapParser will now add more data when importing Image object types from Tiled. The extra data available is: image width, image height, and flags to see if the image is flipped either horizontally, vertically or diagonally (thanks @gotenxds #2564 #2554)
- TilemapLayer.renderRegion has had an assignment to the obsolete
tileColor
property removed (thanks @cryptographer #2583) - Group.getFurthestFrom and Group.getClosestTo has a new optional argument:
callback
. This allows you to apply your own additional filtering to the distance checks, ultimately influencing the selected child (thanks @LoneStranger #2577) - Text.setText has a new optional argument
immediate
which will re-create the texture immediately upon call, rather than wait for the next render pass to do so (thanks @Scraft #2594) - Phaser.Utils.pad now calls
toString
on the input given, which means you can pass in common data types, such as numbers, and have them padded and returned as strings. - The canvas created by Phaser.Debug for use when displaying debug data is no longer stored in the CanvasPool, and is instead a stand-alone canvas, free from ever being re-used by another game object.
- BitmapData has a new, optional, fifth argument:
skipPool
. By default BitmapData objects will ask for the first free canvas found in the CanvasPool, but this behavior can now be customized on a per object basis. - Phaser.ArrayUtils.rotate is now deprecated. Please use Phaser.ArrayUtils.rotateLeft instead.
- Phaser.Text.fontPropertiesCanvas used to be taken from the CanvasPool, but as it's constantly needed it is now generated directly from the document.
- The default image texture, for when none is supplied, is now available under
Phaser.Cache.DEFAULT
. - The missing image texture, for when an image has failed to load, is now available under
Phaser.Cache.MISSING
. - Phaser.Cache.addImage will now check the key given, and if
__default
or__missing
it will update the new constsPhaser.Cache.DEFAULT
andPhaser.Cache.MISSING
accordingly, allowing you to replace the default or missing image textures used by Phaser. - Phaser.Cache.getPixiTexture has now been removed, as the Pixi Cache isn't used internally anywhere any longer.
- Phaser.Cache.getPixiBaseTexture has now been removed, as the Pixi Cache isn't used internally anywhere any longer.
- The second argument to Phaser.Cache.removeImage has been renamed from
removeFromPixi
todestroyBaseTexture
, as that is fundamentally what the argument always did. - AnimationManager.refreshFrame has been removed as it never actually did anything internally.
- Sound.stop will check to see if
gainNode
exists before trying to disconnect from it (#2597)
Bug Fixes
- Fixed issue in Group.align where the cell wouldn't increase if
rows
was great than -1 - Sound.volume was accidentally repeated twice in the source (thanks @LoneStranger #2569)
- Animation.setFrame wouldn't work correctly if the
useLocalFrameIndex
argument was true, and the frame ID was a number (thanks @uboot #2571) - Polygon.contains would only work with non-flattened Polygon objects. It now works with both flat and non-flat Polygons.
- Graphics objects enabled for input would fail to do anything if a Phaser Polygon was given to the Graphics object (which it was in nearly all cases), as it wouldn't detect input correctly with flattened polygons (thanks @symbiane #2591)
- P2.World.clear will now clear out the World.walls property, resetting all of the wall bounds to
null
. This allows the walls to be re-created accurately when the P2 World is reset, which happens on a State change or restart (thanks @ewpolly1 @codermua #2574)
Pixi Updates
Please note that Phaser uses a custom build of Pixi and always has done. The following changes have been made to our custom build, not to Pixi in general.
- Removed
_renderWebGL
,_renderCanvas
,getLocalBounds
andgetBounds
from PIXI.DisplayObject, as they were only there to pass ancient jshint rules. - All Pixi.Graphics methods that change the Graphics, i.e.
drawShape
,lineTo
,arc
, etc will now all automatically callGraphics.updateLocalBounds
. This is so that the bounds of the Graphics object are kept updated, allowing you to scale and rotate the Graphics object and still obtain correct dimensions from it (thanks @kelu-smiley #2573) - PIXI.CanvasPool no longer just checks for
null
parent comparisons. It will check for all falsey parents, helping free-up canvases when the parent objects have been removed elsewhere. - PIXI.CanvasPool.remove and
removeByCanvas
both now set the removed canvas width and height to 1. - PIXI.Texture.fromImage, PIXI.BaseTexture.fromImage and PIXI.Sprite.fromImage have all been removed. They should never have actually been used, as they bypass the Phaser Loader, and don't factor in CORs or any other advanced loader settings.
- The PIXI.BaseTexture.imageUrl property has been removed, as it was never actually populated.
- The PIXI.BaseTexture._UID property has been removed, as it was never actually used internally.
- All references to PIXI.BaseTextureCache have been removed (primarily from BaseTexture.destroy and Texture.destroy), as the BaseTextureCache was never used internally by Phaser, or by our custom version of Pixi.
- PIXI.TextureCache has been removed. It was only ever used by the __default and __missing images that Phaser generates on start-up. It wasn't used internally by Phase...
Five Kings
Version 2.5.0 - "Five Kings" - 17th June 2016
Note: This version was also released as 2.4.9 'Four Kings' on 16th June 2016. The 2.5.0 release marks us moving to a more strict adherence of the Semver rules, and also contains some TypeScript definitions fixes.
New Features
- Phaser.Line.intersectsRectangle checks for intersection between a Line and a Rectangle, or any Rectangle-like object such as a Sprite or Body.
- Group.getClosestTo will return the child closest to the given point (thanks @Nuuf #2504)
- Group.getFurthestFrom will return the child farthest away from the given point (thanks @Nuuf #2504)
- Animation.reverse will reverse the currently playing animation direction (thanks @gotenxds #2505)
- Animation.reverseOnce will reverse the animation direction for the current, or next animation only (thanks @gotenxds #2505)
- The way the display list updates and Camera movements are handled has been completely revamped, which should result is significantly smoother motion when the Camera is following tweened or physics controlled sprites. The
Stage.postUpdate
function is now vastly reduced in complexity. It takes control over updating the display list (callingupdateTransform
on itself), rather than letting the Canvas or WebGL renderers do this. Because of this change, theCamera.updateTarget
function uses the SpritesworldPosition
property instead, which is now frame accurate (thanks @whig @Upperfoot @Whoisnt @hexus #2482) - Game Objects including Sprite, Image, Particle, TilemapLayer, Text, BitmapText and TileSprite have a new property called
data
. This is an empty Object that Phaser will never touch internally, but your own code, or Phaser Plugins, can store Game Object specific data within it. This allows you to associate data with a Game Object without having to pollute or change its class shape. - TilemapLayers will now collide properly when they have a position that isn't set to 0x0. For example if you're stitching together several maps, one after the other, and manually adjust their
scrollX/Y
properties (thanks @Upperfoot #2522) - There are a bunch of new Phaser consts available to help with setting the angle of a Game Object. They are
Phaser.ANGLE_UP
,ANGLE_DOWN
,ANGLE_LEFT
,ANGLE_RIGHT
,ANGLE_NORTH_EAST
,ANGLE_NORTH_WEST
,ANGLE_SOUTH_EAST
andANGLE_SOUTH_WEST
. - Math.between will return a value between the given
min
andmax
values. - InputHandler.dragDistanceThreshold gives you more fine control over when a Sprite Drag event will start. It allows you to specify a distance, in pixels, that the pointer must have moved before the drag will begin.
- InputHandler.dragTimeThreshold gives you more fine control over when a Sprite Drag event will start. It allows you to specify a time, in ms that the pointer must have been held down for, before the drag will begin.
- InputHandler.downPoint is a new Point object that contains the coordinates of the Pointer when it was first pressed down on the Sprite.
- There are two new Phaser consts available, for help with orientation of games or Game Objects. They are
Phaser.HORIZONTAL
,Phaser.VERTICAL
,Phaser.LANDSCAPE
andPhaser.PORTRAIT
. - InputHandler.dragStopBlocksInputUp is a boolean that allows you to control what happens with the input events. If
false
(the default) then both theonInputUp
andonDragStop
events will get dispatched when a Sprite stops being dragged. Iftrue
then only theonDragStop
event is dispatched, and theonInputUp
is skipped. - Group.inputEnableChildren is a new property. If set to
true
will automatically callinputEnabled = true
on any children added to, or created by, the Group. - PIXI.DisplayObjectContainer.ignoreChildInput is a new property. If
true
then the children will not be considered as valid for Input events. Because this has been applied toDisplayObjectContainer
it means it's available in Group, Sprite and any other display level object. Using this boolean you can disable input events for all children in an entire Group, without having to iterate anything or deep-set flags. - InputHandler._pointerOverHandler and _pointerOutHandler have new arguments
silent
- iftrue
then they will not dispatch any Signals from the parent Sprite. - Pointer.interactiveCandidates is a new Array that is erased and re-populated every time this Pointer is updated. It contains references to all of the Game Objects that were considered as being valid for processing by this Pointer, during the most recent update. To be valid they must have suitable a
priorityID
, be Input enabled, be visible and actually have the Pointer over them. You can check the contents of this array in events such asonInputDown
, but beware: it is reset every update. - Pointer.swapTarget allows you to change the
Pointer.targetObject
object to be the one provided. This allows you to have fine-grained control over which object the Pointer is targeting. - Input.setInteractiveCandidateHandler allows you to add a callback that is fired every time
Pointer.processInteractiveObjects
is called. The purpose ofprocessInteractiveObjects
is to work out which Game Object the Pointer is going to interact with. It works by polling all of the valid game objects, and then slowly discounting those that don't meet the criteria (i.e. they aren't under the Pointer, are disabled, invisible, etc). Eventually a short-list of 'candidates' is created. These are all of the Game Objects which are valid for input and overlap with the Pointer. If you need fine-grained control over which of the items is selected then you can use this callback to do so. The callback will be sent 3 parameters: 1) A reference to the Phaser.Pointer object that is processing the Items. 2) An array containing all potential interactive candidates. This is an array ofInputHandler
objects, not Sprites. 3) The current 'favorite' candidate, based on its priorityID and position in the display list. Your callback MUST return one of the candidates sent to it. - Group.onChildInputDown is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputDown
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Group.onChildInputUp is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputUp
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Group.onChildInputOver is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputOver
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Group.onChildInputOut is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputOut
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Phaser.Weapon is a brand new plugin that provides the ability to easily create a bullet pool and manager. Weapons fire Phaser.Bullet objects, which are essentially Sprites with a few extra properties. The Bullets are enabled for Arcade Physics. They do not currently work with P2 Physics. The Bullets are created inside of
Weapon.bullets
, which is a Phaser.Group instance. Anything you can usually do with a Group, such as move it around the display list, iterate it, etc can be done to the bullets Group too. Bullets can have textures and even animations. You can control the speed at which they are fired, the firing rate, the firing angle, and even set things like gravity for them. Please see the Documentation for more details, or view the Weapon examples in the Examples repo. - BitmapData.smoothProperty is a new property that holds the string based prefix needed to set image scaling on the BitmapData context.
- BitmapData.copyTransform allows you to draw a Game Object to the BitmapData, using its
worldTransform
property to control the location, scaling and rotation of the object. You can optionally provide - BitmapData.drawGroup now uses the new
copyTransform
method, to provide for far more accurate results. Previously nested Game Objects wouldn't render correctly, nor would Sprites added viaaddChild
to another Sprite. BitmapText objects also rendered without rotation taken into account, and the Sprites smoothing property was ignored. All of these things are now covered by the new drawGroup method, which also handles full deep iteration down the display list. - Added the following new constants:
Phaser.TOP_LEFT
,Phaser.TOP_CENTER
,Phaser.TOP_RIGHT
,Phaser.LEFT_TOP
,Phaser.LEFT_CENTER
,Phaser.LEFT_BOTTOM
,Phaser.CENTER
,Phaser.RIGHT_TOP
,Phaser.RIGHT_CENTER
,Phaser.RIGHT_BOTTOM
,Phaser.BOTTOM_LEFT
,Phaser.BOTTOM_CENTER
andPhaser.BOTTOM_RIGHT
. - Rectangle.getPoint is a new method that returns a point based on the given position constant, such as
Phaser.BOTTOM_LEFT
. It returns the same result as callingRectangle.bottomLeft
(etc) but unlike those getters you are able to provide your own Point object. - The Game Object Bounds component has been updated to include two new properties:
centerX
andcenterY
. This means you can, for example, now get the horizontal center of a Sprite by calledSprite.centerX
. These properties are also setters, so you can position the Game Objects, and it will take scale and anchor into consideration. - All Game Objects with the Bounds component; which includes Sprites, Images, Text, BitmapText, TileSprites and anything that extend these, now have the new method
alignIn
. It allows you to align the Game Object within another Game Object, or a Rectangle. You can specify one of 9 positions which are the new position constants such as: `Phaser.TO...
Four Kings
Version 2.4.9 - "Four Kings" - 16th June 2016
New Features
- Phaser.Line.intersectsRectangle checks for intersection between a Line and a Rectangle, or any Rectangle-like object such as a Sprite or Body.
- Group.getClosestTo will return the child closest to the given point (thanks @Nuuf #2504)
- Group.getFurthestFrom will return the child farthest away from the given point (thanks @Nuuf #2504)
- Animation.reverse will reverse the currently playing animation direction (thanks @gotenxds #2505)
- Animation.reverseOnce will reverse the animation direction for the current, or next animation only (thanks @gotenxds #2505)
- The way the display list updates and Camera movements are handled has been completely revamped, which should result is significantly smoother motion when the Camera is following tweened or physics controlled sprites. The
Stage.postUpdate
function is now vastly reduced in complexity. It takes control over updating the display list (callingupdateTransform
on itself), rather than letting the Canvas or WebGL renderers do this. Because of this change, theCamera.updateTarget
function uses the SpritesworldPosition
property instead, which is now frame accurate (thanks @whig @Upperfoot @Whoisnt @hexus #2482) - Game Objects including Sprite, Image, Particle, TilemapLayer, Text, BitmapText and TileSprite have a new property called
data
. This is an empty Object that Phaser will never touch internally, but your own code, or Phaser Plugins, can store Game Object specific data within it. This allows you to associate data with a Game Object without having to pollute or change its class shape. - TilemapLayers will now collide properly when they have a position that isn't set to 0x0. For example if you're stitching together several maps, one after the other, and manually adjust their
scrollX/Y
properties (thanks @Upperfoot #2522) - There are a bunch of new Phaser consts available to help with setting the angle of a Game Object. They are
Phaser.ANGLE_UP
,ANGLE_DOWN
,ANGLE_LEFT
,ANGLE_RIGHT
,ANGLE_NORTH_EAST
,ANGLE_NORTH_WEST
,ANGLE_SOUTH_EAST
andANGLE_SOUTH_WEST
. - Math.between will return a value between the given
min
andmax
values. - InputHandler.dragDistanceThreshold gives you more fine control over when a Sprite Drag event will start. It allows you to specify a distance, in pixels, that the pointer must have moved before the drag will begin.
- InputHandler.dragTimeThreshold gives you more fine control over when a Sprite Drag event will start. It allows you to specify a time, in ms that the pointer must have been held down for, before the drag will begin.
- InputHandler.downPoint is a new Point object that contains the coordinates of the Pointer when it was first pressed down on the Sprite.
- There are two new Phaser consts available, for help with orientation of games or Game Objects. They are
Phaser.HORIZONTAL
,Phaser.VERTICAL
,Phaser.LANDSCAPE
andPhaser.PORTRAIT
. - InputHandler.dragStopBlocksInputUp is a boolean that allows you to control what happens with the input events. If
false
(the default) then both theonInputUp
andonDragStop
events will get dispatched when a Sprite stops being dragged. Iftrue
then only theonDragStop
event is dispatched, and theonInputUp
is skipped. - Group.inputEnableChildren is a new property. If set to
true
will automatically callinputEnabled = true
on any children added to, or created by, the Group. - PIXI.DisplayObjectContainer.ignoreChildInput is a new property. If
true
then the children will not be considered as valid for Input events. Because this has been applied toDisplayObjectContainer
it means it's available in Group, Sprite and any other display level object. Using this boolean you can disable input events for all children in an entire Group, without having to iterate anything or deep-set flags. - InputHandler._pointerOverHandler and _pointerOutHandler have new arguments
silent
- iftrue
then they will not dispatch any Signals from the parent Sprite. - Pointer.interactiveCandidates is a new Array that is erased and re-populated every time this Pointer is updated. It contains references to all of the Game Objects that were considered as being valid for processing by this Pointer, during the most recent update. To be valid they must have suitable a
priorityID
, be Input enabled, be visible and actually have the Pointer over them. You can check the contents of this array in events such asonInputDown
, but beware: it is reset every update. - Pointer.swapTarget allows you to change the
Pointer.targetObject
object to be the one provided. This allows you to have fine-grained control over which object the Pointer is targeting. - Input.setInteractiveCandidateHandler allows you to add a callback that is fired every time
Pointer.processInteractiveObjects
is called. The purpose ofprocessInteractiveObjects
is to work out which Game Object the Pointer is going to interact with. It works by polling all of the valid game objects, and then slowly discounting those that don't meet the criteria (i.e. they aren't under the Pointer, are disabled, invisible, etc). Eventually a short-list of 'candidates' is created. These are all of the Game Objects which are valid for input and overlap with the Pointer. If you need fine-grained control over which of the items is selected then you can use this callback to do so. The callback will be sent 3 parameters: 1) A reference to the Phaser.Pointer object that is processing the Items. 2) An array containing all potential interactive candidates. This is an array ofInputHandler
objects, not Sprites. 3) The current 'favorite' candidate, based on its priorityID and position in the display list. Your callback MUST return one of the candidates sent to it. - Group.onChildInputDown is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputDown
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Group.onChildInputUp is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputUp
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Group.onChildInputOver is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputOver
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Group.onChildInputOut is a new Signal that you can listen to. It will be dispatched whenever any immediate child of the Group emits an
onInputOut
signal itself. This allows you to listen for a Signal from the Group, rather than every Sprite within it. - Phaser.Weapon is a brand new plugin that provides the ability to easily create a bullet pool and manager. Weapons fire Phaser.Bullet objects, which are essentially Sprites with a few extra properties. The Bullets are enabled for Arcade Physics. They do not currently work with P2 Physics. The Bullets are created inside of
Weapon.bullets
, which is a Phaser.Group instance. Anything you can usually do with a Group, such as move it around the display list, iterate it, etc can be done to the bullets Group too. Bullets can have textures and even animations. You can control the speed at which they are fired, the firing rate, the firing angle, and even set things like gravity for them. Please see the Documentation for more details, or view the Weapon examples in the Examples repo. - BitmapData.smoothProperty is a new property that holds the string based prefix needed to set image scaling on the BitmapData context.
- BitmapData.copyTransform allows you to draw a Game Object to the BitmapData, using its
worldTransform
property to control the location, scaling and rotation of the object. You can optionally provide - BitmapData.drawGroup now uses the new
copyTransform
method, to provide for far more accurate results. Previously nested Game Objects wouldn't render correctly, nor would Sprites added viaaddChild
to another Sprite. BitmapText objects also rendered without rotation taken into account, and the Sprites smoothing property was ignored. All of these things are now covered by the new drawGroup method, which also handles full deep iteration down the display list. - Added the following new constants:
Phaser.TOP_LEFT
,Phaser.TOP_CENTER
,Phaser.TOP_RIGHT
,Phaser.LEFT_TOP
,Phaser.LEFT_CENTER
,Phaser.LEFT_BOTTOM
,Phaser.CENTER
,Phaser.RIGHT_TOP
,Phaser.RIGHT_CENTER
,Phaser.RIGHT_BOTTOM
,Phaser.BOTTOM_LEFT
,Phaser.BOTTOM_CENTER
andPhaser.BOTTOM_RIGHT
. - Rectangle.getPoint is a new method that returns a point based on the given position constant, such as
Phaser.BOTTOM_LEFT
. It returns the same result as callingRectangle.bottomLeft
(etc) but unlike those getters you are able to provide your own Point object. - The Game Object Bounds component has been updated to include two new properties:
centerX
andcenterY
. This means you can, for example, now get the horizontal center of a Sprite by calledSprite.centerX
. These properties are also setters, so you can position the Game Objects, and it will take scale and anchor into consideration. - All Game Objects with the Bounds component; which includes Sprites, Images, Text, BitmapText, TileSprites and anything that extend these, now have the new method
alignIn
. It allows you to align the Game Object within another Game Object, or a Rectangle. You can specify one of 9 positions which are the new position constants such as:Phaser.TOP_LEFT
orPhaser.CENTER
(see above for the complete list). The Game Objects are positioned based on their Bounds, which takes rotation, scaling and anchor into consideration. You can easily place Sprites into the co...
Watch Hill
Version 2.4.8 - "Watch Hill" - 19th May 2016
New Features
- BitmapData.copy, and by extension any method that uses it, including BitmapData.draw, drawGroup and drawFull, now all support drawing RenderTexture objects. These can either be passed directly, or be the textures of Sprites, such as from a call to generateTexture.
- Arcade Physics has had a new
world
argument added to the following functions:distanceBetween
,distanceToXY
,distanceToPointer
,angleBetween
,angleToXY
andangleToPointer
. The argument (which is false by default), when enabled will calculate the angles or distances based on the Game Objectsworld
property, instead of itsx
andy
properties. This allows it to work for objects that are placed in offset Groups, or are children of other display objects (thanks @Skeptron for the thread #2463) - Arcade Physics Body has a new property
worldBounce
. This controls the elasticity of the Body specifically when colliding with the World bounds. By default this property isnull
, in which case Body.bounce is used instead. Set this property to a Phaser.Point object in order to enable a World bounds specific bounce value (thanks @VitaZheltyakov #2465)
Updates
- TypeScript definitions fixes and updates (thanks @osev7 @staff0rd @galen-manuel)
- Docs typo fixes (thanks @dedoubleyou1 @mortonfox @zeterain)
- You can now access the intensity of the Camera shake effect via the getter / setter
Camera.shakeIntensity
. Useful if you wish to tween the intensity while running. (thanks @drhayes #2443) - The Arcade Physics overlap method would return false if two bodies were overlapping but neither had any velocity (i.e. they were embedded into each other)
- PIXI.defaultRenderer is now set to
null
in Game.destroy, allowing it to be reset if a new Game instance is created on the same page (thanks @xtforgame ##2474) - BitmapData.drawGroupProxy is now capable of iterating through Sprites that have children, and also now uses the world positions for drawing instead. This change updates the functionality of BitmapData.drawGroup.
- Text.setStyle has a new argument
update
which will optionally automatically callupdateText
after setting the new style (thanks @staff0rd #2478)
Bug Fixes
- Fixed an issue in the Arcade Physics overlap method where it would only detect overlaps up to the max bias threshold and no further (thanks @rgk #2441)
- InputHandler.checkPointerDown and checkPointerOver will now test the worldTransform scale property of a Sprite. If zero it will fast return, where-as before it would incorrectly report an up event (thanks @jaapaurelio #2466)
- Fixed a bug in Arcade Physics Body.preUpdate which would incorrectly apply the position of an offset Body (one which has had Body.setSize used on it) when combined with a Sprite with a non-zero anchor (thanks @SBCGames #2470)
- If you set Game.renderType to
Phaser.HEADLESS
it will no longer render the output to the canvas. The canvas is still created (although not added to the DOM), as it's required internally, but no rendering now takes place on it (thanks @ForgeableSum #2464) - Sounds played using the Audio tag, that were paused and then resumed again (either directly in code, or via a game pause event) would not resume from the point at which they paused (thanks @rroylance #2473)
- Sounds played using the Audio tag, set to loop, would get caught in an endless pause-play loop cycle (thanks @rroylance #2473)
Pixi Updates
Please note that Phaser uses a custom build of Pixi and always has done. The following changes have been made to our custom build, not to Pixi in general.
Hinderstap
Version 2.4.7 - "Hinderstap" - 22nd April 2016
New Features
- Added P2.Body.thrustLeft which will move the Body to the left by the speed given (thanks James Pryor)
- Added P2.Body.thrustRight which will move the Body to the right by the speed given (thanks James Pryor)
- Polygon now takes an array of arrays as a new type when constructing it:
[[x1, y1], [x2, y2]]
(thanks @ShimShamSam #2360) - Text has a new property
maxLines
which is the maximum number of lines to be shown for wrapped text. If set to 0 (the default) there is limit. This prevents wrapped text from overflowing on a fixed layout (thanks @slashman #2410) outOfCameraBoundsKill
is a new boolean property that all Game Objects with theInWorld
component has. IfautoCull
and this property are bothtrue
then the Object will be automatically killed if it leaves the camera bounds (thanks @jakewilson #2402)- Group.getByName searches the Group for the first instance of a child with the
name
property matching the given argument. Should more than one child have the same name only the first instance is returned. - BitmapData has a new property
frameData
which is a Phaser.FrameData container instance. It contains a single Frame by default, matching the dimensions of the entire BitmapData, but can be populated with additional frames should you wish to create animations from dynamic BitmapData textures. - FrameData.destroy will nullify the local arrays used to contain Frame instances.
- SoundManager.muteOnPause is a new boolean that allows you to control if the Sound system gets muted automatically when a Phaser game pauses, such as when it loses focus. You may need to set this to
false
if you wish to control the audio system from outside of your Phaser game, i.e. from DOM buttons or similar (#2382) - You can now pass a TilemapLayer as a Texture to a TileSprite. A limitation of this is that if you pass it to a TileSprite it will make a fill pattern from the TilemapLayer at that instant it's passed, and it won't keep track of the layer in future should it update (thanks @jdnichollsc #1989)
- Camera has a new property:
lerp
. This is a Point object, that allows you to control the amount of horizontal and vertical smoothing to be applied to the camera when it tracks a Sprite. It works both with and without deadzones, and is turned off by default. Set it to low values such as 0.1 for really smooth motion tracking (thanks to @WombatTurkey for the idea of adding this) - Camera.shake is a new function that creates a camera shake effect. You can specify the intensity, duration and direction of the effect. You can also set if it should shake the camera out of bounds or not.
- Camera.flash is a new function that makes the camera 'flash' over the top of your game. It works by filling the game with the solid fill color specified, and then fading it away to alpha 0 over the duration given. This is great for things like hit effects. You can listen for the Camera.onflashComplete Signal.
- Camera.fade is a new function that makes the camera fade to the color given, over the course of the duration specified. This is great for things like transitioning from one State to another. You can listen for the Camera.onFadeComplete Signal.
- Camera.resetFX resets any active FX, such as a fade or flash and immediately clears it. Useful for calling after a fade in order to remove the fade from the Stage.
- Phaser.Camera.ENABLE_FX is a const that controls if the Camera FX are available or not. It's
true
by default, but if you set it tofalse
before boot then it won't create the Graphics object required to process the effects. - The Arcade Physics Body has two new properties:
left
andtop
. These are the same asBody.x
andBody.y
but allow you to pass the Body to geometry level functions such as Circle.contains. - World.separate has been optimized to cut down on the number of calls to
intersect
from 3 calls per Game Object collision check, to 2. So if you were colliding 50 sprites it will reduce the call count from 150 to 100 per frame. It also reduces the calls made toseperateX
andseperateY
by the same factor. - Two immovable bodies would never set their overlap data, even if an overlap only check was being made. As this is useful data to have this has been changed. Two immovable bodies will still never separate from each other, but they will have their
overlapX
andoverlapY
properties calculated now. - P2.Body.offset is now used and applied to the Sprite position during rendering. The values given are normal pixel values, and offset the P2 Body from the center of the Sprite (thanks @Mourtz #2430)
Updates
- TypeScript definitions fixes and updates (thanks @jamesgroat @kiswa)
- Docs typo fixes (thanks @thiagojobson @hayesmaker @EJanuszewski)
- Removed a
console.log
from the TilingSprite generator. - Sound.position can no longer become negative, meaning calls to AudioContextNode.start with negative position offsets will no longer throw errors (thanks @Weedshaker #2351 #2368)
- The default state of the internal property
_boundDispatch
in Phaser.Signal is nowfalse
, which allows for use of boundDispatches (thanks @alvinlao #2346) - The Tiled parser only supports uncompressed layer data. Previously it would silently fail, now it detects if layer compression is used and displays a console warning instead (thanks @MannyC #2413)
- The Tiled parser now removes the
encoding
parameter so that a subsequent process doesn't try to decode the data again (thanks @MannyC #2412) - Ensure a parent container is a Group before removing from its hash (thanks @rblopes #2397)
- The Game Object Input Handler now checks to see if the Object was destroyed during the
onInputDown
phase, and bails out early if so (thanks @zeterain #2394) - The Destroy component will now call TweenManager.removeFrom, removing any active tweens from the TweenManager upon the Game Objects destructions (thanks @PokemonAshLovesMyTurkeyAndILikeYouTwo #2408)
- Tween.update will now return
false
(flagging the Tween for destruction) should the Tween.target property every become falsey. This can happen if the object the Tween was tracking is destroyed, nulled or generally removed. - TweenData.repeatTotal is a new property that keeps track of the total number of times the Tween should repeat. If TweenData.start is called, as a result of the Tween repeatCount being > 0 then the child tween resets its total before re-starting.
- The Debug canvas now listens for the ScaleManager.onSizeChange signal and resizes itself accordingly when running under WebGL. This means if your game size changes the Debug canvas won't be clipped off (thanks @francisberesford #1919)
- Camera.follow now uses the Targets
world
property to seed the camera coordinates from, rather than its local position. This means Sprites that are members of offset Groups, or transformed display lists, should now be followed more accurately (thanks @rbozan #2106) - PluginManager.destroy is now called by Game.destroy.
- Game.forceSingleUpdate is now
true
by default. - Video now uses MediaStreamTrack.stop() instead of MediaStream.stop() where possible, as the later is now deprecated in some browsers (thanks @stoneman1 #2371)
- The Physics Manager will now throw a console warning if you try to enable a physics body using an unknown physics engine type (thanks @jakewilson #2415)
- The Tileset class will tell you the name of the tileset image throwing the uneven size error (thanks @jakewilson #2415)
- Emitter.start when used with a false
explode
parameter would cumulatively add particles to the current total. With quantity 10 the first call would emit 10 particles, the next 20, and so on. Calls to start will now reset the quantity each time. This is a behavior change from earlier versions, so if you relied on the old way please account for it in your code (thanks @BdR76 #2187) - You can now pass in your own Canvas element to Phaser and it will use that instead of creating one itself. To do so you must pass a Game Configuration object to Phaser when you instantiate it, and set the
canvas
property of the config object to be the DOM element you wish to use, i.e.:{ canvas: document.getElementById('yourCanvas') }
(thanks @Friksel #2311) - When loading Video with the
asBlob
argument set it now uses a 'blob' type for the XHR loader, and doesn't cast the resulting file as a Blob upon load. This fixes loading videos as blobs on Chrome for Android (thanks @JuCarr #2433) - When the Loader loads audio via the Audio tag, instead of Web Audio, it used to use
Phaser.GAMES[_this.game.id].load
as the callback handler, which would stop it from working if you had multiple Loaders set-up within Phaser. It now uses a local reference to_this
instead (thanks @SBCGames #2435)
Bug Fixes
- The
mouseoutglobal
event listener wasn't removed when the game was destroyed (thanks @stoneman1 #2345 #2344 #2342) - Fixed issue with IE crashing on this.context.close in the Sound Manager (thanks @stoneman1 #2349)
- Phaser.World.centerX and Phaser.World.centerY only worked if the bounds had an origin of 0, 0. They now take into account the actual origin (thanks @fillmoreb #2353)
- SoundManager.destroy now validates that context.close is a valid function before calling it (thanks @brianbunch #2355)
- SoundManager.destroy doesn't close the context if it's being stored in PhaserGlobal (thanks @brianbunch #2356)
- Fix typo in p2 BodyDebug.componentToHex that made most debug bodies appear reddish in color (thanks @englercj #2381)
- Previously when a sprite was tinted and a new texture was loaded then the tint did not apply to the texture and the old tinted texture was used (thanks @CptSelewin #2383)
- Negative lineSpacing in Text objects will no longer crop the bottom pixels off lines of text (thanks @gaelenh #2379 #2374)
- BitmapData.copy, and by extension draw, drawFull, drawGroup, etc, would incorrectly handle drawing a tinted Sprite if it ...
Baerlon
2.4.6 is a point release that addresses 2 severe bugs, and should be used in place of 2.4.5 in all instances. The 2.4.5 change log appears after this one.
New Features
- Added RandomDataGenerator.sign, which returns a -1 or 1 (thanks @taylankasap #2328)
Updates
- StateManager.destroy now sets
clearCache
andclearWorld
internally before clearing the current state, as otherwise they would have been left untouched, such as from Game.destroy (thanks @i-dimitrov #2138)
Bug Fixes
- Groups now check for
child.parent
before callingremoveFromHash
(thanks @spayton #2323 #2338) - BaseTexture.destroy wasn't correctly removing the texture from the BaseTextureCache if it was a cached CanvasPool entry (such as Text objects use), causing drawImage errors in Canvas mode, and just blank textures in WebGL (thanks @civet #2339)
- Loader.getAudioURL and Loader.getVideoURL were hardened to support query string file URLs and still work with uri pairs and data/blobs.
Version 2.4.5 - "Sienda" - 17th February 2016
New Features
- You can use the new const
Phaser.PENDING_ATLAS
as the texture key for any sprite. Doing this then sets the key to be theframe
argument (the frame is set to zero). This allows you to create sprites usingload.image
during development, and then change them to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' and swapping it to be the key of the atlas data. - BitmapText.cleanText is a new method that will scan the given text and either remove or replace all characters that are not present in the font data.
- ArcadePhysics.Body.onCeiling is a new complementary method to go with onFloor (thanks @yigitozdemir #1610)
- Text.precalculateWordWrap allows you to run your text through the Text word wrap function, which is handy if you need to handle pagination on longer pieces of text (thanks @slashman #2277)
- Sprite (and all Game Objects) have a new argument in their destroy method:
destroyTexture
. This boolean (which is false by default) controls if the BaseTexture of the Game Object should be destroyed or not. This is extremely useful in situations where you've got a lot of dynamic assets you no longer need, such as textures created from BitmapDatas. You must set thedestroyTexture
argument yourself. This can be done in a custom Game Object destroy method or as part of your state shutdown (#2261) - The Health Game Object component has a new method:
setHealth
which allows you to set the exact health amount. This is now used by therevive
function. - Text.useAdvancedWrap allows you to swap between the Basic and the Advanced word wrapping functions. In Advanced it will wrap long-words and condense and trim excess white space (thanks @soldoutactivist #1811)
- The Grunt script has been updated to enhance the intro / outro and Pixi defaults. Pixi has been split into intro / outro and main blocks, so you can exclude its intro cleanly. The excludes are now bound, so if you exclude the Phaser UMD it will do the same for Pixi as well (thanks @spayton #2192)
- ArcadePhysics.worldAngleToPointer will get the angle (in radians) between a display object and the pointer, taking all parent rotations into account (thanks @mattrick16 #2171)
- There is new documentation on building Phaser for Webpack and a new custom build grunt option (thanks @deiga #2331)
- Device.safariVersion now holds the major version of the Safari browser.
- Device.edge is a boolean that is set if running under the Microsoft Edge browser.
- Device.dolby is a boolean that is set if the browser can play EC-3 Dolby Digital Plus files
- The Loader and SoundManager can now play Dolby Digital Plus files on supported devices.
Updates
- TypeScript definitions fixes and updates (thanks @clark-stevenson @zimpy @iamfreee @milkey-mouse @juanmirod @danzel @staff0rd @sanchopancho13)
- Docs typo fixes (thanks @zeterain @staff0rd @milkey-mouse @dick-clark @nlotz @s4wny @jonjanisch @Alaxe @cdelstad @tsphillips @rblopes @vrecluse)
- Emitter methods
at
,explode
,flow
,kill
,revive
,setAlpha
,setRotation
,setScale
,setSize
,setXSpeed
,setYSpeed
andstart
now return the Emitter instance for better method chaining (thanks @samme #2308) - Tilemap.hasTile will now return
false
if the Tile doesn't exist in the coordinates given (which can happen if the coordinates are out of bounds) (thanks @cy-ryo-fujiwara #2304) - Update FrameData to check if both the numeric index was set and exists. Should fix Phaser Tiled integration as a result (thanks @Weedshaker #2298)
- Loader.loadUpdate now gets one final call when the loading is complete (before it would end and then call loadComplete, but if you had a callback bound to loadUpdate you'd never get that final 100% load event). (thanks @nexiuhm @McFarts #2297 #2296)
- The TypeScript definitions now have Phaser exported as a module in the header. This allows you to import / require the Phaser TypeScript defs (thanks @PixelWaffles #2255)
- BitmapData.setHSL now accepts 0 as a valid parameter (thanks @FracturedShader #2209)
- Force the usage of typescript 1.4.1 in the package.json so that the TypeScript defs with comments is rebuilt properly again (thanks @vulvulune #2198)
- A tiny logic update in the StateManager (thanks @jaminscript #2151)
- The Style object passed in to Phaser.Text is now cloned instead of referenced. This means you can adjust single Text instances without invaliding other Text objects using the same style object (thanks @asyncanup #2267)
- Added a typescript section to the bower and npm configs to support
tsd link
(thanks @mjohnsonengr #2189 #2180) - SoundManager.destroy now calls AudioContext.close (thanks @stoneman1 #2237)
- Sound.onEndedHandler now sets Sound.currentTime to be Sound.durationMS (thanks @stoneman1 #2237)
- BitmapData would always create a private
_swapCanvas
which was a clone of its main canvas used for advanced movement operations. This no longer happens. The swap canvas is created only as needed, by those functions that use it (specificallymoveH
andmoveV
), meaning a BitmapData will now use half the amount of memory it used to, and you'll have half the amount of canvas DOM elements created (unless you make heavy use of the move functions). - Tweens with 'yoyo' set on them couldn't be re-used again because the start and end properties were left in a reversed state. When a yoyo tween ends it now restores the reversed values (thanks @SBCGames #2307)
- The width and height values passed to the Game constructor are now passed through Math.floor first. This ensures you can never create a game width non-integer dimensions, which has all kinds of implications - from browser performance to breaking things like TileSprite rendering (#2262)
- Tilemap.getObjectIndex has been removed as it didn't work correctly in most cases, and it's easier to just scan the Tilemap.objects object directly anyway (#2242)
- GameObject.revive will now set the health amount to 100 instead of 1, bringing it in-line with the
maxHealth
default value. - Moved the Sound.disconnect after the Sound.stop call in Web Audio (#2280)
- BitmapData.drawGroup can now handle drawing Emitters and BitmapText objects that are part of the Group.
- SoundManager.setTouchLock is no longer set if
SoundManager.noAudio
is true, or if the PhaserGlobal settingdisableAudio
is true (thanks @bcjordan #2206) - Loader.audiosprite is renamed to Loader.audioSprite (the old one still works for legacy reasons) (thanks @epaezrubio #2145)
- EarCut now replaces PolyK, which fixes advanced Graphics mask triangulation issues such as #1941
- Camera.checkBounds now takes the scale of the Camera into account (thanks @ForGorNorPor #2263)
- InputHandler.consumePointerEvent has been removed, as it was never used internally anyway, so was misleading (thanks @GregoryAveryWeir #2227)
- Events.onDragUpdate has a new 6th property
fromStart
which is a boolean. You can determine if the event was the result of the start of a drag movement or not by polling it (#2155) - SinglePad.onDownCallback has been moved to the end of the method, so that DeviceButton.start is now called before the callback fires, meaning if you check the status of the button in the onDownCallback it will now be fully activated (thanks @suicidepills #2159)
- The
z
property assigned to children of a Group now starts from zero instead of 1, this is an internal change mostly but if you relied on thez
property for some reason then please be aware of this (thanks pantoninho)
Bug Fixes
- Buttons (or any Sprites) that don't have a texture, but have children, would incorrectly render the children under WebGL due to the baseTexture.skipRender property (thanks @puzzud #2141)
- TilemapParser accidentally redeclared
i
when parsing the ImageCollections which would cause an infinite loop (thanks DanHett) - BitmapData.update causes a snowballing memory leak under WebGL due to a Context.getImageData call. BitmapData.clear used to call update automatically but no longer does. This resolves the issue of the Debug class causing excessive memory build-up in Chrome. Firefox and IE were unaffected (thanks @kingjerod #2208)
- Pausing a Sound that used a Marker for playback would fire the
onMarkerComplete
signal by mistake as well as stop the fadeTween. This Signal is now only dispatched if Sound.stop is called and the Sound isn't paused (thanks Corin) - BitmapText.text would throw an undefined Texture error if you used a character in your text string that didn't exist in the font data.
- Animation.stop will now stop the named animation only if the
name
argument is passed and matches the currently running animation (thanks @samme #2299 #2301) - TilemapParser accidentally redeclared
i
when parsing Tilemap Layers (thanks @ttencate and @aweber1 #2244 #2233 #2281) - Added
removeAll
to TweenManagers stub, so the call from the StageManager doesn't throw an error in a custom build (thanks @Retrocad...
Sienda
New Features
- You can use the new const
Phaser.PENDING_ATLAS
as the texture key for any sprite. Doing this then sets the key to be theframe
argument (the frame is set to zero). This allows you to create sprites usingload.image
during development, and then change them to use a Texture Atlas later in development by simply searching your code for 'PENDING_ATLAS' and swapping it to be the key of the atlas data. - BitmapText.cleanText is a new method that will scan the given text and either remove or replace all characters that are not present in the font data.
- ArcadePhysics.Body.onCeiling is a new complementary method to go with onFloor (thanks @yigitozdemir #1610)
- Text.precalculateWordWrap allows you to run your text through the Text word wrap function, which is handy if you need to handle pagination on longer pieces of text (thanks @slashman #2277)
- Sprite (and all Game Objects) have a new argument in their destroy method:
destroyTexture
. This boolean (which is false by default) controls if the BaseTexture of the Game Object should be destroyed or not. This is extremely useful in situations where you've got a lot of dynamic assets you no longer need, such as textures created from BitmapDatas. You must set thedestroyTexture
argument yourself. This can be done in a custom Game Object destroy method or as part of your state shutdown (#2261) - The Health Game Object component has a new method:
setHealth
which allows you to set the exact health amount. This is now used by therevive
function. - Text.useAdvancedWrap allows you to swap between the Basic and the Advanced word wrapping functions. In Advanced it will wrap long-words and condense and trim excess white space (thanks @soldoutactivist #1811)
- The Grunt script has been updated to enhance the intro / outro and Pixi defaults. Pixi has been split into intro / outro and main blocks, so you can exclude its intro cleanly. The excludes are now bound, so if you exclude the Phaser UMD it will do the same for Pixi as well (thanks @spayton #2192)
- ArcadePhysics.worldAngleToPointer will get the angle (in radians) between a display object and the pointer, taking all parent rotations into account (thanks @mattrick16 #2171)
- There is new documentation on building Phaser for Webpack and a new custom build grunt option (thanks @deiga #2331)
- Device.safariVersion now holds the major version of the Safari browser.
- Device.edge is a boolean that is set if running under the Microsoft Edge browser.
- Device.dolby is a boolean that is set if the browser can play EC-3 Dolby Digital Plus files
- The Loader and SoundManager can now play Dolby Digital Plus files on supported devices.
Updates
- TypeScript definitions fixes and updates (thanks @clark-stevenson @zimpy @iamfreee @milkey-mouse @juanmirod @danzel @staff0rd @sanchopancho13)
- Docs typo fixes (thanks @zeterain @staff0rd @milkey-mouse @dick-clark @nlotz @s4wny @jonjanisch @Alaxe @cdelstad @tsphillips @rblopes @vrecluse)
- Emitter methods
at
,explode
,flow
,kill
,revive
,setAlpha
,setRotation
,setScale
,setSize
,setXSpeed
,setYSpeed
andstart
now return the Emitter instance for better method chaining (thanks @samme #2308) - Tilemap.hasTile will now return
false
if the Tile doesn't exist in the coordinates given (which can happen if the coordinates are out of bounds) (thanks @cy-ryo-fujiwara #2304) - Update FrameData to check if both the numeric index was set and exists. Should fix Phaser Tiled integration as a result (thanks @Weedshaker #2298)
- Loader.loadUpdate now gets one final call when the loading is complete (before it would end and then call loadComplete, but if you had a callback bound to loadUpdate you'd never get that final 100% load event). (thanks @nexiuhm @McFarts #2297 #2296)
- The TypeScript definitions now have Phaser exported as a module in the header. This allows you to import / require the Phaser TypeScript defs (thanks @PixelWaffles #2255)
- BitmapData.setHSL now accepts 0 as a valid parameter (thanks @FracturedShader #2209)
- Force the usage of typescript 1.4.1 in the package.json so that the TypeScript defs with comments is rebuilt properly again (thanks @vulvulune #2198)
- A tiny logic update in the StateManager (thanks @jaminscript #2151)
- The Style object passed in to Phaser.Text is now cloned instead of referenced. This means you can adjust single Text instances without invaliding other Text objects using the same style object (thanks @asyncanup #2267)
- Added a typescript section to the bower and npm configs to support
tsd link
(thanks @mjohnsonengr #2189 #2180) - SoundManager.destroy now calls AudioContext.close (thanks @stoneman1 #2237)
- Sound.onEndedHandler now sets Sound.currentTime to be Sound.durationMS (thanks @stoneman1 #2237)
- BitmapData would always create a private
_swapCanvas
which was a clone of its main canvas used for advanced movement operations. This no longer happens. The swap canvas is created only as needed, by those functions that use it (specificallymoveH
andmoveV
), meaning a BitmapData will now use half the amount of memory it used to, and you'll have half the amount of canvas DOM elements created (unless you make heavy use of the move functions). - Tweens with 'yoyo' set on them couldn't be re-used again because the start and end properties were left in a reversed state. When a yoyo tween ends it now restores the reversed values (thanks @SBCGames #2307)
- The width and height values passed to the Game constructor are now passed through Math.floor first. This ensures you can never create a game width non-integer dimensions, which has all kinds of implications - from browser performance to breaking things like TileSprite rendering (#2262)
- Tilemap.getObjectIndex has been removed as it didn't work correctly in most cases, and it's easier to just scan the Tilemap.objects object directly anyway (#2242)
- GameObject.revive will now set the health amount to 100 instead of 1, bringing it in-line with the
maxHealth
default value. - Moved the Sound.disconnect after the Sound.stop call in Web Audio (#2280)
- BitmapData.drawGroup can now handle drawing Emitters and BitmapText objects that are part of the Group.
- SoundManager.setTouchLock is no longer set if
SoundManager.noAudio
is true, or if the PhaserGlobal settingdisableAudio
is true (thanks @bcjordan #2206) - Loader.audiosprite is renamed to Loader.audioSprite (the old one still works for legacy reasons) (thanks @epaezrubio #2145)
- EarCut now replaces PolyK, which fixes advanced Graphics mask triangulation issues such as #1941
- Camera.checkBounds now takes the scale of the Camera into account (thanks @ForGorNorPor #2263)
- InputHandler.consumePointerEvent has been removed, as it was never used internally anyway, so was misleading (thanks @GregoryAveryWeir #2227)
- Events.onDragUpdate has a new 6th property
fromStart
which is a boolean. You can determine if the event was the result of the start of a drag movement or not by polling it (#2155) - SinglePad.onDownCallback has been moved to the end of the method, so that DeviceButton.start is now called before the callback fires, meaning if you check the status of the button in the onDownCallback it will now be fully activated (thanks @suicidepills #2159)
- The
z
property assigned to children of a Group now starts from zero instead of 1, this is an internal change mostly but if you relied on thez
property for some reason then please be aware of this (thanks pantoninho)
Bug Fixes
- Buttons (or any Sprites) that don't have a texture, but have children, would incorrectly render the children under WebGL due to the baseTexture.skipRender property (thanks @puzzud #2141)
- TilemapParser accidentally redeclared
i
when parsing the ImageCollections which would cause an infinite loop (thanks DanHett) - BitmapData.update causes a snowballing memory leak under WebGL due to a Context.getImageData call. BitmapData.clear used to call update automatically but no longer does. This resolves the issue of the Debug class causing excessive memory build-up in Chrome. Firefox and IE were unaffected (thanks @kingjerod #2208)
- Pausing a Sound that used a Marker for playback would fire the
onMarkerComplete
signal by mistake as well as stop the fadeTween. This Signal is now only dispatched if Sound.stop is called and the Sound isn't paused (thanks Corin) - BitmapText.text would throw an undefined Texture error if you used a character in your text string that didn't exist in the font data.
- Animation.stop will now stop the named animation only if the
name
argument is passed and matches the currently running animation (thanks @samme #2299 #2301) - TilemapParser accidentally redeclared
i
when parsing Tilemap Layers (thanks @ttencate and @aweber1 #2244 #2233 #2281) - Added
removeAll
to TweenManagers stub, so the call from the StageManager doesn't throw an error in a custom build (thanks @RetrocadeNet #2284) - Loader.binary would return a success even if the xhr'd file returned a 404 or similar (thanks @milkey-mouse @mhstar89 #2251 #2250)
- When loading audio or video from blob or data URIs, the local variable was replaced too soon, throwing errors in
getAudioURL
andgetVideoURL
(thanks @milkey-mouse @jackfreak #2236 #2234) - Tween.hasStarted parameter was set to
false
when the tween was created, but not set again when the tween was stopped or ends. IfTween.start
is used more than once theonStart
callback is called only the first time (thanks @javivi91 #2199) - During a WebGL context loss the Phaser Cache was referencing the wrong local object (thanks @allenevans #2285)
- The Video game object used an anonymous bound function for both the 'ended' and 'playing' event listeners, meaning that they were never removed properly (thanks @ramalhovfc #2303)
- BitmapData.shiftHSL incorrectly used Math.limitValue, now updated to use Math.clamp (thanks @FracturedShader #2222)
- The Loader was deleting the next...