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

2016/2/15

move question

sms926 sms926

2016/2/15

#
I know how to have an actor hit the face and turn. How do I have the actor be able to go through and only through the bottom face?
Super_Hippo Super_Hippo

2016/2/15

#
You mean you want your actor to appear at the top when it moves to the bottom? In your world constructor, right at the beginning, you have a super call, something like this:
super(x, y, cellsize);
Change it to:
super(x, y, cellsize, false);
In my opinion, this makes things easier. (It creates an unbounded world, so objects can move outside the visible area.) In the moving actor class' act method, use this:
if (getY() > getWorld().getHeight()-1) setLocation(getX(), getY()-getWorld().getHeight());
danpost danpost

2016/2/15

#
Making the world unbounded will cause issues along the other edges of the world. The actor will be able to go off screen to who knows where along the other edges. Checks will need to be in place to ensure the actor does not proceed beyond the other three edges.
davmac davmac

2016/2/15

#
sms926 wrote...
I know how to have an actor hit the face and turn. How do I have the actor be able to go through and only through the bottom face?
I think you'll get more directly useful answers if you post the code that you already have, even if it doesn't yet do what you want it to. :)
You need to login to post a reply.