Impl. clearing and pushing trunnerscreen from js
This commit is contained in:
parent
6cbc044251
commit
fb7b651303
4 changed files with 19 additions and 2 deletions
|
@ -23,3 +23,8 @@ void Game::update() {
|
|||
void Game::draw() { screen_stack->draw(); }
|
||||
|
||||
void Game::clear_screens() { screen_stack->clear_screens(); }
|
||||
|
||||
void Game::clear_and_push_trunner() {
|
||||
screen_stack->clear_screens();
|
||||
screen_stack->push_constructing_screen<TRunnerScreen>();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class Game {
|
|||
void draw();
|
||||
|
||||
void clear_screens();
|
||||
void clear_and_push_trunner();
|
||||
|
||||
private:
|
||||
ScreenStack::Ptr screen_stack;
|
||||
|
|
10
src/main.cc
10
src/main.cc
|
@ -16,7 +16,7 @@
|
|||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
||||
extern Game *global_game_ptr = nullptr;
|
||||
extern Game *global_game_ptr;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -37,6 +37,14 @@ int EMSCRIPTEN_KEEPALIVE clear_all_screens() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int EMSCRIPTEN_KEEPALIVE clear_and_push_trunner() {
|
||||
if (global_game_ptr) {
|
||||
global_game_ptr->clear_and_push_trunner();
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -60,7 +60,10 @@
|
|||
console.log("onerror: " + event);
|
||||
};
|
||||
function demo0_clear_all_screens() {
|
||||
Module.ccall('clear_all_screens', 'number', [], []);
|
||||
return Module.ccall('clear_all_screens', 'number', [], []);
|
||||
};
|
||||
function demo0_clear_and_push_trunner() {
|
||||
return Module.ccall('clear_and_push_trunner', 'number', [], []);
|
||||
};
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
|
|
Loading…
Reference in a new issue