i have class player and i have class book, i want if player take a book then game paused, if i press any key game run again..
can you help me, how i make game pause like above?


1 | private int pause = 0 ; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public void act() { if (pause == 1 ) { if (Greenfoot.isKeyDown( "p" ); { pause = 0 ; } } else if (pause == 0 ) { if ( /* find book boolean */ ) { pause = 1 ; } //add your other act stuff } } |
1 2 3 4 5 | if (!hasPaused && ! "" .equals(takenBook)) { hasPaused = true ; setWorld( new BookWorld(takenBook, nameOfWorld)) } |