I'm making a slightly modified version of my collision detector that will return what side the collision happened on, but it tells me I'm missing a return statement, even though I've made an "else return". What is wrong in this:
Do I maybe have a bracket in the wrong place? It's my understanding that if I have the "else" statement, this should work. Any help appreciated :D!
public String detectCollisionReturnSide(int moveSpeed, int xMomentum, int yMomentum) { NonPassable object; if(getOneIntersectingObject(NonPassable.class) != null) { object = (NonPassable) getOneIntersectingObject(NonPassable.class); if(object.getY() >= (getY() - 15)) //gives angled illusion { if(xMomentum > 0) //moving right { return "CollidedRight"; } if(xMomentum < 0) //moving left { return "CollidedLeft"; } if(yMomentum > 0) //moving down { return "CollidedDown"; } if(yMomentum < 0) //moving up { return "CollidedUp"; } } } else { return "noCollision"; } }