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

2012/5/17

onGround question

xChocoMel xChocoMel

2012/5/17

#
I'm kind of a newby with greenfoot, so maybe someone can help me with this! I've got a player, which has to stand on the ground (Ground.class), but also on a moving platform called Platform.class. My code is:
public boolean onGround()        
    {
        Object under = getOneObjectAtOffset ( 0, getImage().getHeight() / 2, Ground.class);
        return under != null;
    }
So now there is only Ground.class in my code, but I want to add Platform.class too. But if I replace Ground.class by null, my character also stands on the grass (Grass.class), and I don't want that! I hope someone can help me with this problem. Thanks in advance!
MrDoomsday MrDoomsday

2012/5/17

#
Why not just add a second boolean like "onPlatform()" and use Platform.class in that one instead?
You need to login to post a reply.