Skip to content

Commit f06f784

Browse files
committed
Merge pull request #1300 from pnstickne/wip-1294b
Cache: addBitmapData can auto-create FrameData, fixes 1294
2 parents 17de8fd + f7f940d commit f06f784

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/loader/Cache.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,24 @@ Phaser.Cache.prototype = {
244244
},
245245

246246
/**
247-
* Add a BitmapData object in to the cache.
247+
* Add a BitmapData object to the cache.
248248
*
249249
* @method Phaser.Cache#addBitmapData
250250
* @param {string} key - Asset key for this BitmapData.
251251
* @param {Phaser.BitmapData} bitmapData - The BitmapData object to be addded to the cache.
252-
* @param {Phaser.FrameData} [frameData] - Optional FrameData set associated with the given BitmapData.
252+
* @param {Phaser.FrameData|null} [frameData=(auto create)] - Optional FrameData set associated with the given BitmapData. If not specified (or `undefined`) a new FrameData object is created containing the Bitmap's Frame. If `null` is supplied then no FrameData will be created.
253253
* @return {Phaser.BitmapData} The BitmapData object to be addded to the cache.
254254
*/
255255
addBitmapData: function (key, bitmapData, frameData) {
256256

257257
bitmapData.key = key;
258258

259+
if (typeof frameData === 'undefined')
260+
{
261+
frameData = new Phaser.FrameData();
262+
frameData.addFrame(bitmapData.textureFrame);
263+
}
264+
259265
this._bitmapDatas[key] = { data: bitmapData, frameData: frameData };
260266

261267
return bitmapData;

0 commit comments

Comments
 (0)