Set Tile To 0



  • How do I get a tile in a tile map to set to 0 after any object touches it?

    I am doing this:

    for (v in 0...16) map.setTile(Std.int(player.x / 16 ), Std.int(player.y / 16), FlxG.collide(player, map) ? v : 0);
    

    What that gives me though is whenever the player touches the tile map in the upper left of the sprite the tile is set to 0. But not for any other directions.

    I can copy what you need to do from here: http://haxeflixel.com/demos/SetTileProperties/

    BUT when I copy this line:

    map.setTileProperties(2, FlxObject.LEFT, rightHit); 
    

    I get the error: Cannot skip non-nullable argument Range

    How do I get to happen what I want to happen?

    Forum bug: Popup keeps coming up after I've clicked it:
    Forum Updated

    This forum has just been updated to the latest version. Click here to refresh the page.



  • Figured something out.



  • While I did figure something out, I still have a problem. The player tunnels through the terrain as well! This is what I'm doing. I create a map like in BSPMapGenerator. Then I sort of combine it with the SetTileProperties demo. I do it like this:

    //When the flxtilemap is created from bspmapgenerator, i give it's tiles these properties
    
    	for (v in 1...16) map.setTileProperties(v, FlxObject.ANY, bombHit);		
    

    BombHit is just a rename of the function rightHit in SetTileProperties. I then set up everything else. For collisions, I go:

    FlxG.collide(player, map);		
    FlxG.collide(_blueEmitter, map, bombHit);
    

    This is bombHit and it's sister function:

    private function removeTile(Tile:FlxTile):Void
    {		
    	map.setTileByIndex(Tile.mapIndex, 0, true);		
    }		
    
    //Both here need to be FlxObject
    private function bombHit(Tile:FlxObject, particle:FlxObject):Void	
    {
    	removeTile(cast Tile);
    }
    

    Again, the problem is tiles are set to 0 whenever the player object hits the tile map too. I've no idea how to fix that.

    I need only the particles from the blue emitter to effect the tiles on the tile map and not the player object.

    How would you do this?


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.