This site requires JavaScript, please enable it in your browser!
Greenfoot back
Akimb
Akimb wrote ...

2014/4/24

Rain drop game, removing objects that fall to the ground

1
2
Akimb Akimb

2014/4/27

#
I get nullPointer error. It says that the problem is in:
1
int xDiff = bucket.getX()-getX(), yDiff = bucket.getY()-getY();
line. My bucket is created in the BigWorld(World subclass), maybe because of that ?
danpost danpost

2014/4/27

#
I only shown the 'if' code bock (without the 'if' conditional statement), it should be like this:
1
2
3
4
5
6
7
8
if (isTouching(Bucket.class)) {
    Actor bucket = getOneIntersectingObject(Bucket.class);
    int xDiff = bucket.getX()-getX(), yDiff = bucket.getY()-getY();
    if (yDiff > bucket.getImage().getHeight()/2-10 && Math.abs(xDiff) < bucket.getImage().getWidth()/2-3) {
        ((Counter)((BigWorld)getWorld()).getCounter()).addScore();
    }
    getWorld().removeObject(this);
}
Akimb Akimb

2014/4/27

#
Works now, thanks. :)
You need to login to post a reply.
1
2