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

2017/4/24

not a statement

BrianOK BrianOK

2017/4/24

#
(newY+under.getY()-(under.getImage().getHeight()/2)-((getImage().getHeight()/2))-1;) -1 is not a statement. following a guide and work for him? (line 17)
    public boolean onGround()
    {
        Ground under = null;
        int counter = 1;
        int max = vSpeed;
        //int variance
        while (counter <=max&&under==null)
      {
          under=(Ground)getOneObjectAtOffset(0,getimage().getHeight()/2+counter,Ground.class);
          counter ++;
        }
        // If there is a platform, correct Player's height so that he always lands right on the platform
        // This avoids a wierd floating effect that was present otherwise
        if(under !=null)
        {
            int newY;
            newY+under.getY()-(under.getImage().getHeight()/2)-((getImage().getHeight()/2))-1;
            setLocation(getX(),newY);
        }
        return under!= null;
}
danpost danpost

2017/4/24

#
All you have is an arithmetic expression at line 17. It is not assigning any value to any variable. Maybe the first '+' should be an '='.
You need to login to post a reply.