// Save data
cc.sys.localStorage.setItem(key, value)
cc.sys.localStorage.setItem('gold', 100);
// For complex data as object, we can first serialize it to JSON:
userData = {
name: 'Tracer',
level: 1,
gold: 100
};
cc.sys.localStorage.setItem('userData', JSON.stringify(userData));
// Read data
cc.sys.localStorage.getItem(key)
var userData = JSON.parse(cc.sys.localStorage.getItem('userData'));
// Save data
cc.sys.localStorage.setItem(key, value)
cc.sys.localStorage.setItem('gold', 100);
// For complex data as object, we can first serialize it to JSON:
userData = {
name: 'Tracer',
level: 1,
gold: 100
};
cc.sys.localStorage.setItem('userData', JSON.stringify(userData));
// Read data
cc.sys.localStorage.getItem(key)
var userData = JSON.parse(cc.sys.localStorage.getItem('userData'));