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 Joncom

Since ImpactJS 1.20, Dominic has recommended using strict mode.

I tried adding the line "use strict"; to the top of my module, and it immediately broke. I'm not quite sure what I can do to fix this.

reflection.js (one of my entities):
ig.module('game.entities.non-weltmeister.reflection')

.requires('impact.entity')

.defines(function() { "use strict";

	EntityReflection = ig.Entity.extend({ // line 7

// ...etc.

Results in the following two errors:
Uncaught ReferenceError: EntityReflection is not defined reflection.js:7
Uncaught ReferenceError: EntityReflection is not defined main.js:229
I can get rid of the first error by adding var to the front of line 7. But that effectively makes EntityReflection a local var and so, it is still not accessible in main.js

1 decade ago by paulh

i use ig.game.my_variable_name to make things global .. not sure its the right thing to do though :-)

1 decade ago by dominic

You could do this:
ig.global.EntityReflection = ig.Entity.extend({ ... });
// or
window.EntityReflection = ig.Entity.extend({ ... });

I realize this is a bit awkward. In Impact 2.0, entities will live in their own "namespace". No more globals :)

1 decade ago by Heiko

Looking forward to version 2.0 :)

1 decade ago by mmaxwell

Quote from dominic
You could do this:
ig.global.EntityReflection = ig.Entity.extend({ ... });
// or
window.EntityReflection = ig.Entity.extend({ ... });

I realize this is a bit awkward. In Impact 2.0, entities will live in their own "namespace". No more globals :)


I love this. My one complaint about ImpactJS currently is that it encourages using global variables, or at least that's how a lot of the sample code makes me feel. I love that you're migrating to a "use strict" model.
Page 1 of 1
« first « previous next › last »