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

2013/5/17

Is there something wrong with this code?

Gzuzfrk Gzuzfrk

2013/5/17

#
Sorry everyone I'm new so I'm trying to figure this out. Is there something wrong with this? public boolean onGround() { Actor under = getOneObjectAtOffset ( 0, getHeight() / 2, Ground.class); return under != null; }
Gzuzfrk Gzuzfrk

2013/5/17

#
I says that it can't find getHeight
danpost danpost

2013/5/17

#
'getHeight' (which is interpreted as 'this.getHeight()') is not a method in the Actor class; so the compiler cannot find it using 'this' (the actor) as the object to run the method on. 'height' is a property of an image and 'image' is a property of an actor; therefore, getImage().getHeight() (interpreted as 'this.getImage().getHeight()') is what you should be using.
You need to login to post a reply.