Jump to content

Returning all tiles of a specific type

Vexen Crabtree

Recommended Posts

I want to adjust the alpha of all tiles of a particular type, but I don't know an elegant way of doing it... I could iterate through all tiles, and find them one by one. Is there a cleverer way? Something like a "get_tilesByType" function, used like this:


(or iterating through each returned object and running .setAlpha).

As the player runs around, they clean up 'dirt' (tile index = 11 from the tilemap). How do I count how many dirts remain? It is likely a similar solution to the one above;

var dirt_remaining = levelData.tilemap.get_tilesByType(11).length;

If you're interested, this is how I'm cleaning dirt tiles:


function cleanDirt(pPlayer,pTile)
	//Has to accept pPlayer because this is invoked by a game collide callback
	txtComplete.setText("Cleanliness:\n     " + Math.floor(100*dirtCleanedQ/dirtStartQ) + "%");


Link to comment
Share on other sites


  • Recently Browsing   0 members

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