1 decade ago by MikeL
This was particularly insidious. But maybe if I had made better use of the console, I would have found it more quickly. Here is the problem:
If you do something like this:
You will get this ouput to the console, as expected:
But, let&
For some reason the nested arrays get changed into generic objects. As a workaround I did this for now:
and it seems to work. Interestingly using a non-nested array like just
If you do something like this:
var myArr = [[1,3,5],[7,9,11]]; console.log(myArr); ig.game.spawnEntity( EntityOdd, 50, 50, {numArr: myArr} );
You will get this ouput to the console, as expected:
[ Array[3] , Array[3] ]
But, let&
039;s say you now want to access numArr from within your EntityOdd. From within EntityOdd doing #console.log(this.numArr)
gives you this:[ Object , Object ]
For some reason the nested arrays get changed into generic objects. As a workaround I did this for now:
var myArr = [[1,3,5],[7,9,11]]; var entity = ig.game.spawnEntity( EntityOdd, 50, 50, {numArr: myArr} ); entity.numArr = myArr;
and it seems to work. Interestingly using a non-nested array like just
[1,3,5,7,9,11]
works just fine.