Again, you cannot refer to the current world by creating a new one. Similar situation as above.
public class MyWorld extends TK2934World { Robot robot; public MyWorld() { super(750, 580); displayTimer(); resetTimer(300); startTimer(); MoveRightTile r = new MoveRightTile(); addObject(r,500,300); MoveLeftTile l = new MoveLeftTile(); addObject(l,400,300); robot = new Robot(); addObject(robot,50,100); robot.setMoving(false); } public void world_act() { if(timesUp()) { displayMessage("Time's Up",Color.red); } } public void moveRobot() { robot.setMoving(true); } }
public class MyWorld extends TK2934World { Robot robot; public MyWorld() { super(750, 580); displayTimer(); resetTimer(300); startTimer(); MoveRightTile r = new MoveRightTile(); addObject(r,500,300); MoveLeftTile l = new MoveLeftTile(); addObject(l,400,300); robot = new Robot(); addObject(robot,50,100); robot.setMoving(false); } public void world_act() { if(timesUp()) { displayMessage("Time's Up",Color.red); } } public void moveRobot() { robot.setMoving(true); } }
public void moveRobot(MoveRightTile tile) { robot.setMoving(true); }
public class MoveRightTile extends Tile { /** * Act - do whatever the MoveRightTile wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public MoveRightTile() { } public void clickedAct() { Tile tile; MyWorld my = (MyWorld)getWorld(); my.moveRobot(this); } now i want ot add lefttile in Tile,and will control the robot move left and right }