Coding the detectCollisions method: Part 2
Add the following code after the highlighted comment. Notice the first line of code is an if
statement that checks for a collision between the current GameObject
and the current player collider from the ArrayList
of the player's detailed colliders.
// More code here next
if (RectF.intersects(testedTransform
.getCollider(),
playerColliders.get(i))) {
// React to the collision based on
// body part and object type
switch (go.getTag() + " with " + "" + i) {
// Test feet first to avoid the
// player sinking in to a tile
// and unnecessarily triggering
// right and left as well
case "Movable Platform with 0":// Feet
playersPlayerTransform.grounded();
playersLocation.y =
(testedTransform.getLocation().y)
- (playersTransform.getSize().y);
break;
case "Death with 0":// Feet
gs.death();
break;
case...