Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by mimik

Hello

I have found my self writing alot of functions and logic, in my game class file
and it usually gets bloated fast.
my main.js isen't as scaled down as it juste do be,

So I'm Asking if you guys got some good tips for making my main file less blotade with perhaps external files.

Like one file for a save function and one for load.
But also to also to add functionality into my game class
Draw function
Update function
and init function.

I found myself not knowing how to do this.
Can i make a external file and add code to does areas in a easy way?
How do i do it?


Do I creat a continue to
MyGame = ig.Game.extend function or do you got some tips or example how to think about this?

I can have some game logic in the entites ofc but i want to have a good structure with one file for example save.js function
one for draw ui functions etc.

1 decade ago by jswart

What you can do is create new classes that extend the ' ig.Class ' object.

Example:


myNewClass = ig.Class.extend({
    // Your code here
});


Put this in a file named ' mynewclass.js ' in the ' lib ' folder.

Then in your main.js do this:

    // ...
    myNewObject = new MyNewClass();
    // ...

Here are the docs: http://impactjs.com/documentation/class-reference/class
Page 1 of 1
« first « previous next › last »