Skip to content
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

Closed
agj opened this issue Jan 15, 2010 · 4 comments
Closed

Tilemap callbacks not always being called #22

agj opened this issue Jan 15, 2010 · 4 comments

Comments

@agj
Copy link

agj commented Jan 15, 2010

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.

@agj
Copy link
Author

agj commented Jan 18, 2010

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.

@AdamAtomic
Copy link
Owner

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 :)

@agj
Copy link
Author

agj commented Feb 12, 2010

Alrighty. I like my overlaps() solution, but maybe it's not very efficient to do two collision checks every frame. Hm.

@AdamAtomic
Copy link
Owner

tilemaps have callbacks again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants