make sprite collisions register events with all tiles touched #920
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Currently, only the top most / left most wall that a sprite is touching has it's collision event trigger, which feels weird as the sprite is hitting multiple tiles but only counting collisions for one of them seemingly arbitrarily.
This defers the wall collision handling until after each tile the sprite would be touching has been checked, and then runs the collision events for each of them, instead of backing out after the first one.
fixes microsoft/pxt-arcade#1185 (except the sub issue of a request for non-bounding box based tile collisions, which I don't think will be feasible for now at least.)
worth a note this will cause a minor change in the block above's behavior (will return the rightmost collided tile instead of the leftmost), but that behavior wasn't defined / generally understood before anyways. I think that one might be good to change in the future, maybe just to be an option on the
is hitting wall
block that takes a parameter for the type of wall (e.g so you can check if it's hitting a lava tile); I don't think there's really anything valuable you can do with the block currently (without going to ts), and haven't seen it used (that I remember).