Releases: phaserjs/phaser
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...
Amador
New Features
- Emitter.emitParticle now has 4 new optional arguments:
x
,y
,key
andframe
. These allow you to override whatever the Emitter default values may be and emit the particle from the given coordinates and with a new texture. - Group.resetChild is a new method that allows you to call both
child.reset
and/orchild.loadTexture
on the given child object. This is used internally bygetFirstDead
and similar, but is made public so you can use it as a group iteration callback. Note that the child must have publicreset
andloadTexture
methods to be valid for the call. - Group.getFirstDead, Group.getFirstAlive and Group.getFirstExists all have new optional arguments:
createIfNull
,x
,y
,key
andframe
. If the method you call cannot find a matching child (i.e. getFirstDead cannot find any dead children) then the optionalcreateIfNull
allows you to instantly create a new child in the group using the position and texture arguments to do so. This allows you to always get a child back from the Group and remove the need to do null checks and Group inserts from your game code. The same arguments can also be used in a different way: ifcreateIfNull
is false AND you provide the extra arguments AND a child is found then it will be passed to the newGroup.resetChild
method. This allows you to retrieve a child from the Group and have it reset and instantly ready for use in your game without any extra code. - P2.Body.removeCollisionGroup allows you to remove the given CollisionGroup, or array of CollisionGroups, from the list of groups that a body will collide with and updates the collision masks (thanks @Garbanas #2047)
- Filter.addToWorld allows you to quickly create a Phaser.Image object at the given position and size, with the Filter ready applied to it. This can eliminate lots of duplicate code.
- Tiled 0.13.0 added support for layer data compression when exporting as JSON. This means that any .tmx stored using base64 encoding will start exporting layer data as a base64 encoded string rather than a native array. This update adds in automatic support for this as long as the data isn't compressed. For IE9 support you'll need to use the new polyfill found in the resources folder (thanks @noidexe #2084)
- You can now load single layer Pyxel Edit TileMaps as an atlas (thanks @joshpmcghee #2050)
- Canvas.getSmoothingPrefix will return the vendor prefixed smoothing enabled value from the context if set, otherwise null.
- The Random Number Generator can now get and set its state via rnd.state. This allows you to do things like saving the state of the generator to a string that can be part of a save-game file and load it back in again (thanks @luckylooke #2056 #1900)
- Device.iOSVersion now contains the major version number of iOS.
- The new
PointerMode
enumeration value has been added for better simple input discrimination in the future, between active pointers such as touch screens and passive pointers, such as mouse cursors (thanks @pnstickne #2062) - Button.justReleasedPreventsOver controls if a just-release event
on a pointer prevents it from being able to trigger an over event. - Button.forceOut expanded to accept a PointerMode value such that it
can be controlled per-input mode. - Phaser.KeyCode is a new pseudo-type used by the Keyboard class (and your code) to allow for separation of all the Keyboard constants to their own file. This stops the JSDocs from becoming 'polluted' and allows for easier future expansion (thanks @pnstickne #2118 #2031)
Updates
- TypeScript definitions fixes and updates (thanks @clark-stevenson @milkey-mouse @timotei @qdrj @Garbanas @cloakedninjas)
- Docs typo fixes (thanks @rwrountree @yeluoqiuzhi @pnstickne @fonsecas72 @JackMorganNZ @caryanne)
- Math.average has been optimized (thanks @rwrountree #2025)
- When calling GameObject.revive the
heal
method is called to apply the health value, allowing it to take into consideration amaxHealth
value if set (thanks @bsparks #2027) - Change splice.call(arguments, ..) to use slice instead (thanks @pnstickne #2034 #2032)
- BitmapData.move, moveH and moveV have a new optional
wrap
argument allowing you to control if the contents of the BitmapData are wrapped around the edges (true) or simply scrolled off (false). - Time.desiredFps has moved to a getter / setter.
- Time.physicsElapsed and Time.physicsElapsedMS are no longer calculated every frame, but only when the desiredFps is changed.
- Time.update has been streamlined and the
updateSetTimeout
andupdateRAF
methods merged and duplicate code removed. - Time.desiredFpsMult is a pre-calculated multiplier used in Game.update.
- Time.refresh updates the
Time.time
andTime.elapsedMS
values and is called automatically by Game.update. - DeviceButton was setting a
duration
property on itself, which went against the read only getter of duration (thanks @winstonwolff) - Added Node.js v4 stable to Travis config (thanks @phillipalexander #2070)
- Optimised Canvas.getSmoothingEnabled, Canvas.setSmoothingEnabled and Canvas.setImageRenderingCrisp.
- The Physics Editor Exporter (found in the resources folder of the repo) has had an option to prefix shape names and optimize JSON output added to it (thanks @Garbanas #2093)
- Touch.addTouchLockCallback has a new argument
onEnd
which allows the callback to fire either on a touchstart or a touchend event. - The SoundManager now detects if the browser is running under iOS9 and uses a touchend callback to unlock the audio subsystem. Previous versions of iOS (and Android) still use touchstart. This fixes Apple's screw-up with regard to changing the way Web Audio should be triggered in Mobile Safari. Thanks Apple (thanks @MyCatCarlos for the heads-up #2095)
- InputHandler.validForInput now checks if the game object has
input.enabled
set tofalse
and doesn't validate it for input if that's the case. - The default Button.onOverMouseOnly value has changed from
false
totrue
. If you used this in your touch enabled games then please be aware of this change (#2083) - BitmapData.clear now automatically calls BitmapData.update at the end of it.
- New Color stub added for the custom build process. Contains just the bare minimum of functions that Phaser needs to work. Cuts file size from 48.7KB to 7.4KB. Note: Do not stub this out if using BitmapData objects.
- New DOM stub added for the custom build process. Contains just the bare minimum of functions that Phaser needs to work. Cuts file size from 14.8KB to 2.4KB. Note: Do not stub this out if using the full Scale Manager.
- New Scale Manager stub added. Removes all Scale Manager handling from Phaser! But saves 75KB in the process. If you know you don't need to scale the Phaser canvas, or are handling that externally, then you can safely stub it out in a custom build.
- Added the PIXI.PolyK, PIXI.WebGLGraphics and PIXI.CanvasGraphics files to the Graphics custom build option. They weren't used anyway and this removes an extra 40.2KB from the build size.
- Phaser.Create no longer automatically creates a BitmapData object when it starts. It now only does it when you first make a texture or grid.
- New Create stub added for the custom build process. Cuts file size by 8KB.
- You can now exclude the FlexGrid from custom builds, saving 15KB.
- The ScaleManager no longer creates a Phaser.FlexGrid if the class isn't available (i.e. excluded via a custom build)
- Time.suggestedFps is now defaulted to
Time.desiredFps
for the first few frames until things have settled down (previously it wasnull
) (thanks @noidexe #2130) - Text with anchor 0.5 and word wrap would have an extra space added to its width calculations, this is now adjusted for (thanks @nickryall #2052 #1990)
- ScaleManager.getParentBounds now checks if
parentNode
has anoffsetParent
before callinggetBoundingClientRect
on it (thanks @McFarts #2134)
Bug Fixes
- Loader.bitmapFont wouldn't automatically set the
atlasURL
value if just the key was given. - The Loader would put the baseURL and/or path in front of
data:
andblob
URLs (thanks @rblopes #2044) - When the Text width was being calculated it would add the
strokeThickness
value twice, causing an alignment offset (thanks @nickryall #2039) - Sound.onEndedHandler has a fix for AudioBufferSourceNode listener memory leak (thanks @Pappa #2069)
- Game.update could call
updateLogic
multiple times in a single frame when catching up with slow device frame rates. This would cause Tweens to advance at twice the speed they should have done (thanks @mkristo) - Added useCapture flags to removeEventListener in MSPointer class (thanks @pmcmonagle #2055)
- Under setTimeOut (or when
forceSetTimeOut
was true) the Time was incorrectly settingTime.timeExpected
causing game updates to lag (thanks @satan6 #2087) - Fixes edge case when TilingSprite is removed before render (thanks @pnstickne #2097 #2092)
- Camera.setBoundsToWorld only adjusts the bounds if it exists (thanks @prudolfs #2099)
- Keyboard.addCallbacks didn't check to see if the arguments were
null
, only if they wereundefined
making the jsdocs misleading. - ScaleManager.getParentBounds now takes any transforms into account to get the correct parent bounds (thanks @jdnichollsc #2111 #2098)
- Cache.addBitmapFont now applies a default value for the x and y spacing if the arguments are omitted (thanks @nlotz #2128)
- Removed use of the
tilePosition
property in the Phaser.Rope class as it isn't implemented and caused calls toRope.reset
to crash (thanks @spayton #2135) - ScaleMin and ScaleMax stopped working in Phaser 2.3.0 due to an incorrect transform callback scope (thanks @brianbunch #2132)
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.
- CanvasRenderer.mapBlendModes optimised to cut down on file size.
- PIXI.WebGLRenderer.updateTexture now returns a boo...
Coramen
New Features
- Loader.images is a new method that allows you to pass an array of image keys, and optionally the URLs to the Loader and have them all added to the load queue in one go.
- TweenManager.frameBased allows you to control if all newly created Tweens update based on the physics step (i.e. frame based) or the system clock (time based). A frame based tween will use the physics elapsed timer when updating. This means it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should be given in frames. If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween has actually been through.
- Tween.frameBased does the same as TweenManager.frameBased but allows you to set the value on a per-tween basis.
- BitmapText.smoothed is a new boolean property that allows you to set texture smoothing on a bitmap font or not. By default smoothing is always on, but you can turn it off which helps for bitmap fonts created from pixel art style character sets.
- Text.addFontStyle and Text.addFontWeight allow you to apply font weights and styles to specific characters in a Text object. For example you can now include bold or italics within single Text objects (thanks @jdnichollsc #1950)
- PIXI.CanvasPool is a new static global created to deal with the issue of resource leaks and continuous DOM node build-up when creating lots of Text or BitmapData objects, or when calling
generateTexture
on any display object. The CanvasPool will do its best to re-use out dated canvas elements rather than filling up the DOM with new ones. - Sprite.setTexture has a new
destroyBase
parameter - set this totrue
if you know the base used a generated texture that isn't being used by any other sprites. This will free-up the canvas for further re-use by other calls togenerateTexture
or Text objects. - Line.midPoint will return a Point object where the
x
andy
values correspond to the center (or midpoint) of the Line segment. - Line.rotateAround allows you to rotate a Line around the given coordinates (in world space)
- Line.centerOn will position the Line so that its midpoint lays on the coordinates given.
- BitmapData.line draws a line to the BitmapData in the color and thickness specified.
- BitmapData.op is a handy short-code to get and set the canvas global composite operator.
- BitmapData.drawFull draws the given Game Object or Group to a BitmapData and then recursively iterates through all of its children, including children of Game Objects and Groups. It can draw Text, BitmapText, Sprites, Images, Emitters and Graphics objects. It's perfectly valid to pass in
game.world
as the parent object, and it will iterate through the entire display list. - Phaser.TilemapParser.INSERT_NULL is a new boolean that controls what happens when the parser encounters an empty tile: When scanning the Tiled map data the TilemapParser can either insert a null value (true) or a
Phaser.Tile
instance with an index of -1 (false, the default). Depending on your game type depends how this should be configured. If you've a large sparsely populated map and the tile data doesn't need to change then setting this value totrue
will help with memory consumption. However if your map is small, or you need to update the tiles (perhaps the map dynamically changes during the game) then leave the default value set (thanks #1982)
Updates
- TypeScript definitions fixes and updates (thanks @clark-stevenson @vrecluse @yahiko00 @cloakedninjas @qdrj)
- JSDoc typo fixes (thanks @Cowa @yahiko00 @qdrj @stuff)
- VideoStream.active = false is used if the browser supports it, otherwise it falls back to VideoStream.stop.
- Text can now accept
undefined
ornull
as thetext
argument in the constructor and will cast it as an empty string. - Point.rotate uses a faster and simpler rotation function when no distance argument is specified.
- Setting a P2.Body from Static or Kinematic to Dynamic will now automatically adjust the Body.mass to be 1 (thanks @wayfu #2005)
- Pointer.withinGame is no longer automatically set to
false
in thePointer.stop
method. Instead it will check if the Pointer actually is within the stage bounds and only setwithinGame
tofalse
if it's outside the bounds. - MSPointer now has an
onPointerUpGlobal
handler for when the pointer is released outside of the canvas, but still within the browser window. This means that in IE11 a SpritesonInputUp
event will now trigger even when outside the canvas (thanks @bvargish #2000) - MSPointer now has handlers for the pointer being over and outside of the canvas element, which sets the
Pointer.withinGame
booleans accordingly. It also triggers theMouse.mouseOutCallback
andMouse.mouseOverCallback
callbacks respectively. - The MSPointer event listeners have been renamed to all lower-case, i.e. 'pointerDown' is now 'pointerdown'.
Bug Fixes
- Pointer.isDown was reset before the
Input.onUp
event, meaning you couldn't get the Pointer duration from within the event. - Pointer.isDown was reset before the Input tap calculations, meaning
onTap
wouldn't dispatch (thanks @stovenator #1953) - InputHandler.pointerOver would get stuck in an 'isOver' state if the Sprite changed its visibility during an
onUp
callback (thanks @Cristy94 #1955) - If you override the P2 mpx functions, to define your own px to meters values, the P2 Debug Bodies would ignore it (thanks @vrecluse #1957)
- ArrayUtils.numberArrayStep would return an empty array if a single parameter was given, instead of a single step array (thanks @pooya72 #1958)
- Text with tints applied wouldn't update properly in Canvas mode.
- Removed use of the deprecated
enterFullScreen
andleaveFullScreen
signals from the Scale Manager (thanks @mmanlod #1972) - BitmapText with tints applied wouldn't update properly in Canvas mode (thanks @Pajamaman #1969)
- Group.cacheAsBitmap would be incorrectly offset in Canvas mode (thanks @mkristo #1925)
- Text.setTextBounds didn't add the x and y values to the width and height offsets.
- Line.rotate used a calculation method which resulted in the line growing (or shrinking) in length over time the more it was rotated. The new method never changes the lines length.
- BitmapText.font failed to pull the new font from the Phaser Cache, stopping it from updating properly (thanks @AbrahamAlcaina #2001)
- Video.stop now removes the 'playing' event listener, which stop Videos set to loop from throwing errors after being destroyed.
- Tilemap.createFromObjects has been strengthened so that will only create Sprites for matching gids/ids/names. It also only sets the Sprite width and height values if they are present in the Tiled data (thanks @pparke #2012)
- TilingSprite._renderCanvas wasn't correctly allowing for pixel rounding (thanks @ximop #2022)
- Cache.addSpriteSheet didn't include default values for the
frameMax
,margin
andspacing
arguments (thanks @vladkens #2017 #2018) - Tilemap.shuffle was calling the deprecated Phaser.Utils.shuffle, which has now moved to Phaser.ArrayUtils.shuffle.
- Enabling a filter on a display object that had a multiply blend mode set would cause the object to become invisible. The two cannot be combined, so when you set a filter on a display object it now automatically resets the blend mode to
NORMAL
. The same does not happen in reverse however, so if you've got a filter set and then change the blend mode to multiply it will still break. Be careful to capture this yourself (thanks @wayfu #1994)
Altara
Updates
- TypeScript definitions fixes and updates (thanks @clark-stevenson @shivinsky)
- JSDoc typo fixes (thanks @DrkSephy)
- TilemapLayer - Fixed unmatched
context.save
andcontext.restore
calls (thanks @MortimerGoro #1934) - Cache.getFrame has a new
cache
parameter (that defaults to the Image cache, but can be changed to any other) - Cache.getFrameCount has a new
cache
parameter (that defaults to the Image cache, but can be changed to any other) - Cache.getFrameData has a new
cache
parameter (that defaults to the Image cache, but can be changed to any other) - Cache.hasFrameData has a new
cache
parameter (that defaults to the Image cache, but can be changed to any other) - Cache.getFrameByIndex has a new
cache
parameter (that defaults to the Image cache, but can be changed to any other) - Cache.getFrameByName has a new
cache
parameter (that defaults to the Image cache, but can be changed to any other) - Device.canPlayVideo now checks for
ogv
as a valid file extension for OGG video files (thanks @JB-Tellez #1928) - Phaser.Sound will now automatically check the Cache to see if the audio file it is using is still there or not. If not then it will automatically called
Sound.destroy
on itself. If you do not desire this result then you should ensure that you undertake all house-keeping yourself, and properly destroy Sound objects before callingCache.removeSound
(#1946)
Bug Fixes
- DeviceButton would try to set
altKey
,shiftKey
andctrlKey
even for Joypads (thanks @zatch #1939) - Pointer.move would accidentally reset the
isDown
status of the Pointer on touch devices, which broke things like Sprite input events when built to native apps or run locally (#1932 #1943) - Pointer.onDown (and input enabled items like Buttons) would fail on FireFox / Linux and CocoonJS (#1944 #1945)
Ionin Spring
This is a small point release that updates the Creature runtimes and fixes a couple of small cache issues.
It also modifies the Grunt build scripts so that all third party libs (such as Creature, P2, gl-matrix and PIXI) are now kept well and truly outside of Phaser. They are defined and placed first in the build files. So no more PIXI hiding within the Phaser namespace or UMD patching for Phaser required.
Updates
- The Creature Runtimes have been updated to the latest versions and the
Phaser.Creature
class updated to use them. - GameObjectFactory.creature is a new method to help with quick Creature animation object creation.
- Cache.getPixiTexture will now search the image cache if it couldn't find a texture in the PIXI.TextureCache global array, if it finds a matching image in the image cache then it returns a new PIXI.Texture based on it.
- Cache.getPixiBaseTexture will now search the image cache if it couldn't find a BaseTexture in the PIXI.BaseTextureCache global array.
Bug Fixes
- Fixed Cache.getKeys to use the
_cacheMap
(thanks @jamesgroat #1929) - Safari on OSX wouldn't recognise button presses on trackpads (thanks JakeCake)
- Cache.removeImage now calls destroy on the image BaseTexture, removing it from the PIXI global caches without throwing a warning.
Katar
Note: Revision a
of Phaser 2.4.0 includes a fix to the build files that stopped some PIXI classes being undefined (such as TilingSprite). Nothing in the framework itself changed.
API Changes
- RenderTexture.render now takes a Matrix as its second parameter, not a Point object. This brings it in line with Pixi and allows you to perform much more complex transformations on the object being rendered. If you need to replicate the old behavior please use RenderTexture.renderXY(sprite, point.x, point.y) instead.
- PIXI.DisplayObject.updateTransform has a new optional parameter
parent
. If the DisplayObject doesn't have a parent (i.e. it isn't on the display list yet) then in the pastupdateTransform
would fail. This meant you couldn't do things like scale or rotate a Sprite and then draw it to a RenderTexture or BitmapData, as calls to updateTransform would be ignored. The new checks now look to see if theparent
parameter is set. If so this takes priority over the actual parent and is used to modify the transform (note that it doesn't reparent the DisplayObject, it merely uses it for the transform.) If there is no parent (explicitly or via the parameter) then it falls back to use Phaser.World as the parent. If it can't reach that then no transform takes place. - If Phaser.Sound.noAudio has been set then Phaser.Loader will not load any audio files. No errors are thrown, but all calls to Loader.audio and Loader.audiosprite are silently ignored.
noAudio
can be set either via thePhaserGlobal
global var or is set if the device your game is running on has no audio playback support. - Files can now be added to the Loader with an absolute URL even if you have a Loader.baseURL set. In previous versions the baseURL would still be prepended to the file URL, but the Loader now checks if the a file URL begins with
http
or//
and skips prepending the baseURL to it. - Phaser.StateManager would incorrectly call
loadUpdate
andloadRender
while the game was paused or if the State didn't have anupdate
orrender
method defined, even after the loader was completed. Although this is a bug fix it's still an API change should you have been using theloadUpdate/Render
calls in the old way. Also the StateManager no longer callspreRender
unless the Statecreate
method has finished. If the State doesn't have acreate
method thenpreRender
runs immediately. - Frame.uuid has been removed (was flagged as deprecated for several releases). This has a two-fold effect: First it means that the property no longer exists and secondly it means that the AnimationParser (the class responsible for loading sprite sheets and texture atlases) no longer has to call either RandomDataGenerator.uuid OR populates the PIXI.TextureCache. The first saves some CPU time and the second saves memory by not creating references to textures it doesn't ever use. The PIXI.TextureCache is now ignored by Phaser other than for the
__missing
and__default
textures. - Phaser.AnimationParser methods
JSONData
,JSONDataHash
andXMLData
have all had theircacheKey
parameter removed as it's no longer used. - Input.deleteMoveCallback no longer takes an integer as its parameter. Now you have to give it the original callback and context in order to remove it. This is to protect against index invalidation (see the fixed Bugs list)
- Group.add and Group.addAt will only create a Physics Body on the child if it doesn't already have one. This is a change from 2.3 where it would replace the physics body property with the new body, but this could lead to garbage build-up over time, so you should now properly destroy the body before changing it.
- Button game objects now have
Input.useHandCursor
set totrue
by default. - Phaser.BitmapText no longer extends PIXI.BitmapText but replaces it entirely.
- Phaser.Text no longer extends PIXI.Text but replaces it entirely. Phaser.Text now natively extends a Phaser Sprite, meaning it can be enabled for physics, damaged, etc.
- Mouse.button and MSPointer.button have been deprecated and are no longer set (they remain at -1). They never supported complex button events such as holding down 2 buttons and releasing just one, or any buttons other than left and right. They have been replaced with the far more robust and accurate Pointer DeviceButton properties such as
Pointer.leftButton
,Pointer.rightButton
and so on. - Phaser.DeviceButton is a new class that handles a specific button on an input device, for example the middle button of a mouse, the eraser button of a stylus or a shoulder button on a Gamepad.
- Phaser.DeviceButton.shiftKey is a boolean that holds if the shift key was held down or not during the last button event.
- Phaser.DeviceButton.altKey is a boolean that holds if the alt key was held down or not during the last button event.
- Phaser.DeviceButton.ctrlKey is a boolean that holds if the control key was held down or not during the last button event.
- Phaser.GamepadButton has been removed and now uses DeviceButton instead. Three internal API changes took place:
processButtonDown
is renamed tostart
,processButtonUp
is renamed tostop
andprocessButtonFloat
is renamed topadFloat
. If you extended GamepadButton in your own code you need to replace it with DeviceButton. - MSPointer now checks the
pointerType
property of the DOM event and if it matches 'mouse' it will updateInput.mousePointer
, rather thanInput.pointer1
(or whatever the next free Pointer was). - Time.suggestedFps is now only populated if
Time.advancedTiming
is enabled.
p2.js Upgraded to version 0.7.0
Phaser has been upgraded internally to use the new release of p2 physics. All Phaser based API call signatures remain unchanged unless listed below.
For the full list of p2 additions please read their change log.
- The P2.Body.onBeginContact arguments have changed. It now sends 5 arguments: The Phaser.P2.Body, the p2.Body, the p2 Shape from Body A, the p2 Shape from Body B and the contact equations array. Note that the Phaser.P2.Body may be null if you collide with a 'native' p2 body (such as the world bounds). However the p2.Body argument will always be populated.
- The P2.Body.onEndContact arguments have changed. It now sends 4 arguments: The Phaser.P2.Body, the p2.Body, the p2 Shape from Body A and the p2 Shape from Body B. Note that the Phaser.P2.Body may be null if this is the end of a contact with a 'native' p2 body (such as the world bounds). However the p2.Body argument will always be populated.
- P2.Body.applyImpulse allows you to apply an impulse to a Body. An impulse is a force added to a body during a short period of time.
- P2.Body.applyImpulseLocal allows you to apply an impulse to a point local to the Body. An impulse is a force added to a body during a short period of time.
- P2.Body.getVelocityAtPoint gets the velocity of a point in the body.
Build Updates
- The Grunt build script now lets you exclude four new modules: rope, tilesprite, creature and video.
- Rope removes the ability to create Rope sprites and also removes the PIXI.Rope and PIXI.Strip classes.
- TileSprite removes the ability to create Tile Sprites and also removes the PIXI.TilingSprite class.
- Creature is not enabled by default, but allows you to control support for Creature bone based animations.
- Video removes the ability to render Videos and video streams to textures.
- Pixi is no longer an optional module. Phaser no longer uses any main stream branch of Pixi and has multiple fixes and tweaks internally through-out it. Therefore it's now no longer possible to replace the version of Pixi that Phaser uses with any other version, so we removed the option from the custom list. Over time we will do away with the Pixi globals and merge it fully into Phaser to avoid conflicts with any other version of Pixi present.
New Features
- All calls to Loader methods that add files to the queue, such as
Loader.image
orLoader.atlas
, now have the URL as an optional parameter. If not set Loader will assume the URL to be based on the key given. For example the following:game.load.image("boom", "boom.png")
can now be expressed as justgame.load.image("boom")
, orgame.load.atlas("player", "player.png", "player.json")
can now be shortened togame.load.atlas("player")
. Please see the freshly updated jsdocs for full details. - Loader.atlas and
Cache.addTextureAtlas
will now automatically determine the format of the JSON data (array or hash) when added to the Cache. You no longer need to specify it explicitly if JSON, only if XML. - Added support for the Creature Automated Animation Tool. You can now create a Phaser.Creature object which uses json data and a texture atlas for the animations. Creature is a powerful animation tool, similar to Spriter or Spine. It is currently limited to WebGL games only, but the new libs should prove a solid starting point for anyone wanting to incorporate Creature animations into their games.
- Tilemap.getTileWorldXY has a new optional parameter:
nonNull
which if set makes it behave in the same way asgetTile
does (thanks @GGAlanSmithee #1722) - Group.hash is an array (previously available as
Group._hash
, but protected) into which you can add any of its children viaGroup.addToHash
andGroup.removeFromHash
. Only children of the Group can be added to and removed from the hash. The hash is used automatically by Arcade Physics in order to perform non z-index based destructive sorting. However if you don't use Arcade Physics, or it isn't a physics enabled Group, then you can use the hash to perform your own sorting and filtering of Group children without touching their z-index (and therefore display draw order). - Group.physicsSortDirection is a new property allowing you to set a custom sort direction for Arcade Physics Sprites within the Group hash. Previously Arcade ...
Tarabon
Significant Updates
Game Objects and Components
All of the core Game Objects have received an important internal restructuring. We have moved all of the common functions to a new set of Component classes. They cover functionality such as 'Crop', 'Physics Body', 'InCamera' and more. You can find the source code to each component in the src/gameobjects/components
folder of the repo.
All of the Game Object classes have been restructured to use the new component approach. This puts an end to the "God classes" structure we had before and removes literally hundreds of lines of duplicate code. It also allowed us to add features to Game Objects; for example Bitmap Text objects are now full-class citizens with regard to physics capabilities.
Although this was a big internal shift from an API point of view not much changed - you still access the same methods and properties in the same way as before. Phaser is just a lot leaner under the hood now.
It's worth mentioning that from a JavaScript perspective components are mixins applied to the core game objects when Phaser is instantiated. They are not added at run-time or are dynamic (they never get removed from an object once added for example). Please understand that this is by design.
You can create your own custom Phaser classes, with your own set of active components by copying any of the pre-existing Game Objects and modifying them.
Custom Builds
As a result of the shift to components we went through the entire source base and optimised everything we could. Redundant paths were removed, debug flags removed and new stub classes and hooks were created. What this means is that it's now easier than ever to "disable" parts of Phaser and build your own custom version.
We have always included a couple of extra custom builds with Phaser. For example a build without P2 Physics included. But now you can strip out lots of additional features you may not require, saving hundreds of KB from your build file in the process. Don't use any Sound in your game? Then you can now exclude the entire sound system. Don't need Keyboard support? That can be stripped out too.
As a result of this work the minimum build size of Phaser is now just 83KB (minified and gzipped).
Please see the README instructions on how to create custom builds.
Arcade Physics
We've updated the core of Arcade Physics in a number of significant ways.
First we've dropped lots of internal private vars and moved to using non-cached local vars. Array lengths are no longer cached and we've implemented physicsType
properties on Game Objects to speed-up the core World collideHandler. All of these small changes have lead to a nice improvement in speed as a result, and also allows us to now offer things like physics enabled BitmapText objects.
More importantly we're now using a spacial pre-sort for all Sprite vs. Group and Group vs. Group collisions. You can define the direction the sort will prioritize via the new sortDirection
property. By default it is set to Phaser.Physics.Arcade.LEFT_RIGHT
. For example if you are making a horizontally scrolling game, where the player starts on the left of the world and moves to the right, then this sort order will allow the physics system to quickly eliminate any objects to the right of the player bounds. This cuts down on the sheer volume of actual collision checks needing to be made. In a densely populated level it can improve the fps rate dramatically.
There are 3 other directions available (RIGHT_LEFT
, TOP_BOTTOM
and BOTTOM_TOP
) and which one you need will depend on your game type. If you were making a vertically scrolling shoot-em-up then you'd pick BOTTOM_TOP
so it sorts all objects above and can bail out quickly. There is also SORT_NONE
if you would like to pre-sort the Groups yourself or disable this feature.
Another handy feature is that you can switch the sortDirection
at run-time with no loss of performance. Just make sure you do it before running any collision checks. So if you had a large 8-way scrolling world you could set the sortDirection
to match the direction the player was moving in and adjust it in real-time, getting the benefits as you go. My thanks to Aaron Lahman for inspiring this update.
Phaser.Loader
The Phaser.Loader has been updated to support parallel downloads which is now enabled by default (you can toggle it via the Loader.enableParallel
flag) as well as adding future extensibility points with a pack/file unified filelist and an inflight queue.
There are no known incompatibilities with the previous Loader. Be aware that with parallel downloading enabled the order of the Loader events may vary (as can be seen in the "Load Events" example).
The parallel file concurrency limit is available in Loader.maxParallelDownloads
and is set to 4 by default. Under simulated slower network connections parallel loading was a good bit faster than sequential loading. Even under a direct localhost connection parallel loading was never slower, but benefited most when loading many small assets (large assets are more limited by bandwidth); both results are fairly expected.
The Loader now supports synchronization points. An asset marked as a synchronization point must be loaded (or fail to load) before any subsequent assets can be loaded. This is enabled by using the withSyncPoint
and addSyncPoint
methods. Packs ('packfile' files) and Scripts ('script' files) are treated as synchronization points by default. This allows parallel downloads in general while allowing synchronization of select resources if required (packs, and potentially other assets in the future, can load-around synchronization points if they are written to delay final 'loading').
Additional error handling / guards have been added, and the reported error message has been made more consistent. Invalid XML (when loading) no longer throws an exception but fails the particular file/asset that was being loaded.
Some public methods/properties have been marked as protected, but no (except in case of a should-have-been-private-method) public-facing interfaces have been removed. Some private methods have been renamed and/or removed.
A new XHR object is created for each relevant asset (as there must be a different XHR for each asset loaded in parallel). Online searches indicated that there was no relevant benefit of XHR (as a particular use-case) re-use; and time will be dominated with the resource fetch. With the new flight queue an XHR cache could be re-added, at the cost of some complexity.
The URL is always transformed through transformUrl, which can make adding some one-off special cases like #1355 easier to deal with.
This also incorporates the fast-cache path for Images tags that can greatly speed up the responsiveness of image loading.
Loader.resetLocked is a boolean that allows you to control what happens when the loader is reset, which happens automatically on a State change. If you set resetLocked
to true
it allows you to populate the loader queue in one State, then swap to another State without having the queue erased, and start the load going from there. After the load has completed you could then disable the lock again as needed.
Thanks to @pnstickne for vast majority of this update.
Pixi v2
We are now using our own custom build of Pixi v2. The Pixi project has moved all development resources over to Pixi v3, but it wasn't ready in time for the release of Phaser 2.3 so we've started applying our own fixes to the version of Pixi that Phaser uses.
As a result we have removed all files from the src/pixi
folder that Phaser doesn't use, in order to make this distinction clearer. This includes EventTarget
, so if you were relying on that in your game you'll need to add it back in to your local build.
We've also removed functions and properties from Pixi classes that Phaser doesn't require: such as the Interaction Manager, Stage.dirty, etc. This has helped us cut down the source code size and make the docs less confusing, as they no longer show properties for things that weren't even enabled.
We've rolled our own fixes into our version of Pixi, ensuring we keep it as bug-free as possible.
New Features
Physics.Arcade.isPaused
allows you to toggle Arcade Physics processing on and off. Iftrue
theBody.preUpdate
method will be skipped, halting all motion for all bodies. Note that other methods such ascollide
will still work, so be careful not to call them on paused bodies.Arcade.Body.friction
allows you to have more fine-grained control over the amount of velocity passed between bodies on collision.- BitmapData.text will render the given string to the BitmapData, with optional font, color and shadow settings.
- MSPointer.capture allows you to optionally event.preventDefault the pointer events (was previously always on)
- MSPointer.event now stores the most recent pointer event.
- MSPointer.pointerDownCallback, pointerMoveCallback and pointerUpCallback all allow you to set your own event based callbacks.
- MSPointer.button now records which button was pressed down (if any)
- Phaser now supports rotated and flipped tiles in tilemaps, as exported from the Tiled map editor (thanks @nkholski #1608)
- TilemapParser now supports Tiled 0.11 version maps which includes the
rotation
property on all Object types. - Tilemap.createFromObjects now checks for a
rotation
property on the Object and if present will set it as the Sprite.angle (#1433) - If for whatever reason you wish to hide the Phaser banner in the console.log you can set
window.PhaserGlobal.hideBanner
totrue
and it will skip the output. Honestly I'd rather if you didn't, but the option is now there. - TilemapLayer.setScale will allow you to apply scaling to a specific Tilemap layer, i.e.
layer.setScale(2)
would double the size of the layer. The way the Camera responds to the layer is adjusted accordingly based on the scale,...