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 ansimuz

Hi

I've been working with impact for 3 weeks and wanted to know what is the correct way to create a class file for example i have a class for the camera inside the main.js and i want it to have it in a different file so i have a better organization.

Whati want to know exactly:

1. How to import and call from the main.js file

2. How and where should i save the camera.js file.


I have the class defined in this way:
Camera = ig.Class.extend({...})

1 decade ago by Joncom

1. At the top of main.js, you will want to require your class, like this:
ig.module('game.main')

.requires(
'impact.game',
'impact.font',
'game.camera' // <-- Loads your camera class.
)

2. You will want to save your class to /lib/game/camera.js. And it will look like this:
ig.module('game.camera')

.requires()

.defines(function() {

	Camera = ig.Class.extend({...});

});

Good luck!

1 decade ago by ansimuz

Worked like charm.

Thanks
Page 1 of 1
« first « previous next › last »