-
If I want to make a data object in Cocos Creator, that’s not a component, and won’t be attached to the scene, what is the best way to do that?
cc.Class({
, ES6class
, or standard JavaScript objects usingfunction
? -
If I want that object to be in a separate JS file (and remember, it’s not a component) what’s the best way to load it?
-
If I want to make a global singleton, which is not attached to any scene, but holds data relevant to all scenes, what is the best practice for that?
You can simply define a global data like:
window.globalData = {
foo: 1,
bar: 'test'
};