API Docs for: 1.4.0
Show:

Kiwi.Files.FileStore Class

Module: Files
Parent Module: Kiwi

Holds all of the Files (regardless of the file type) that have been loaded throughout a game/are accessable at a particular point in time. Contains methods for dealing with files. Note: Each time the state is switched the file store will remove all references to files that have not been flagged as global.

Constructor

Kiwi.Files.FileStore

(
  • game
)
Kiwi.Files.FilesStore

Parameters:

  • game Kiwi.Game

    The game that this FileStore belongs to.

Returns:

Kiwi.Files.FilesStore:

Methods

addFile

(
  • key
  • value
)
Boolean public

Adds a File with a key to the FileStore. If the key that you specify already exists then this method will return false otherwise it should return true if it was added.

Parameters:

  • key String

    A unique key that this file should be accessed by.

  • value Kiwi.Files.File

    The file that you would like to save on the FileStore.

Returns:

Boolean:

If the file was added or not

boot

() public

The boot method is executed when the DOM elements needed for this game are ready and thus the game can 'boot'.

exists

(
  • key
)
Boolean public

Checks to see if a key that you pass is already being used for another file. Returns true if that key is already in used, false if it isn't.

Parameters:

  • key String

    The key that you are checking.

Returns:

Boolean:

getFile

(
  • key
)
Kiwi.Files.File public

Returns a particular file by the key that you specify.

Parameters:

  • key String

    The key of the file that you to get.

Returns:

getFilesByTag

(
  • tag
)
Object public

Returns an object full of files that have a Tag that is associated with it.

Parameters:

  • tag String

Returns:

Object:

All of the files with that tag.

objType

() String public

The type of object that this is.

Returns:

String:

"FileStore"

removeAllFiles

() public

Defined in src\file\FileStore.ts:248

Available since 1.3.0

Removes all files on the FileStore. Use this method with caution.

removeFile

(
  • key
)
Boolean public

Removes a file by the key that is passed. Returns a boolean indicating if a file was removed or not. Note: Only returns false if that file did not exist in the first place.

Parameters:

  • key String

    The key of the file you want to remove.

Returns:

Boolean:

removeFilesByTag

(
  • tag
)
Number public

Removes all of the files by a tag that is specified.

Parameters:

  • tag String

Returns:

Number:

The number of files that were removed.

removeGlobalFiles

() public

Defined in src\file\FileStore.ts:205

Available since 1.3.0

Removes all the files on the FileStore which are not associate with a particular state.

removeStateFiles

(
  • state
)
public

Removes files on the FileStore that are associated with a particular state.

Parameters:

size

() Number public

Returns the number of files that are on this FileStore.

Returns:

Number:

Properties

_files

Object private

The files that are on this FileStore.

_game

Kiwi.Game private

The game that this FileStore belongs to.

_size

Number private

The number of files that are on the file store.

Default: 0

keys

String public

Returns all of the keys for every file that exist on this FileStore as an array.