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

Get Learning Java by Building Android Games - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.