You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem here is that it proceeds to call Callback for every tile with any collision flag set, regardless if the Object overlaps with the current tile or not. This is bad since you'll be calling the callback many times on tiles that the object does not overlap / collide with.
Instead, since it just computed if there is an overlap, and you'd only want to do Callback if there is, the line above should be
if (overlapFound && tile.allowCollisions != FlxObject.NONE)
The text was updated successfully, but these errors were encountered:
An improvement to the same function is to move the calculation of tile.mapindex up with the other code tile data code. Here's what it should look like (the last line):
Without this, when Callback is called, mapIndex is zero so there is no way to know which tile triggered the collision callback. Again, this line is already in the code, but it is lower down when the tile's own callback is called. It should be here so mapIndex is available to both Callback and the tile's callback.
After a bit of digging I found that this code used to look different in AS3 Flixel and was originally changed here by @Beeblerox. That commit seems to have been inspired by this one from @Dovyski in the FlixelCommunity fork (with discussion in FlixelCommunity/flixel#37).
Suggestion
This is a small suggestion to the function
overlapsWithCallback()
in FlxTilemap that I'm 90% sure is how it was intended to behave. Change the line:to
Reasoning
In FlxTilemap, the function
overlapsWithCallback()
computes if there is an overlap then immediately does the callback:The problem here is that it proceeds to call
Callback
for every tile with any collision flag set, regardless if theObject
overlaps with the currenttile
or not. This is bad since you'll be calling the callback many times on tiles that the object does not overlap / collide with.Instead, since it just computed if there is an overlap, and you'd only want to do
Callback
if there is, the line above should beThe text was updated successfully, but these errors were encountered: