imsupergreg Posted July 28, 2014 Share Posted July 28, 2014 Hey everyone! I'm new to Phaser and started developing a new app today. Unfortunately, I have been brickwalled by a weird problem relating to changing tilemap tile fill types. In my app, I need to toggle what tile type to fill each tile with. I have two images that I use in my tilemap. function preload(){ game.load.tilemap('map', 'assets/maps/TileMap.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tile-danger-zone', 'assets/tile-danger-zone.png'); // tile 1 game.load.image('tile-safe-zone', 'assets/tile-safe-zone.png'); // tile 2} // short version of what I'm trying to doif(currentTile.index == EMPTY_ZONE_ID) map.fill(DANGER_ZONE_ID, x, y, 1, 1); // works fineelse if (currentTile.index == SAFE_ZONE_ID) // the real version would fill all 'danger zone' tiles into 'safe zone' tiles map.fill(SAFE_ZONE_ID, x, y, 1, 1); // failsShort story is, I have a character that moves around on a tilemap using tweening (to keep him within tiles). When you run over an "empty tile" it turns to a "danger tile" and when you leave the "empty zone", it changes all the "danger tiles" into "safe tiles". Changing them to a "danger tile" works perfectly fine, however, later when I try to switch it back to a "safe zone" tile, it fails with the error below. Don't know what to do!?!? Uncaught TypeError: Cannot set property 'index' of undefined phaser.min.js:17 b.Tilemap.fillphaser.min.js:17 clearEndangeredTilesBalls.js:135 fillTilesBalls.js:116 playerTweenCompleteBalls.js:199 b.SignalBinding.executephaser.min.js:7 b.Signal.dispatchphaser.min.js:7 dispatchphaser.min.js:7 b.Tween.updatephaser.min.js:13 b.TweenManager.updatephaser.min.js:13 b.Game.updatephaser.min.js:9 b.RequestAnimationFrame.updateRAFphaser.min.js:13 window.requestAnimationFrame.forceSetTimeOut._onLoop I tried to keep this short and sweet, so let me know if I left anything out or if you need more code. Any help is appreciated! Thanks Cheers,Super. Link to comment Share on other sites More sharing options...
Dumtard Posted July 28, 2014 Share Posted July 28, 2014 The error seems to be coming from the file Balls.js line 135, we will need to see the code around there.I also suggest not developing with the .min.js file, it is much easier to find the source of problems in the .js file. Once you are done making your game and going for release you can then use the .min.js. Link to comment Share on other sites More sharing options...
Recommended Posts