hi everyone, I've got a problem I can't fix myself. I'm new to greenfoot and trying to make a platformer game. i already got stuck on the following problem: my character can jump, but it doesn't jump anymore after touching/standing on the big "platform" I made. does anyone have a tip to help me to fix this? I'd really appreciate it :) To give a bit more information, this is the code I use:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import greenfoot.Actor; public class Player1 extends Actor { int vSpeed = 0; int accel = 1; int jumpHeight = -20; public void act() { moveAround(); checkFalling(); } private void fall() { setLocation(getX(),getY()+ vSpeed); vSpeed = vSpeed + accel; } public void moveAround() { if(Greenfoot.isKeyDown("w")) { vSpeed = -12; } if(Greenfoot.isKeyDown("up")) { vSpeed = -12; } if(Greenfoot.isKeyDown("a")) { move (-4); } if(Greenfoot.isKeyDown("left")) { move (-4); } if(Greenfoot.isKeyDown("d")) { move (4); } if(Greenfoot.isKeyDown("right")) { move (4); } } boolean onGround() { Actor under = getOneObjectAtOffset(0, getImage().getHeight()/2, ground.class); return under != null; } private void checkFalling() { if (onGround() == false) { fall(); } if (onGround() == true) { vSpeed = 0; } } }