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

2020/3/23

Moving Background

RcCookie RcCookie

2020/3/23

#
Hey guys, I´m currently trying to implement a camera package that allowes to show a part of the world. I´ve got the Actors moving across the screen in their relative position to the selected one and now I´m trying to get the background image moving, too. Unfortunatly I just can´t get it to work, it just draws a weird shape of images layed onto each other on the screen and the part that is actually moving only moves in 45°-angles. I did not use the move method but only setLocation, and I´ve got no idea how to fix this. I would really apreciate it if someone could tell me how to simply draw the background image at an offset position. Here´s the code I used so far (h is the Actor the camera shoud look at):
GreenfootImage temp = new GreenfootImage(w.getBackground().getWidth(), w.getBackground().getWidth());
temp.drawImage(w.getBackground(), h[0].getX(), h[0].getY());
setBackground(temp);
Thanks for any help! RcCookie
You need to login to post a reply.