Game Development Reference
In-Depth Information
Next, let the same class implement the Disposable interface as follows:
public class WorldController extends InputAdapter
implements Disposable {
...
}
Then, add the following lines of code to the same class:
@Override
public void dispose () {
if (b2world != null) b2world.dispose();
}
Finally, make the following changes to the GameScreen class:
@Override
public void hide () {
worldController.dispose();
worldRenderer.dispose();
Gdx.input.setCatchBackKey(false);
}
Memory that is allocated by a Box2D's world instance is now going to be freed
correctly when it is no longer needed.
Now, run the game and finish the level by passing the goal to marvel at the awesome
rain of carrots. A screenshot of what you should see is as follows:
 
Search WWH ::




Custom Search