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 doobdargent

Hey,
since Weltmeister loads all the level's entities at init(), I don't want my game to consume resources trying to draw off screen entities.

So I've override the Entity.draw() methods like this:

draw: function(){
            if(!ig.game.isInScreen(this.pos)) return;
            this.parent();
}

The thing is, in Weltmeister, the entities are now hidden.
Any idea why?

Cheers!

1 decade ago by doobdargent

Well, just the fact to write the question helps me to think differently.

ig.game.isInScreen does not exists in Weltmeister context. Any way to determine if I'm in weltmeister context or in game?

1 decade ago by doobdargent

Found it!

ig.system.running

Works like a charm. By the way I should have read the class reference much sooner. Lots of useful helper functions there!

1 decade ago by unstoppableCarl

What exactly did you do to resolve this?

1 decade ago by doobdargent

To determine if you're in weltmeister you can use this:
if(typeof(wm) != 'undefined') return;

To spare resource while your entities are offscreen I remove them from the ig.game.entities array. (So it doesn't get updated/drawed/checked)

I remove them using ig.game.entities.erase( entity ); because ig.game.removeEntity( entity ); will make some unwanted changes (like set _killed to true).

1 decade ago by alexandre

IIRC, this works too.
if (ig.global.wm)
{
  // ...
}

1 decade ago by doobdargent

Thanks for your input alex, much more readable like this ;)
Page 1 of 1
« first « previous next › last »