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

2011/7/18

Greenfoot World coordinates

Pieter Pieter

2011/7/18

#
Hi all, I noticed that if I put an Actor in my own World at X position = 0, the left part of my Actor's image is chopped off. Rather, I have to specify X = 75 to align my image to the World's image left side border. Is this confirmed behavior? I find this very confusing, in any case? FYI: Just a code snippet of my World's constructor: super(1024,800,1); addObject(new myActor(),0,400);
Pieter Pieter

2011/7/18

#
OK, I found the solution (and it is explained in the book...) Positions specify the MIDDLE of the Actor's image, not the upper left corner...
DonaldDuck DonaldDuck

2011/7/18

#
If your world object knew the actors image ( GreenfootImage myActorImage = new GreenfootImage("filename of actors image"); ) you could say addObject(new myActor(), 0+(myActorImage.getWidth()/2), 0+(myActorImage.getHeight()/2)); to make the actor be added in the top left corner, but this gets even more confusing. Just remember that the objects x,y coordinates are the center point of the image.
You need to login to post a reply.