sbiermanlytle / iioEngine

iio Engine: A JavaScript game engine for HTML5 Canvas
http://iioengine.com
455 stars 81 forks source link

Reference existing ioAppManager #21

Closed jamessimo closed 10 years ago

jamessimo commented 10 years ago

Is there any way that I can reference an already existing ioAppManager?

For example, I want to split my Global game logic and Level logic, like so.

global.js

var world;
function GameControl(io) {  
        //create the box2d world
        world = io.addB2World(new b2World(
        new b2Vec2(0, 30) 
       ,true      
    ));

currentLvl = new lvl1();
currentLvl.setup();

io.setB2Framerate(60, function(){
//Game Logic
};iio.start(GameControl, 'myCanvas');

level1.js


lvl1.prototype.setup = function() {
//Define Background
        io.setBGImage(imgPath+'bg.gif'); //I WANT THIS TO REF THE GameControl(io) APP.
}

As far as I know, I don't see any clear way to reference an already existing ioAppManager. (so I can add objects and styles to the canvas

jamessimo commented 10 years ago

looking at https://github.com/sbiermanlytle/iioengine/blob/master/extensions/iioDebugger.js

I managed to duplicate its behaviour and pass an existing AppManager to my level.