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 BrownHorse

I want to create a module that has an array that I can access from other modules.
ig.module(
    'game.module-name'
)
.defines(function(){

words: ['blah', 'blah', 'blah'];
    
});

How do I structure the module and how do I access the array from another module? I'm a javascript noob.

1 decade ago by Joncom

/* lib/game/example.js */
ig.module('game.example')
.defines(function(){
    ig.example = {
        foo: [] // Define your array.
    }    
});

/* lib/game/main.js */
ig.module('game.main')
.requires( ..., 'game.example' )
.defines(function(){
    MyGame = ig.Game.extend({
        ...
        init: function() {
            ...
            console.log(ig.example.foo); // Log your array.
        }
    });
});

1 decade ago by BrownHorse

Thank you
Page 1 of 1
« first « previous next › last »