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

2013/5/24

How do you make actors jump??

programmingnewb programmingnewb

2013/5/24

#
I really don't know how to make the actors jump...): I don't understand how to check if it is falling or check if it lands on a platform while falling public void jump() { if (Greenfoot.isKeyDown("space")) { setLocation(getX(), getY() - 4); fall(); } } public boolean onPlatform() { Actor below = getOneObjectAtOffset (0, getImage().getHeight()/2, Platform.class); return below != null; } public void checkFall() { } public void fall() { setLocation(getX(), getY() + 4); }
VIJIKUTTI VIJIKUTTI

2014/7/26

#
sorry stupid by divya in coimbatore .
NikZ NikZ

2014/7/29

#
Where is onPlatform() being called?
NikZ NikZ

2014/7/29

#
There is a chance that your player will fall through the platform if the platform is not 4 pixels. Also, do not use getOneObjectAtOffset(). That checks one pixel. Use isTouching() or getOneIntersectingObject() etc., the ones that check a platform intersecting your player.
You need to login to post a reply.