Jump to content

TileMap Fill Throwing Error in phaser.min.js File


imsupergreg
 Share

Recommended Posts

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);          // fails
Short 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!?!?

 

 

  1. Uncaught TypeError: Cannot set property 'index' of undefined phaser.min.js:17
    1. b.Tilemap.fillphaser.min.js:17
    2. clearEndangeredTilesBalls.js:135
    3. fillTilesBalls.js:116
    4. playerTweenCompleteBalls.js:199
    5. b.SignalBinding.executephaser.min.js:7
    6. b.Signal.dispatchphaser.min.js:7
    7. b.Tween.updatephaser.min.js:13
    8. b.TweenManager.updatephaser.min.js:13
    9. b.Game.updatephaser.min.js:9
    10. b.RequestAnimationFrame.updateRAFphaser.min.js:13
    11. window.requestAnimationFrame.forceSetTimeOut._onLoop
    12.  

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...