Hi all,
Since my script is getting bigger, I want to split cc.Class script to multiple files.
I did research for how to do it, and find this,
So, I wrote code below, but it isn’t working. Can anybody tell me how to fix it?
It seems require(‘CB_X.js’)(CharBase); part is not working.
Thanks in advance.
CharaBase.js
require('CB_A.js')(CharBase);
require('CB_ABjs')(CharBase);
var CharBase = cc.Class({
onLoad: function() {
CharBase.methodA();
this.methodB();
},
});
module.exports = CharBase;
CB_A.js
module.exports = function(CharBase) {
CharBase.prototype.methodA = function() {
cc.log('Class method A');
};
// more methods...
};
CB_B.js
module.exports = function(CharBase) {
CharBase.methodB = function() {
cc.log('Instance method B');
};
// more methods...
};