Closed jedeen closed 7 years ago
If you implement your game UI as all HTML this also works really well, since if the game is stopped no updates/processing will happen but HTML will work fine.
Can I take this ?
@SurajGoel For sure! Please do, let us know if you need any assisstance :)
@eonarheim Sorry, didn't see your post. On it now, will update you soon.
@eonarheim How should I write a unit test for this ? A simple idea :- Maybe run the engine first, check the status, stop the engine, check the status again. And should I put the test in Utility Functions test suite ?
@SurajGoel Sounds like a good way to do it! You'll probably want to test that it can be un-paused as well.
This is Engine
functionality, so I'd recommend putting the test in EngineSpec.ts
Now that I'm thinking about it, this is more of a test of the Engine.start()
and Engine.stop()
methods. @excaliburjs/core-contributors, what do you think?
Context
Currently, you can stop/start (i.e. pause/resume) a game with
Engine.start()
andEngine.stop()
. However, in order to implement pause logic, you need to manage your own boolean:Proposal
The
Engine
already has a private_hasStarted
variable that appears to be maintaining, but not exposing, this status.It would be helpful to have an
isStopped()
orisPaused()
method to return the current state of the game, so the above code could be simplified to: