Flixel: Is it possible to change a tiles image?

Monkey Forums/Monkey Programming/Flixel: Is it possible to change a tiles image?

DeltaWolf7(Posted 2013) [#1]
Is it possible to change the index of the image being used by a tile in Flixel for Monkey?
I am assuming that it can be done on a Tile object, would I have to replace it or can it be modified?

Is it possible to swap the look of a tile when the play enters it, say grass to dirt?

Thanks


CGV(Posted 2013) [#2]
I haven't looked at Flixel for Monkey, I'm only familiar with the original version of Flixel so I'm not sure if your talking about FlxTilemap or not, but if you are it has methods for changing the tile image.

setTile()

setTileByIndex()

Just look them up in the source.


devolonter(Posted 2013) [#3]
Hi,

As CVG has said earlier there are two methods to change tile. In Flixel for Monkey you can use the following methods of FlxTilemap: SetTile(x, y, newTile) or SetTileByIndex(index, newTile)


DeltaWolf7(Posted 2013) [#4]
Ah yes, thank you. I just realised the docs can be found here: http://flixel.org/docs/

Thank you guys for the nudge in the right direction.


DeltaWolf7(Posted 2013) [#5]
Ok, so after much messing around, I have come up with this..

My world class implements FlxTileHitListener
And once the tilemap is loaded I call this;

 FloorTiles.SetTileProperties(1, FlxObject.NONE, Self, Null, 1)


All in the same class, but..

Method OnTileHit:Void(tile:FlxTile, Object:FlxObject)
		Print ("event fire") 
		FloorTiles.SetTileByIndex(tile.ID, 2, True)
	End Method


never gets called. Events and Delegates would be welcome..
I have tried changing the part that says 'Self' to OnTileHit, but it just tell me it cant find the required overload.

What am I doing wrong??? Based on the Flixel docs, it seems correct.


devolonter(Posted 2013) [#6]
Do you have a call of something like FloorTiles.Overlaps(playerObject) or playerObject.Overlaps(FloorTiles) in Update method of your world/playstate class? Since callback function will be called only in this case. From documentation:
This callback function, if present, is triggered by calls to overlap() or overlapsWithCallback()



DeltaWolf7(Posted 2013) [#7]
Bingo...

Totally missed that. Noob alert.

Thank you, yes that's what I missed. Couldnt work it out for looking.