new Cache(game)
Phaser.Cache constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
- Source:
Members
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game Local reference to game.
-
onSoundUnlock
-
- Source:
Properties:
Name Type Description onSoundUnlockPhaser.Signal Description.
Methods
-
addBitmapFont(key, url, data, xmlData)
-
Add a new Bitmap Font.
Parameters:
Name Type Description keystring The unique key by which you will reference this object.
urlstring URL of this font xml file.
dataobject Extra font data.
xmlDataobject Texture atlas frames data.
- Source:
-
addCanvas(key, canvas, context)
-
Add a new canvas object in to the cache.
Parameters:
Name Type Description keystring Asset key for this canvas.
canvasHTMLCanvasElement Canvas DOM element.
contextCanvasRenderingContext2D Render context of this canvas.
- Source:
-
addDefaultImage()
-
Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default.
- Source:
-
addImage(key, url, data)
-
Add a new image.
Parameters:
Name Type Description keystring The unique key by which you will reference this object.
urlstring URL of this image file.
dataobject Extra image data.
- Source:
-
addRenderTexture(key, textue)
-
Add a new Phaser.RenderTexture in to the cache.
Parameters:
Name Type Description keystring The unique key by which you will reference this object.
textuePhaser.Texture The texture to use as the base of the RenderTexture.
- Source:
-
addSound(key, url, data, webAudio, audioTag)
-
Add a new sound.
Parameters:
Name Type Description keystring Asset key for the sound.
urlstring URL of this sound file.
dataobject Extra sound data.
webAudioboolean True if the file is using web audio.
audioTagboolean True if the file is using legacy HTML audio.
- Source:
-
addSpriteSheet(key, url, data, frameWidth, frameHeight, frameMax)
-
Add a new sprite sheet in to the cache.
Parameters:
Name Type Description keystring The unique key by which you will reference this object.
urlstring URL of this sprite sheet file.
dataobject Extra sprite sheet data.
frameWidthnumber Width of the sprite sheet.
frameHeightnumber Height of the sprite sheet.
frameMaxnumber How many frames stored in the sprite sheet.
- Source:
-
addText(key, url, data)
-
Add a new text data.
Parameters:
Name Type Description keystring Asset key for the text data.
urlstring URL of this text data file.
dataobject Extra text data.
- Source:
-
addTextureAtlas(key, url, data, atlasData, format)
-
Add a new texture atlas.
Parameters:
Name Type Description keystring The unique key by which you will reference this object.
urlstring URL of this texture atlas file.
dataobject Extra texture atlas data.
atlasDataobject Texture atlas frames data.
formatnumber The format of the texture atlas.
- Source:
-
addTilemap(key, url, mapData, format)
-
Add a new tilemap.
Parameters:
Name Type Description keystring The unique key by which you will reference this object.
urlstring URL of the tilemap image.
mapDataobject The tilemap data object.
formatnumber The format of the tilemap data.
- Source:
-
addTileset(key, url, data, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing)
-
Add a new tile set in to the cache.
Parameters:
Name Type Argument Default Description keystring The unique key by which you will reference this object.
urlstring URL of this tile set file.
dataobject Extra tile set data.
tileWidthnumber Width of the sprite sheet.
tileHeightnumber Height of the sprite sheet.
tileMaxnumber How many tiles stored in the sprite sheet.
tileMarginnumber <optional>
0 If the tiles have been drawn with a margin, specify the amount here.
tileSpacingnumber <optional>
0 If the tiles have been drawn with spacing between them, specify the amount here.
- Source:
-
checkImageKey(key) → {boolean}
-
Checks if an image key exists.
Parameters:
Name Type Description keystring Asset key of the image you want.
- Source:
Returns:
True if the key exists, otherwise false.
- Type
- boolean
-
decodedSound(key, data)
-
Add a new decoded sound.
Parameters:
Name Type Description keystring Asset key for the sound.
dataobject Extra sound data.
- Source:
-
destroy()
-
Clears the cache. Removes every local cache object reference.
- Source:
-
getCanvas(key) → {object}
-
Get acanvas object from the cache by its key.
Parameters:
Name Type Description keystring Asset key of the canvas you want.
- Source:
Returns:
The canvas you want.
- Type
- object
-
getFrame(key) → {Phaser.Frame}
-
Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.
Parameters:
Name Type Description keystring Asset key of the frame data you want.
- Source:
Returns:
The frame data you want.
- Type
- Phaser.Frame
-
getFrameByIndex(key) → {Phaser.Frame}
-
Get a single frame out of a frameData set by key.
Parameters:
Name Type Description keystring Asset key of the frame data you want.
- Source:
Returns:
The frame data you want.
- Type
- Phaser.Frame
-
getFrameByName(key) → {Phaser.Frame}
-
Get a single frame out of a frameData set by key.
Parameters:
Name Type Description keystring Asset key of the frame data you want.
- Source:
Returns:
The frame data you want.
- Type
- Phaser.Frame
-
getFrameData(key) → {Phaser.FrameData}
-
Get frame data by key.
Parameters:
Name Type Description keystring Asset key of the frame data you want.
- Source:
Returns:
The frame data you want.
- Type
- Phaser.FrameData
-
getImage(key) → {object}
-
Get image data by key.
Parameters:
Name Type Description keystring Asset key of the image you want.
- Source:
Returns:
The image data you want.
- Type
- object
-
getImageKeys() → {Array}
-
Returns an array containing all of the keys of Images in the Cache.
- Source:
Returns:
The string based keys in the Cache.
- Type
- Array
-
getKeys(array) → {Array}
-
Get the cache keys from a given array of objects. Normally you don't call this directly but instead use getImageKeys, getSoundKeys, etc.
Parameters:
Name Type Description arrayArray An array of items to return the keys for.
- Source:
Returns:
The array of item keys.
- Type
- Array
-
getSound(key) → {Phaser.Sound}
-
Get sound by key.
Parameters:
Name Type Description keystring Asset key of the sound you want.
- Source:
Returns:
The sound you want.
- Type
- Phaser.Sound
-
getSoundData(key) → {object}
-
Get sound data by key.
Parameters:
Name Type Description keystring Asset key of the sound you want.
- Source:
Returns:
The sound data you want.
- Type
- object
-
getSoundKeys() → {Array}
-
Returns an array containing all of the keys of Sounds in the Cache.
- Source:
Returns:
The string based keys in the Cache.
- Type
- Array
-
getText(key) → {object}
-
Get text data by key.
Parameters:
Name Type Description keystring Asset key of the text data you want.
- Source:
Returns:
The text data you want.
- Type
- object
-
getTextKeys() → {Array}
-
Returns an array containing all of the keys of Text Files in the Cache.
- Source:
Returns:
The string based keys in the Cache.
- Type
- Array
-
getTexture(key) → {Phaser.RenderTexture}
-
Get a RenderTexture by key.
Parameters:
Name Type Description keystring Asset key of the RenderTexture you want.
- Source:
Returns:
The RenderTexture you want.
- Type
- Phaser.RenderTexture
-
getTextureFrame(key) → {Phaser.Frame}
-
Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.
Parameters:
Name Type Description keystring Asset key of the frame data you want.
- Source:
Returns:
The frame data you want.
- Type
- Phaser.Frame
-
getTilemap(key) → {Object}
-
Get tilemap data by key.
Parameters:
Name Type Description keystring Asset key of the tilemap you want.
- Source:
Returns:
The tilemap data. The tileset image is in the data property, the map data in mapData.
- Type
- Object
-
getTileset(key) → {Phaser.Tileset}
-
Get tile set image data by key.
Parameters:
Name Type Description keystring Asset key of the image you want.
- Source:
Returns:
The tileset data. The tileset image is in the data property, the tile data in tileData.
- Type
- Phaser.Tileset
-
getTileSetImage(key) → {object}
-
Get tile set image data by key.
Parameters:
Name Type Description keystring Asset key of the image you want.
- Source:
Returns:
The image data you want.
- Type
- object
-
isSoundDecoded(key) → {boolean}
-
Check if the given sound has finished decoding.
Parameters:
Name Type Description keystring Asset key of the sound you want.
- Source:
Returns:
The decoded state of the Sound object.
- Type
- boolean
-
isSoundReady(key) → {boolean}
-
Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked.
Parameters:
Name Type Description keystring Asset key of the sound you want.
- Source:
Returns:
True if the sound is decoded and the device is not touch locked.
- Type
- boolean
-
isSpriteSheet(key) → {boolean}
-
Check whether an image asset is sprite sheet or not.
Parameters:
Name Type Description keystring Asset key of the sprite sheet you want.
- Source:
Returns:
True if the image is a sprite sheet.
- Type
- boolean
-
reloadSound(key)
-
Reload a sound.
Parameters:
Name Type Description keystring Asset key for the sound.
- Source:
-
reloadSoundComplete(key)
-
Description.
Parameters:
Name Type Description keystring Asset key for the sound.
- Source:
-
removeCanvas(key)
-
Removes a canvas from the cache.
Parameters:
Name Type Description keystring Key of the asset you want to remove.
- Source:
-
removeImage(key)
-
Removes an image from the cache.
Parameters:
Name Type Description keystring Key of the asset you want to remove.
- Source:
-
removeSound(key)
-
Removes a sound from the cache.
Parameters:
Name Type Description keystring Key of the asset you want to remove.
- Source:
-
removeText(key)
-
Removes a text from the cache.
Parameters:
Name Type Description keystring Key of the asset you want to remove.
- Source:
-
updateSound(key)
-
Description.
Parameters:
Name Type Description keystring Asset key for the sound.
- Source: