WaitForSecondsRealtime
Namespace:
namespace Lenga\Engine\Core;
class WaitForSecondsRealtime
Methods
getDuration
public function getDuration()
keepWaiting
public function keepWaiting()
Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\WaitForSecondsRealtime;
class PauseInsensitiveTimer extends Behaviour
{
public function start(): void
{
$this->startCoroutine($this->timedAction());
}
private function timedAction(): \Generator
{
Debug::log('Action starts now');
// Wait 2 real seconds, even if game is paused
yield new WaitForSecondsRealtime(2.0);
Debug::log('2 real seconds have passed, regardless of pause state');
}
}