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

10 years ago by DanBridge

Hi,

I'm using the drop example to learn about procedurally generating maps.

I've hit a problem trying to change the tile image (e.g. from 1 to 2 in this.map ) as it also changes the collision map value, which changes the collision map value to 2, which gives a sloping collision tile

I'm sure I'm doing something silly but can't see it, any help would be really appreciated :)

Thanks
Dan


e.g. it uses this.map which is that passed to the collision and the background

this.collisionMap = new ig.CollisionMap( 16, this.map );
this.backgroundMaps.push( new ig.BackgroundMap(16, this.map, 'media/tiles.png' ) );

10 years ago by Joncom

Please include the code where you attempt to change "from 1 to 2 in this.map".

10 years ago by DanBridge

Hi JonCom,

Thanks for replying! I've just managed to fix the problem.

I was using impact's drop example game which uses a single this.map array to pass to the constructor of both the background and the collision maps.

As JS passes the array by ref, modifying it afterward (e.g. changing a background tile from 1 to 2 via this.backgroundmap[0].data etc also updates the collision map)

so I've just cloned the initial map and keeping two near identical versions, one for the collisions and one for the background.

Sorry!

Dan

10 years ago by Joncom

No problem. Congrats on solving the issue.
Page 1 of 1
« first « previous next › last »