Raicuparta Posted March 30, 2014 Share Posted March 30, 2014 (edited) Want the grass to move when the player steps on it. Have 4 layers on my tilemap, one of them exclusively for the grass.Have this function: moveGrass: function(x, y) { _map.replace(18, 20, _layer[1].getTileX(x), _layer[1].getTileY(y), 1, 1, 'Grass1'); }And I pass the player's x and y as arguments. _layer is an array of layers, and 'Grass1' is the layer with the grass I wanna repalce.I get this error: Uncaught TypeError: Cannot read property 'index' of null phaser.min.js:15 b.Tilemap.replacephaser.min.js:15 moveGrassLevel.js:53 updatePlayer.js:144 updatemain.js:46 b.StateManager.updatephaser.min.js:6 b.Game.updatephaser.min.js:8 b.RequestAnimationFrame.updateRAFphaser.min.js:11 window.requestAnimationFrame.forceSetTimeOut._onLoopphaser.min.js:11 Even tried it with different layers, still get this error, not sure what index the error is referring to. EDIT: So it seems the problem is that the blank tiles are null so I can't attempt to replace them. So I just need to be more careful with choosing a tile to replace, or fill the entire screen with invisible tiles. Edited March 30, 2014 by Raicuparta Link to comment Share on other sites More sharing options...
Recommended Posts