Kiwi.Files.FileStore Class
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
Parameters:
-
game
Kiwi.GameThe game that this FileStore belongs to.
Returns:
Item Index
Methods
Methods
addFile
-
key
-
value
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
StringA unique key that this file should be accessed by.
-
value
Kiwi.Files.FileThe file that you would like to save on the FileStore.
Returns:
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
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
StringThe key that you are checking.
Returns:
getFile
-
key
Returns a particular file by the key that you specify.
Parameters:
-
key
StringThe key of the file that you to get.
Returns:
getFilesByTag
-
tag
Returns an object full of files that have a Tag that is associated with it.
Parameters:
-
tag
String
Returns:
All of the files with that tag.
objType
()
String
public
The type of object that this is.
Returns:
"FileStore"
removeAllFiles
()
public
Removes all files on the FileStore. Use this method with caution.
removeFile
-
key
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
StringThe key of the file you want to remove.
Returns:
removeFilesByTag
-
tag
Removes all of the files by a tag that is specified.
Parameters:
-
tag
String
Returns:
The number of files that were removed.
removeGlobalFiles
()
public
Removes all the files on the FileStore which are not associate with a particular state.
removeStateFiles
-
state
Removes files on the FileStore that are associated with a particular state.
Parameters:
-
state
Kiwi.State
size
()
Number
public
Returns the number of files that are on this FileStore.
Returns:
Properties
_files
Object
private
The files that are on this FileStore.
_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.