java - Tiles not updating completely in rendering in libgdx -


this code trying make work correctly. when character collides specific object supposed run. tiles gain new properties, not change in rendering process. goal give them new properties , rendering new tile.

collisionlayer = (tiledmaptilelayer) map.getlayers().get(0);                 for(int x = 0; x < collisionlayer.getwidth();x++){                     for(int y = 0; y < collisionlayer.getheight();y++){                         cell = collisionlayer.getcell(x,y);   if(cell.gettile().getproperties().containskey("hiddenwall")) {                             cell.settile(map.gettilesets().gettile(2));                     }                     }                } 

this old code worked. upon collision tile players location, , upon collision collision tile tile new block type , set it. code below works , displays correctly. code above not. have idea why?

cell cell = collisionlayer.getcell(                     (int) ((getx()) / (collisionlayer.gettilewidth() )),                     (int) ((gety())/ (collisionlayer.gettileheight() )));              cell.settile(map.gettilesets().gettile(2)); 

it turns out running method in wrong place. needed run in render method of program. though did work in other places. (which in collision detection) 1 tile @ tile. checking every tile on map wasn't working of other mechanics. once ran code in render method worked charm every time.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -