Jump to content

Updating tiles not working?


Recommended Posts

I'm trying to update properties on tiles within a tilemap layer once the player has moused down on a tile.  When I try this though, my tiles never get updated.


I tried the following as a basic test where I directly update a single tile in the layer all of the time to make sure that the update was working and this works correctly.

function update(){  foobar = bg_map_layer.getTiles( 14,113, 1, 1);   foobar[0].alpha = 0.5;  foobar[0].rotation = 40;}

So here I'm trying to update the tiles in update after they have been moused down on...


function update(){  if(game.input.mousePointer.isDown){      mouseX = game.input.mousePointer.x      mouseY = game.input.mousePointer.y            if ((mouseX > 867 && mouseX < 74) && (mouseY > 77 && mouseY < 72))      {          play_button.x=867          play_button.y=77      }      arr_touched_tiles = _.union(arr_touched_tiles, bg_map_layer.getTiles( 300,300, 100, 100));       arr_touched_tiles = bg_map_layer.getTiles( game.input.mousePointer.x, game.input.mousePointer.y, 10, 10);   }  for(var i = 0; i < arr_touched_tiles.length; i++){      arr_touched_tiles[i].alpha = 0.0;      arr_touched_tiles[i].rotation = 40;  } }

On this second version I never see the tiles change.  When I try to inspect it in the browser console it gets into my for loop and the values appear to be set on the tiles, but they do not display with the alpha + rotation.


Link to comment
Share on other sites


  • Recently Browsing   0 members

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