Releases: phaserjs/phaser
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,...
Alkindar
Version 2.2.2 - "Alkindar" - 6th January 2015
New Features
- Phaser.Loader now supports BLOB urls for audio files (thanks @aressler38 #1462)
- Line.reflect will calculate the reflected, or outgoing angle of two lines. This can be used for Body vs. Line collision responses and rebounds.
- Line.normalAngle gets the angle of the line normal in radians.
- Line.normalX and Line.normalY contain the x and y components of the left-hand normal of the line.
- Line.fromAngle will sets this line to start at the given
x
andy
coordinates and for the segment to extend atangle
for the givenlength
. - BitmapData.drawGroup draws the immediate children of a Phaser.Group to a BitmapData. Children are only drawn if they have their
exists
property set totrue
. The children will be drawn at theirx
andy
world space coordinates. When drawing it will take into account the child's rotation, scale and alpha values. No iteration takes place. Groups nested inside other Groups will not be iterated through.
Updates
- TypeScript definitions fixes and updates (thanks @clark-stevenson @Schmavery)
- DOM.visualBounds now includes scroll bars (#1429)
- The new fixed time-step code has been more carefully linked to Pixi transform updates. This should finally put a stop to the tunneling issues that were being reported.
- Tween.stop fired a different set of onComplete parameters to Tween.update. Both now dispatch `onComplete(target, tween)`` as the parameters in that order (thanks @P0rnflake #1450)
- Removed redundant
tolerance
parameter from Rectangle.intersects (thanks @toolness #1463) - Phaser.Graphics.drawCircle now overrides PIXI.drawCircle which means the docs are now correct re: diameter not radius (thanks @ethankaminski #1454)
- Device.webAudio check inversed to avoid throwing a warning in Chrome.
- Mouse.mouseMoveCallback is flagged as deprecated.
- Remove
tw
andth
init from TilemapLayer (thanks @nextht #1474) - Particles.Arcade.Emitter.makeParticles now checks the given
quantity
value againstEmitter.maxParticles
. Ifquantity
is more thanmaxParticles
then themaxParticles
value is reset to the newquantity
given (as this is how most devs seem to use it). - Particles.Arcade.Emitter.emitParticle now returns a boolean depending if a particle was emitted or not.
- Particles.Arcade.Emitter.update only updates
_counter
if a particle was successfully emitted. - Phaser.Point.angleSq removed. It didn't work so any code relying on it would be broken, and it's unclear what it was meant for (thanks @nextht #1396)
- BitmapData.copy
tx
parameter ifnull
andsource
is a Display Object, it will default tosource.x
. - BitmapData.copy
ty
parameter ifnull
andsource
is a Display Object, it will default tosource.y
.
Bug Fixes
- Fix / double-copy for Safari tilemap bug when rendering with delta scrolling. This fixes tilemaps not appearing to update on Safari OS X and iOS specifically (thanks @pnstickne @neurofuzzy @lastnightsparty #1439 #1498)
- Simplified call to
updateTransform
. This is the unified and verified fix for #1424 #1479 #1490 #1502 and solves issues with physics tunneling and visual glitches under the new time step code. - Tween.delay, Tween.repeat and Tween.yoyo will no longer throw an error if called before a TweenData object has been created (via Tween.to or Tween.from) (thanks @SomMeri #1419)
- The click trampoline added for IE prevented Chrome for Android from being
able to launch Full Screen mode with the default parameters for
ScaleManger#startFullScreen (the desktop version of Chrome was not
affected.). This is now fixed and additional compatibility settings (clickTrampoline) that can be used to configure when such is used. By default the 'when-not-mouse' mode is only enabled for Desktop browsers, where the
primary input is ubiquitously a mouse. There are no known breaking compatibility changes - the Full Screen should be initiatable in Chrome for Android as it was in 2.1.x. The default Android browser does not support Full Screen (thanks @pnstickne) - TilemapParser now checks for image collections, avoiding crashes. These would arise with maps exported from the new release of Tiled (thanks @paul-reilly #1440)
- Group.replace could still access
newChild.parent
after it was set toundefined
. This unifies the approach (thanks @pnstickne #1410 #1417) - P2.postBroadphaserHandler updated to avoid skipping final 2 pairs.
- The P2 World constructor wouldn't let you use your own config unless you specified both the gravity and broadphase. Now allows one or both (thanks @englercj #1412)
- The RandomDataGenerator could be seeded with an array of values. However if the array contained a zero it would stop seeding from that point (thanks @jpcloud @pnstickne #1456)
- Added extra checks to Sound.play to stop it throwing DOM Exception Error 11 if the
sound.readyState
wasn't set or the sound was invalid. Also wrappedstop()``call in a
try catch`. - Time.reset would incorrectly reset the
_started
property, now maps it toTime.time
(thanks @XekeDeath #1467) - Fix floating point inaccuracy in Tween easing edge cases (thanks @jounii #1492)
- Phaser.Signal was causing a CSP script-src violations in Cordova and Google Chrome Apps (thanks @elennaro #1494)
- Added Events.onEnterBounds to the destroy method (thanks @legendary-mich #1497)
- AnimationManager.destroy is now more careful about clearing up deep references (thanks @Arturszott #1449)
- Ellipse.right and Ellipse.bottom setters fixed (thanks @nextht #1397)
- Fixed double Ellipse.getBounds definition (thanks @nextht #1397)
- TileSprite.loadTexture crashed when textures were updated in WebGL (thanks @pandavigoureux29 #1495)
Pixi.js 2.2.0 Updates
- The strip class has now three extra properties, canvasPadding, paddingX, and paddingY : @darionco
- Added mipmap option to to textures.
- Added the ability to use GL_TRIANGLES when rendering Strips @darionco
- Added the ability to tint the Graphics.
- Fixed Y-flipped mask issue on render texture.
- Fixed the issue where you could an alpha that is more than one and it would.
- Fixed text issues when using accents.
- Fixed sprite caching not clearing the previous cached texture : @kambing86
- Fixed arcTo issues.
- Vertex buffer and and vertex shader optimisation and reduced memory footprint on the tint and alpha : @bchevalier
- Applied the new generic updateTransform to spritebatch : @kambing86
Danabar
Version 2.2.1 - "Danabar" - 4th December 2014
Bug Fixes
- Fixed Pixi.js issue with
alpha
not working on any display object. - Fixed TweenManager.isTweening() and .removeFrom() (thanks @jotson #1408)
- Added Game.debug reset method for when the debug manager is disabled (thanks @DanielSitarz #1407)
- Custom Particle classes that used a BitmapData wouldn't work (thanks @hardalias #1402)
Version 2.2.0 - "Bethal" - 3rd December 2014
New Features
- Updated to Pixi v2.2.0 - see separate change log entry below.
- Cache.getRenderTexture will retrieve a RenderTexture that is stored in the Phaser Cache. This method replaces Cache.getTexture which is now deprecated.
- Cache.autoResolveURL is a new boolean (default
false
) that automatically builds a cached map of all loaded assets vs. their absolute URLs, for use with Cache.getURL and Cache.checkURL. Note that in 2.1.3 and earlier this was enabled by default, but has since been moved behind this property which needs to be set totrue
before you load any assets to enable. - You can now call Tween.to again on a Tween that has already completed. This will re-use the same tween, on the original object, without having to recreate the Tween again. This allows a single tween instance to be re-used multiple times, providing they are linked to the same object (thanks InsaneHero)
- Phaser.Color.valueToColor converts a value: a "hex" string, a "CSS 'web' string", or a number - into red, green, blue, and alpha components (thanks @pnstickne #1264)
- Stage.backgroundColor now supports CSS 'rgba' values, as well as hex strings and hex numbers (thanks @pnstickne #1234)
- Pointer.addClickTrampoline now adds in support for click trampolines. These raise pointer events into click events, which are required internally for a few edge cases like IE11 full screen mode support, but are also useful if you know you specifically need a DOM click event from a pointer (thanks @pnstickne #1282)
- Point.floor will Math.floor both the
x
andy
values of the Point. - Point.ceil will Math.ceil both the
x
andy
values of the Point. - ScaleManager.scaleSprite takes a Sprite or Image object and scales it to fit the given dimensions. Scaling happens proportionally without distortion to the sprites texture. The letterBox parameter controls if scaling will produce a letter-box effect or zoom the sprite until it fills the given values.
- Phaser.DOM.getBounds is a cross-browser element.getBoundingClientRect method with optional cushion.
- Phaser.DOM.calibrate is a private method that calibrates element coordinates for viewport checks.
- Phaser.DOM.aspect gets the viewport aspect ratio (or the aspect ratio of an object or element)
- Phaser.DOM.inViewport tests if the given DOM element is within the viewport, with an optional cushion parameter that allows you to specify a distance.
- Phaser.DOM.viewportWidth returns the viewport width in pixels.
- Phaser.DOM.viewportHeight returns the viewport height in pixels.
- Phaser.DOM.documentWidth returns the document width in pixels.
- Phaser.DOM.documentHeight returns the document height in pixels.
- TilemapLayers have been given a decent performance boost on canvas with map shifting edge-redraw (thanks @pnstickne #1250)
- A large refactor to how the internal game timers and physics calculations has been made. We've now swapped to using a fixed time step internally across Phaser, instead of the variable one we had before that caused glitchse on low-fps systems. Thanks to pjbaron for his help with all of these related changes.
- We have separated the logic and render updates to permit slow motion and time slicing effects. We've fixed time calling to fix physics problems caused by variable time updates (i.e. collisions sometimes missing, objects tunneling, etc)
- Once per frame calling for rendering and tweening to keep things as smooth as possible
- Calculates a
suggestedFps
value (in multiples of 5 fps) based on a 2 second average of actual elapsed time values in theTime.update
method. This is recalculated every 2 seconds so it could be used on a level-by-level basis if a game varies dramatically. I.e. if the fps rate consistently drops, you can adjust your game effects accordingly. - Game loop now tries to "catch up" frames if it is falling behind by iterating the logic update. This will help if the logic is occasionally causing things to run too slow, or if the renderer occasionally pushes the combined frame time over the FPS time. It's not a band-aid for a game that floods a low powered device however, so you still need to code accordingly. But it should help capture issues such as gc spikes or temporarily overloaded CPUs.
- It now detects 'spiraling' which happens if a lot of frames are pushed out in succession meaning the CPU can never "catch up". It skips frames instead of trying to catch them up in this case. Note: the time value passed to the logic update functions is always constant regardless of these shenanigans.
- Signals to the game program if there is a problem which might be fixed by lowering the desiredFps
- Time.desiredFps is the new desired frame rate for your game.
- Time.suggestedFps is the suggested frame rate for the game based on system load.
- Time.slowMotion allows you to push the game into a slow motion mode. The default value is 1.0. 2.0 would be half speed, and so on.
- Time.timeCap is no longer used and now deprecated. All timing is now handled by the fixed time-step code we've introduced.
- Time.now can no longer be relied upon to contain a timestamp value. If the browser supports requestAnimationFrame then
Time.now
will contain the high resolution timer value that rAf generates. Otherwise it will contain the value of Date.now. If you require the actual time value (in milliseconds) then please useTime.time
instead. Note that all Phaser sub-systems that used to rely onTime.now
have been updated, so if you have any code that extends these please be sure to check it. - Game.forceSingleUpdate will force just a single logic update, regardless of the delta timer values. You can use this in extremely heavy CPU situations where you know you're about to flood the CPU but don't want Phaser to get stuck in a spiral.
- Tilemap.createFromTiles will convert all tiles matching the given tile index (or an array of indexes) into Sprites. You can optionally then replace these tiles if you wish. This is perfect for games when you want to turn specific tiles into Sprites for extra control. The Sprites have an optional properties object which they can be populated with.
- Added support for the Wheel Event, which is the DOM3 spec (thanks @pnstickne #1318)
- Wheel Scroll Event (old non-FF) and DOM Mouse Wheel (old FF) are
supported via a non-exported reused wrapper object; WheelEventProxy.
The proxy methods are generated one-time dynamically but only when needed. - Key.justDown allows you to test if a Key has just been pressed down or not. You can only call justDown once per key press. It will only return
true
once, until the Key is released and pressed down again. This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop (thanks @pjbaron #1321) - Key.justUp allows you to test if a Key has just been released or not. You can only call justUp once per key press. It will only return
true
once, until the Key is pressed down and released again. This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop (thanks @pjbaron #1321) - Device.whenReady is a new signal that you can use to tell when the device is initialized.
- Device.onInitialized is dispatched after device initialization occurs but before any of the ready callbacks have been invoked. Local "patching" for a particular device can/should be done in this event.
- TweenManager.removeFrom method allows you to remove a tween from a game object such as a Sprite (thanks @lewster32 #1279)
- Tweens have been completely rewritten. They're now much more flexible and efficient than before:
- When specifying the ease in
Tween.to
orTween.from
you can now use a string instead of the Function. This makes your code less verbose. For example instead ofPhaser.Easing.Sinusoidal.Out
and you can now just use the string "Sine".The string names match those used by TweenMax and includes: "Linear", "Quad", "Cubic", "Quart", "Quint", "Sine", "Expo", "Circ", "Elastic", "Back", "Bounce", "Power0", "Power1", "Power2", "Power3" and "Power4". You can append ".easeIn", ".easeOut" and "easeInOut" variants. All are supported for each ease types. - Tweens now create a TweenData object. The Tween object itself acts like more of a timeline, managing multiple TweenData objects. You can now call
Tween.to
and each call will create a new child tween that is added to the timeline, which are played through in sequence. - Tweens are now bound to the new Time.desiredFps value and update based on the new Game core loop, rather than being bound to time calculations. This means that tweens are now running with the same update logic as physics and the core loop.
- Tween.timeScale allows you to scale the duration of a tween (and any child tweens it may have). A value of 1.0 means it should play at the desiredFps rate. A value of 0.5 will run at half the frame rate, 2 at double and so on. You can even tween the timeScale value for interesting effects!
- Tween.reverse allows you to instantly reverse an active tween. If the Tween has children then it will smoothly reverse through all child tweens as well.
- Tween.repeatAll allows you to control how many times all child tweens will repeat before firing the Tween.onComplete event. You can set the value to -1 to repeat forever.
- Tween.loop now controls the looping of all child tweens.
- Tween.onRepeat is a new signal that is dispatched whenever a Tween repeats. If a Tween has many child tweens its di...