Question

I'm currently in the process of developing a game for OUYA using android java and ODK. when checking for collisions my game crashes out and returns to the menu. This is the point at which things bug out:

    private void checkCollision() {
    if (Rect.intersects(bulletRect1, enemyRectOne1)) {
        visible = false;
    }
}

both Rects are working fine as when I paint them on screen and comment out this method they display as they should. visible = false works fine in other methods within the class. Have I made a mistake somewhere or have other people come across this?

EDIT fixed now. Hunted through my entire code searching for where a Rect could be set to null. Turns out 2 versions of the same Rect were being created, 1 of which was probably null. Many thanks for the support.

Was it helpful?

Solution

2 versions of the same Rect were being created in earlier code, 1 of which was probably null. Simple mistake but very costly time wise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top