1 decade ago by momander
An entity's draw() method is called both during design-time (Weltmeister) and during run-time (when the game is played). Some custom drawing that works well during a game may not make sense or even be possible during design-time. For example, hitting ig.game.getEntitiesByType() won't work.
How can the code in my draw() method tell the difference between design-time and run-time?
This doc says that ig.game will be null during design-time:
http://impactjs.com/documentation/class-reference/ig-core#ig-game
So I wrote this code in my entity:
But ig.game is not null (the debugger tells me it's an [object Object]) so the custom drawing logic runs, and I get errors. How can I avoid executing the custom drawing code during design-time?
How can the code in my draw() method tell the difference between design-time and run-time?
This doc says that ig.game will be null during design-time:
http://impactjs.com/documentation/class-reference/ig-core#ig-game
So I wrote this code in my entity:
draw: function() { this.parent(); if (ig.game != null) { // Custom drawing code here. } }
But ig.game is not null (the debugger tells me it's an [object Object]) so the custom drawing logic runs, and I get errors. How can I avoid executing the custom drawing code during design-time?