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

2014/4/8

MoveToGround Error

Greenfootnoob Greenfootnoob

2014/4/8

#
G'day.... i was watching a video from youtube however there was an error. can anyone help? it says '.class expected'. just before the 'newY'.
public void moveToGround(Actor ground) 
    {
        int groundHeight = ground.getimage(). getHeight()/
        int newY = ground.getY() - (groundHeight + getImage(). getHeight())/2;
        
        setLocation(getX(), newY);
        
    }
danpost danpost

2014/4/8

#
Yeah. Line 3 looks incomplete (or closes with the wrong character).
Greenfootnoob Greenfootnoob

2014/4/9

#
so what could i add or replace?
danpost danpost

2014/4/9

#
Change the last character to what it should be to end a command line.
Greenfootnoob Greenfootnoob

2014/4/9

#
what do you mean by last character?
Greenfootnoob Greenfootnoob

2014/4/9

#
sorry I'm new to green foot
danpost danpost

2014/4/9

#
Look at the end of your line 3 above. You end it with a forward slash. That cannot be right. All command lines should end with a semi-colon -- ";". BTW, this has nothing to do with greenfoot; this is Java syntax. This is covered in the Java tutorials on this page.
You need to login to post a reply.