Hello,
I made a frogger, but came onto a problem wit getOneInterSectingObject, with trying somethings out, i made it work. But now i don't understand why it does work like this and not in the "original" way. Can someone enlighten me ?
The part that doesn't work is my reference to log.getIsAtRightEdge()
Thanks in advance.
/**
* Does Work !
* If the frog is on a log
* move with the log
*/
private void moveOnTheLog()
{
Log log2 = (Log) getOneIntersectingObject(Log.class);
if ( log2.getIsAtRightEdge() == true ){
setLocation(getX()-Log.LOG_SPEED, getY());
}
else {
setLocation(getX()+Log.LOG_SPEED, getY());
}
}
/**
* Doesn't Work !
* If the frog is on a log
* move with the log
*/
private void moveOnTheLog()
{
Actor log = getOneIntersectingObject(Log.class);
if ( log.getIsAtRightEdge() == true ){
setLocation(getX()-Log.LOG_SPEED, getY());
}
else {
setLocation(getX()+Log.LOG_SPEED, getY());
}
}


