I am trying to set an actors rotation when it is added to the world to the same rotation as another actor.
Whatever I do, it doesn't work (the rotation doesn't change)
Please help
The world is called Background, and the 2 actors are called Corridor and Tile. I want to set the Tile actor to the same rotation as the Corridor actor.
The code in the World is:
The code in the Corridor is:
And the code in the tile is:
Sorry if this is formated badly, i'm new to this stuff. Thanks
int tileSize = 50; private Tile theTile; public Background() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(1000, 800, 1); theTile = new Tile(); prepare(); } public Tile getTile() { return theTile; }
public void drawMaze() { int randomRotation = 90*Greenfoot.getRandomNumber(4); setRotation(randomRotation); Tile tile = new Tile(); getWorld().addObject(tile, getX(), getY()); Background background = (Background)getWorld(); Tile tileDIR = background.getTile(); int currentRotation = getRotation(); tileDIR.copyRotation(currentRotation); int tileSize = ((Background)getWorld()).returnTileSize(); move(tileSize); }
public void copyRotation(int corridorRotation) { setRotation(corridorRotation); }