Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

External Class (Module?)


N3RD
 Share

Recommended Posts

Hello again,

Is there a way to import external classes?

I come from a OOP Background and would like to split classes into single files.

The reason being its alot nicer and cleaner to have multiple smaller classes than

having 1 Main class which is 1000+ lines long. 

 

example:

Main.js
Obj1.js
Obj2.js
etc.....

Is the termonoligy here with panda.js Module instead of class?
If possible what would the implementation be?

Thank you!

N3RD
 

Link to comment
Share on other sites

Yes what you are looking for is Modules. You use them like this:

 

src/game/object1.js:

game.module('game.object1').require(// module dependencies// 'game.object2',// 'game.object3').body(function() {// your code    game.createClass('className', {        init: function(arg1,arg2) {        }});

you are not limited to src/game/ you can also have src/plugins/, src/functions/ and so on. and you call them like this:

game.module('directory.filename','directory1.directory2.filename2')
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...