MonsieurPixel Posted December 6, 2013 Share Posted December 6, 2013 Hi, I've seen that Matt Groves (and probably many of you) was using something to keep is code in separate files (i.e. Defined in: src/pixi/loaders/BitmapFontLoader.js:5). Though, Pixi.js comes as one file in the end ! I want to achive such magic. How is this done ? Thank you ! Quote Link to comment Share on other sites More sharing options...
Paul Brzeski Posted December 6, 2013 Share Posted December 6, 2013 They're just extending the object PIXI itself, by the look of it. The way I'd do it is create a creation function that acts as the basis for your 'something' (in your example it would be PIXI a function fired when you instantiate it). Here's how you might do it from scratch (just writing this off the top of my head, sorry if it doesn't compile) // mySomething.jsvar mySomething = function(){ return this;}; // mySomething.doStuff.js mySomething.prototype.doStuff = function() { // stuff}; <html><script src='mySomething.js'></script><script src='mySomething.doStuff.js'></script><script>function onLoad() { // create a new instance of mySomething accessible in this scope var mySomething = new mySomething(); // we are able to access doStuff because it was added in mySomething.doStuff.js mySomething.doStuff();}</script><body onload='onLoad()'></body></html> Quote Link to comment Share on other sites More sharing options...
benny! Posted December 6, 2013 Share Posted December 6, 2013 If you are speaking of having a clean codebase with logically separated javascript files - well I guess this is what we all do when our project grows. To release a single compressed file of all your javascript files - there is no real magic behind it. Typically, this release version is automatically created within your build process, ie. a javascript minifier takes all your files, merges and compresses them into one single file. There are numerous build tools and scripts around and it's usually a matter of taste which to choose. Personally I use an ant-script and Google Closure compiler - but I guess there exists a Grunt task for this, too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.