-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tilemap callbacks not always being called #22
Comments
I was able to sidestep this issue by extending the FlxTilemap class and adding a variation of the overlaps() function that returns an array of overlapping tiles instead of a boolean value. The issue with the collide() function remains, though, and I did rack my brain trying to find a way to solve it, but really couldn't without a major restructuring of the way the callback system works. |
The new version (hopefully going up tonight) has had callbacks removed until I can figure out a more reliable way of handling them...whatever new system we figure out, hopefully it will be more reliable than the old one :) |
Alrighty. I like my overlaps() solution, but maybe it's not very efficient to do two collision checks every frame. Hm. |
tilemaps have callbacks again :) |
The issue can be experienced when, for instance, the player character in a platformer is standing with one foot on one tile, and another on a different tile; if both these tiles had a callback set, only the left tile's will be triggered.
It took me a while to discover the cause for the issue, since I'm not an experienced programmer, but I did find it. When one uses a tilemap's collide() function, it calls collideX() and collideY() for every block that could be colliding against the passed core. The problem lies in these two, which modify the core's position; so, if we're iterating between the two blocks at the abovementioned character's feet, the leftmost block will trigger a collision (since the sprite is at that time actually falling through it), and in the process move the sprite's position upwards so it's not colliding any longer; therefore, when a collision check is attempted for the second block, it will return false and not perform the callback.
The text was updated successfully, but these errors were encountered: