P2 Body onBeginContact and onEndContact are messed up
liv1n9 opened this issue · comments
Version: Phaser 2 CE 13.2
I want to check if two object using P2 bodies are overlap or not. My solution: use a boolean variable overlap = false, when onBeginContact, set overlap = true, onEndContact, set overlap = false. The first object is not moving (but not static) while other's body position is controlled by mouse click. The problem is this scenario is not work as expected, onBeginContact and onEndContact seem to work with every polygon parts of object's body, so the overlap assignment is not correct.
Is there any way to check 2 p2 body overlaping or not?
I figured out the solution 👍 , instead of using boolean variable overlap, i use integer variable overlap, when onBeginContact i increase overlap by 1, when onEndContact i decrease overlap by 1. So two objects overlap when variable overlap > 0, otherwise they are not overlap.