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 congwang0517

If I define a variable like this in index.html:
<script>
var obj1 = {x:100,y:100};
<script>
I want to use obj1 in impactjs. e.g.
var entity1 = this.spawnEntity(EntityM, 300,300);
How to assign obj1.x to the entity.pos.x?

Thanks for any help!

1 decade ago by Graphikos

entity1.pos.x = obj1.x;

Unless I'm missing the point... It is getting quite late. ;)

1 decade ago by Arantor

Well, I think variable scope will be a problem at that point.

If you declare it as:
<script>
obj1 = { x: 100, y: 100 };
</script>

and have that before the code where Impact + your game is loaded, it should work.
Page 1 of 1
« first « previous next › last »