did you check this ?
http://api.haxeflixel.com/flixel/tile/FlxTilemap.html#tileToSprite
I think a for loop could do the trick here.. something like
for (j in 0...map.heightInTiles)
for (i in 0...map.widthInTiles-1)
if(map.getTile(i,j) == 0 && map.getTile(i+1,j) == 32)
map.setTile(i,j,newIndex,true);
if you more complex checks you should probably check this tutorial.
as far as I can see ... you are not even initializing the whitSquare
variable right. since you are creating a new local variable in the create()
function using the var
keyword. so I can't see where is the public variable initialized.
I would also advice against using relative values when moving the cursor. because then you wouldn't be able to tell when a position is wrong quickly since errors are accumulated. so something like whiteSquare.y = 155;
is better
hello everyone ..
so I needed FlxNapeTileMap into my current project .. and mostly it worked prefectly (great thanks for those who worked on it :smiley: )
but it seemed to crash on neko for certain maps in a very weird way althoug it will work nicely on linux cpp & flash. this crash only happens on certain layouts though . I tried to find a pattern to it but I couldn't. so whenever I faced it I kept changing different tiles until it worked again (which is not acceptable of course).
here is the neko crash log ->
Invalid field access : elem
Called from zpp_nape/shape/Polygon.hx line 923
Called from zpp_nape/shape/Polygon.hx line 1115
Called from zpp_nape/space/Space.hx line 4944
Called from zpp_nape/space/Space.hx line 2405
Called from zpp_nape/space/Space.hx line 1821
Called from nape/phys/BodyList.hx line 455
Called from flixel/addons/nape/FlxNapeTilemap.hx line 256
Called from flixel/addons/nape/FlxNapeTilemap.hx line 143
Called from map/TiledLevel.hx line 106
Called from a C function
Called from map/TiledLevel.hx line 29
Called from state/mode/collect/CollectCoinsSinglePlayerMode.hx line 30
Called from flixel/FlxGame.hx line 623
Called from flixel/FlxGame.hx line 713
Called from flixel/FlxGame.hx line 663
Called from flixel/FlxGame.hx line 530
Called from openfl/_legacy/events/EventDispatcher.hx line 98
Called from a C function
Called from openfl/_legacy/display/DisplayObject.hx line 161
Called from a C function
Called from openfl/_legacy/display/DisplayObjectContainer.hx line 286
Called from openfl/_legacy/display/Stage.hx line 1103
Called from openfl/_legacy/display/Stage.hx line 351
Called from openfl/_legacy/display/Stage.hx line 1084
Called from openfl/_legacy/display/Stage.hx line 430
so today I was planning to fix that problem .. I started to follow the call stack.
and then three hours and 40 traces() later .. I found the line causing the problem.
without going into much details this check should evaluate to true
if(crs*crs>=Config.epsilon*Config.epsilon)
tracing both crs & config.epsilon results in 49152
and1e-08
respectively
now you would think that the last condition would result in true easily, right ?
WRONG because in neko -> 49152*49152 = -1879048192
._.
overflowing seems to be a know issue with Neko .. Ref
so I was finally able to get it to work by just using crs
for comparison instead of crc*crs
but I would like to know better ways to do it. also I would like to know what should I do about that change .. should I push it somewhere for example ?
thanks
here is the current situation . I am working on a top-down car game. and I wanted to implement skid marks .. similar skid to the ones found in absolute drift
here is some of the approaches I can think of and their pros and cons :
1- use short FlxSprites to form the skid marks and continuously draw them while the car is moving.
pros : easy to implement, and you can easily delete sprites after a certain amount of time.
cons : looks ragged and unrealistic. it also doesn't seems memory-efficient at all.
2- make a level-size FlxSprite and stamp short skid-marks in it
pros : fairly easy to implement and much more efficient.
cons : you lose control over individual sprites so they can't fade after a while, also it still doesn't look smooth.
3- make a level-size FlxSprite and draw curves on it using the drawCurve()
function
pros : should look a lot better than previous solutions .
cons : I have no idea how to set the control point to formulate the curve, also I still have no control over individual pieces so I can't make it fade after a while .
so my question is whether there are better solution to draw skid marks other than those mentioned above or how to overcome the deficiencies for any of the solutions mentioned above.