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

2013/1/19

Help with collision

Cross Cross

2013/1/19

#
Hii.~ So, in my game 'Big fish Small fish', the hit boxes for the different fish are too large, and the two objects don't even touch before removing the User. Is there another way to make the fish eat each other? This is my eating code
     public boolean canSee(Class clss)
    {
        Actor actor = getOneIntersectingObject(clss);
        return actor != null;
    }
    /**
     * Removes the object if they intersect
     */
    public void eat(Class clss)
    {
       Actor actor = getOneIntersectingObject(clss);
       if(actor != null)
       {
            getWorld().removeObject(actor);
       }
    }
Cross Cross

2013/1/19

#
And this is how the fishes would eat the user
public void fishEatingUser()
    {
        if(canSee(User.class))
        {
            eat(User.class);
            Greenfoot.setWorld(new gameOver());
        }
    }
danpost danpost

2013/1/19

#
You would either have to forego using the canSee method and create another one using a different intersect-checking method, or see if you can trim any excess edges off the images of the fish (or both).
Cross Cross

2013/1/19

#
Thankyou!~
You need to login to post a reply.