Hello,
i have this problem:
My game has a big world. The image goes to the right and left. But when i place my testperson und you walk in one direction, he moves out the image. So my question is, is it possible that the world moves with the charakter? And how to do this.
These are my codes (test world):
and
Thanks for any help!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class SpielWelt extends World { private static int zellenGroesse = 70; /** * Erschaffe eine Welt mit 14 * 10 Zellen. */ public SpielWelt() { super(50, 6, zellenGroesse); setBackground("images/istockphoto-1200036161-612x612.jpg"); Greenfoot.setSpeed(15); } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Mann here. * * @author (your name) * @version (a version number or a date) */ public class test extends Actor { public void act() { { int speed = 1; if (Greenfoot.isKeyDown("up")) setLocation(getX(), getY() - speed) ; if (Greenfoot.isKeyDown("down")) setLocation(getX(), getY() + speed) ; if (Greenfoot.isKeyDown("left")) setLocation(getX() - speed, getY()); if (Greenfoot.isKeyDown("right")) setLocation(getX() + speed, getY()); } } }