-
Notifications
You must be signed in to change notification settings - Fork 17
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
FlxTilemap.overlapsWithCallback calls callback when no overlapping #37
Comments
@Dovyski, you assigned this issue to yourself. Are you still working on it, or should I "open it up to the public"? |
I am still working on it. I've committed some code to the Sandbox to test it, but have no time to continue. Does anyone want to continue from where I left or should I keep going? |
It's entirely up to you. If you have found something and are on the right track, go ahead and finish when you get the time; we aren't in a hurry. But if you feel stuck, perhaps a second set of eyes could help. |
Ok, I will keep working on it. I think it's not far from over. |
I've just committed some tilemap collision tests to FlixelSandbox. I could not reproduce this bug, It's important to note that |
It's been a year since @imagame opened the issue, so he was definitely using Flixel 2.55, not a previous version. But he has probably found a solution or just moved on.
That makes sense. Shall we close this issue for now, but double check with imagame in the original issue? Perhaps he still has the old code laying around and we can see if this was the case or not. |
I think he found a solution too :) I will close this issue here then. I already asked @imagame about the code in the original issue. If we get something, we can re-open this issue. |
Original code (while loop starting in line 945 in overlapsWithCallback function):
And now same loop with my fix replacing 'else' code in line 977, to avoid calling the tile callback in all situations (only has to be called if there is overlapping !):
|
I've read the whole /**
* Checks if the Object overlaps any tiles with any collision flags set,
* and calls the specified callback function (if there is one).
* Also calls the tile's registered callback if the filter matches.
*
* @param Object The <code>FlxObject</code> you are checking for overlaps against.
* @param Callback An optional function that takes the form "myCallback(Object1:FlxObject,Object2:FlxObject)", where Object1 is a FlxTile object, and Object2 is the object passed in in the first parameter of this method.
* @param FlipCallbackParams Used to preserve A-B list ordering from FlxObject.separate() - returns the FlxTile object as the second parameter instead.
* @param Position Optional, specify a custom position for the tilemap (useful for overlapsAt()-type funcitonality).
*
* @return Whether there were overlaps, or if a callback was specified, whatever the return value of the callback was.
*/
public function overlapsWithCallback(Object:FlxObject,Callback:Function=null,FlipCallbackParams:Boolean=false,Position:FlxPoint=null):Boolean Here are my thoughts so far according to what I've understood from the method code:
Even though this is what I've understood from the code, I am not able to reproduce that behavior. I am running some tests. As soon as I have some news, I will let you guys know. |
After some time in the deep catacombs of Flixel, I've found an answer :D All I said in my previous post is correct and accurate. Flixel will invoke the tile's callback every time it detects an overlap, no matter if the tile allows collision or not. I could not reproduce @imagame bug: Flixel invoked the tile's callback only when an overlap was found (I've pushed to the Sandbox the code I used). @imagame Could you please provide us with a snippet of your game's code? |
I'll try to recreate it, once i review the code of my game (more than a |
Ok, I will wait for your code. Don't worry about the time, it's not wasted :) |
I've reproduced the "overlapping issue behaviour" using your FlixelSandbox As it is now TestTileMap.as when the player collides with Tile 3 (the I'm not sure if it could be considered and issue or not. Certainly for my Hope this comments help, as you can see your code is valid to test it. Only 2013/3/5 Fernando Bevilacqua notifications@github.com
|
Finally I got some time to test your case and I've confirmed the bug. I will investigate it even further. |
I've fixed the bug using @imagame 's solution (I just removed a few duplicated code blocks). I tested it using the sandbox and it seems to be working. If anybody wants to test it further, use this Flixel branch which contains the fix. |
…overlapping. The overlapping check performed for tiles with allowCollision = false ignored the object widht/height, so the tile callback would fire even when the Object was placed close to, but not overlapping, the tile.
Fix issue #37 FlxTilemap.overlapsWithCallback calls callback when no overlapping
Fixed here 99447a0. |
Issue #194 by: imagame
The tile's registered callback is been calling when there is no overlapping, for tiles that not allow collisions.
The tile callback should be called only if there is overlapping, not in all cases (line 977)
For tiles that allow collisions it is correct.
The text was updated successfully, but these errors were encountered: