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

2013/5/1

World At Edge problem

ColonelCaboose ColonelCaboose

2013/5/1

#
Alright so I have a very large image that is very long, and I have
if(atWorldEdge())
        {
            isRight = !isRight;
        }
So what pretty much happens is that half the image goes off screen before turning around, then goes across the othe world and goes halfway off screen at the other edge of the world and turns back around. How do I change it's origin to the image doesn't go off screen?
danpost danpost

2013/5/1

#
Change the condition in the 'atWorldEdge' method in the 'Animal' class so that the limits are (1) getX()< getImage().getWidth()/2 (2) getX() > getWorld().getWidth()-getImage().getWidth()/2 (3) getY() < getImage().getHeight()/2 (4) getY() > getWorld().getHeight()-getImage().getHeight()/2
You need to login to post a reply.