Skip to content

Commit 1f84024

Browse files
committed
Cache.getImage now returns null if no image was found.
1 parent 3b28d56 commit 1f84024

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Version 2.1.0 - "Cairhien" - -in development-
138138
* The World bounds can now be set to any size, including smaller than the game dimensions. Before it was locked to a minimum size of the game canvas, but it can now be anything.
139139
* ScaleManager.orientationSprite has been removed because it never displayed correctly anyway (it would be distorted by the game scale), it will be bought back in a future version by way of a custom orientation state.
140140
* ArcadePhysics.overlap has been updated so that the Body.overlapX/Y properties are set to the amount the two bodies overlapped by. Previously they were zero and only populated during the separation phase, but now the data is available for just overlap checks as well. You can then use these values in your ovrelap callback as required - note that they are changed for every check, so a Sprite overlap tested against 10 other sprites will have the overlapX/Y values updated 10 times in a single collision pass, so you can only safely use the values in the callback (#641)
141+
* Cache.getImage now returns `null` if the requested image wasn't found.
141142

142143
### Bug Fixes
143144

src/loader/Cache.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ Phaser.Cache.prototype = {
823823
*
824824
* @method Phaser.Cache#getImage
825825
* @param {string} key - Asset key of the image to retrieve from the Cache.
826-
* @return {object} The image data.
826+
* @return {object} The image data if found in the Cache, otherwise `null`.
827827
*/
828828
getImage: function (key) {
829829

@@ -834,6 +834,7 @@ Phaser.Cache.prototype = {
834834
else
835835
{
836836
console.warn('Phaser.Cache.getImage: Invalid key: "' + key + '"');
837+
return null;
837838
}
838839

839840
},

0 commit comments

Comments
 (0)