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

2013/9/24

camera following actor

wabuilderman wabuilderman

2013/9/24

#
is there any easy way to get the camera (viewport) to follow a actor (the player) ?
Zamoht Zamoht

2013/9/24

#
You will have to move all the other objects around the actor you want to follow. If the actor should move left: List objects = getWorld().getObjects(Actor.class); objects.remove(this); for (Actor object : objects) { object.setLocation(object.getX()+1, object.getY()); } Something like this should work. Remember to remove ui elements from the objects list.
There are several scenarios that people have made that follows the main actor, or moves the screen based off the player's movement. The two I've used include: danpost's Scrolling SuperWorld and SPower's Scrolling world Hoped that helped!
You need to login to post a reply.