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

2014/4/1

Platformer Help

Galfrea Galfrea

2014/4/1

#
Hello friends! I was making a simple platformer for my project and have run into a few problems which I hope someone will be able to help with. The biggest problem is that the character / hero that you play as won't land on the platform in which he's supposed to stand on. Obviously I've messed around with the code and it still doesn't work. The code I used it below, any help will be appreciated!
 private void checkKeys()
        {
            int yPos = getY();
       if(Greenfoot.isKeyDown("down"))
       move (yPos = -5);
       if (Greenfoot.isKeyDown("up") && jumping==false)
       jump();
       if (Greenfoot.isKeyDown("left"))
       move (-5);
       if (Greenfoot.isKeyDown("right"))
       move (5);
               Actor under = getOneObjectAtOffset (0,100,Platform.class);
        Actor over = getOneObjectAtOffset (0,0,Platform.class);
        if(under != null) {
            vSpeed = 0;
            jumping = false;
        }
        else if (over != null)
        {
            vSpeed = -vSpeed;
            fall();
        }
        else {
            fall();
        }

    }    
You need to login to post a reply.