Sorry what do you mean by fields in my world class and by area I am trying to access the score, do you mean the method I want to use it in?
Sorry about this and thanks for persevering.


1 2 3 4 | if (score == 10 ) { addObject( new Square2, 0 , 0 ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | public class mainWorld extends World { Score score = new Score(); public mainWorld() { super ( 256 , 512 , 1 ); setBackground( "Background.png" ); Greenfoot.setWorld( new mainMenu()); if (score == 10 ) { addObject( new Square2(), 0 , 0 ); } displayUser(); displayDefault(); displayScore(); getScore(); } public void displayUser() { User userMain = new User(); addObject(userMain, 128 , 48 ); } public void displayDefault() { int randomXe1 = Greenfoot.getRandomNumber( 256 ); int randomXe2 = Greenfoot.getRandomNumber( 256 ); int randomXe3 = Greenfoot.getRandomNumber( 256 ); addObject( new Rectangle(), randomXe1, 512 ); addObject( new Rectangle2(), randomXe2, 512 ); addObject( new Square(), randomXe3, 512 ); } public void displayScore() { score = new Score(); addObject(score, 128 , 505 ); } public Score getScore() { return score; } } |