So, i searched about it and i’m pausing a game with FP.world.active = false, saving the world on a variable of world type, but i cant resume it…
Any ideas?
So, i searched about it and i’m pausing a game with FP.world.active = false, saving the world on a variable of world type, but i cant resume it…
Any ideas?
A simple way to pause the game is to skip the world’s update while the game is paused.
public class PauseWorld extends World
{
private var _paused:Boolean = false;
override public function update():void
{
if (_paused)
{
// When paused, only check to see if the player unpaused the game.
if (Input.pressed(Key.P))
{
_paused = false;
}
}
else
{
// Check to see if the user paused the game.
if (Input.pressed(Key.P))
{
_paused = true;
}
else
{
// If unpaused, perform game updates.
}
super.update();
}
}
}
Ok, i’ll give it a try… So the thing is, bind i var to decide if it is paused or not…but it’s with buttons, i’ll figure it out…
Only another question, there’s any way to store a world on a var and restore it?
Ok, i tried what you said, it kinda works, but some entities that’s not created on this class, like a bullet that is created by another class continues to update. There’s no other way?
You’ve gotta’ make sure to not call super.update()
when paused, or else your world will still call update on your entities.
Ok, i got my error, i had to make the variable paused global and verify if it was true in every entity on the game, like the hero, the enemies… but it worked, thanks!
I’ve tried that, but the world would always be kinda weird once I brought it back.