Cache Class
A game only has one instance of a Cache and it is used to store all externally loaded assets such as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
Constructor
Item Index
Methods
Methods
-
key
Get a Texture by key.
Parameters:
-
key
StringAsset key of the RenderTexture you want.
Returns:
addAudio
-
obj
Add a new sound.
Parameters:
-
obj
ObjectThe audio file object
-
key
StringAsset key for the audio.
-
url
StringURL of this audio file.
-
data
ArrayBuffer | AudioThe loaded audio data
-
webAudio
BooleanIs this a webAudio ArrayBuffer for a sound?
-
decoded
BooleanIs the data decoded yet?
-
addBitmapFont
-
obj
Add a new Bitmap Font.
Parameters:
-
obj
ObjectThe bitmap font file object
-
key
StringAsset key for the font texture.
-
url
StringURL of this font xml file.
-
data
ObjectExtra font data.
-
format
NumberThe format of the bitmap font data
-
-
key
Get a Texture by key.
Parameters:
-
key
StringAsset key of the RenderTexture you want.
Returns:
addCanvas
-
obj
Add a new canvas.
Parameters:
-
obj
ObjectThe spritesheet object
-
key
StringAsset key for this canvas.
-
canvas
HTMLCanvasElementCanvas DOM element.
-
context
CanvasRenderingContext2DRender context of this canvas.
-
-
key
Get a Bitmap Font by key.
Parameters:
-
key
StringAsset key of the Bitmap Font you want.
Returns:
addImage
-
obj
Add a new image.
Parameters:
-
obj
ObjectThe image file object
-
key
StringAsset key for the image.
-
url
StringURL of this image file.
-
image
ImageThe image object that was loaded
-
addSpriteSheet
-
obj
Add a new sprite sheet.
Parameters:
-
obj
ObjectThe spritesheet object
-
key
StringAsset key for the sprite sheet.
-
url
StringURL of this sprite sheet file.
-
image
ImageThe image of the sprite sheet
-
frameWidth
NumberWidth of the sprite sheet.
-
frameHeight
NumberHeight of the sprite sheet.
-
frameMax
NumberHow many frames stored in the sprite sheet.
-
addText
-
obj
Add a new text data.
Parameters:
-
obj
ObjectThe text file object
-
key
StringAsset key for the text data.
-
url
StringURL of this text data file.
-
data
ObjectExtra text data.
-
addTextureAtlas
-
obj
Add a new texture atlas.
Parameters:
-
obj
ObjectThe texture atlas file object
-
key
StringAsset key for the texture atlas.
-
url
StringURL of this texture atlas file.
-
format
NumberThe format of the atlas data ATLAS_FORMAT.JSON_ARRAY, ATLAS_FORMAT.JSON_HASH, or ATLAS_FORMAT.STARLING_XML
-
data
ObjectThe texture atlas data exported from TexturePacker
-
image
ImageThe texture image
-
addTilemap
-
obj
Add a new tilemap.
Parameters:
-
obj
ObjectThe tilemap file object
-
key
StringAsset key for the tilemap
-
url
StringURL of the tilemap data file
-
data
ObjectThe loaded tilemap data
-
format
NumberThe format of the tilemap data
-
[images]
Arrayoptional Array of images used in the tilesets of this tilemap
-
destroy
()
Destroys this object, removing references so the GC can cleanup
getAudio
-
key
Get sound by key.
Parameters:
-
key
StringAsset key of the sound you want.
Returns:
getAudioData
-
key
Get sound data by key.
Parameters:
-
key
StringAsset key of the sound you want.
Returns:
getCanvas
-
key
Get canvas by key.
Parameters:
-
key
StringAsset key of the canvas you want.
Returns:
getImage
-
key
Get image data by key.
Parameters:
-
key
StringAsset key of the image you want.
Returns:
getText
-
key
Get text data by key.
Parameters:
-
key
StringAsset key of the text data you want.
Returns:
The text data you want.
getTilemap
-
key
Get tilemap data by key.
Parameters:
-
key
StringAsset key of the tilemap you want.
Returns:
The tilemap file data. The map data is in the data
property, the images (for tileset) are in images
removeCanvas
-
key
Remove a canvas by key.
Parameters:
-
key
Stringkey to remove
removeImage
-
key
Remove an image by key.
Parameters:
-
key
Stringkey to remove
removeSound
-
key
Remove a sound by key.
Parameters:
-
key
Stringkey to remove
removeText
-
key
Remove a text by key.
Parameters:
-
key
Stringkey to remove
Properties
_canvases
Object
private
Canvas key-value container.
_images
Object
private
Image key-value container.
_sounds
Object
private
Sound key-value container.
_text
Object
private
Text key-value container.
_tilemaps
Object
private
Tilemap key-value container.