Classes

Data

Custom game data can be stored in the vars property of this class, and from there, saved to and loaded from localStorage. Most modern browsers, as well as those on mobile devices, have this feature. It is a much easier-to-use (not to mention safer) method for handling browser data, compared to cookies. You can store as many complex variables as you wish; JackyJS uses JSON.stringify() and JSON.parse() to handle them.

NOTE: if localStorage exists, game data is saved using the name property you specified in the GAME.Execute function. This prevents any overwriting of data if you have multiple games on your site, for example.

The following are the default property/values stored in this class:

	
	vars: {
		userName: 'noname',
		userAbbr: null,
		scoreCurrent: null,
		scoreHigh: null,
		volumeSound: 50,
		volumeMusic: 50,
		mutedSound: false,
		mutedMusic: false,
		volumeAll: 0.5,
		mutedAll: false
	}	

Methods (static)

Name Parameter Type Description
savesaves the contents of Data.vars into localStorage.
loadloads the contents of Data.vars from localStorage.
clearclears all contents in localStorage, for this domain.
remove* nameStringname of item you want removed from localStorage.