I defined a module (for the code easy to read,I delete some unnecessary line..)
Here is my game.js
define(['util'], function (util) {
return {
createNew : function (setting) {
var game = {
intervalTrigger : function () {
return window.setInterval(function () {
score++;//how to read deal with this value?
}, 1000);
}
}
};
return game;
}
};
});
and use it in app.js
:
require.config({
baseUrl: "./src",
});
requirejs(['util', 'game'],
function (util,game) {
var score = 0;
function startgame(level) {
var setting = {};
var g = game.createNew();
g.intervalTrigger();
}
startgame(0);
});
in my case, I need to createNew
for few times, so the score can't be stored in the module.
so how to access score
in the module game
?