Skip to content

Cache: addBitmapData can auto-create FrameData, fixes 1294 #1300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/loader/Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,24 @@ Phaser.Cache.prototype = {
},

/**
* Add a BitmapData object in to the cache.
* Add a BitmapData object to the cache.
*
* @method Phaser.Cache#addBitmapData
* @param {string} key - Asset key for this BitmapData.
* @param {Phaser.BitmapData} bitmapData - The BitmapData object to be addded to the cache.
* @param {Phaser.FrameData} [frameData] - Optional FrameData set associated with the given BitmapData.
* @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.
* @return {Phaser.BitmapData} The BitmapData object to be addded to the cache.
*/
addBitmapData: function (key, bitmapData, frameData) {

bitmapData.key = key;

if (typeof frameData === 'undefined')
{
frameData = new Phaser.FrameData();
frameData.addFrame(bitmapData.textureFrame);
}

this._bitmapDatas[key] = { data: bitmapData, frameData: frameData };

return bitmapData;
Expand Down