When I get the Hero to the 'exit' point of the map - how do I get it to read the next portion of the map?


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | private void moveMap() { CreateMap C = (CreateMap)getWorld(); if (C.MapLevel == 0 && getX() >= 200 && getY() <= 0 ) { C.MapLevel = (C.MapLevel+ 1 ); Greenfoot.setWorld( new CreateMap(C.MapLevel)); } else if (C.MapLevel == 1 && getX() >= 211 && getY() >= 328 ) { C.MapLevel = (C.MapLevel- 1 ); Greenfoot.setWorld( new CreateMap(C.MapLevel)); } } |
1 2 3 4 5 6 7 8 9 10 11 12 | public void addMapSpecificObjects() { Hero = new Hero(); if (MapLevel == 0 ) { addObject(Hero, 206 , 87 ); } if (MapLevel == 2 ) { addObject(Hero, 211 , 312 ); } } |
1 2 3 | CreateMap C2 = new CreateMap(C.MapLevel); // gets reference to new world C2.Hero.setLocation( /* wherever */ ); // relocates hero in new world Greenfoot.setWorld(C2); // sets new world active |