Impl. clearing and pushing trunnerscreen from js
Some checks failed
Build and Publish WASM version of demo / Build-And-Deploy-main (push) Has been skipped
Build and Publish WASM version of demo / Build-And-Deploy-devel (push) Failing after 16s

This commit is contained in:
Stephen Seo 2023-08-31 22:17:19 +09:00
parent 6cbc044251
commit fb7b651303
4 changed files with 19 additions and 2 deletions

View file

@ -23,3 +23,8 @@ void Game::update() {
void Game::draw() { screen_stack->draw(); } void Game::draw() { screen_stack->draw(); }
void Game::clear_screens() { screen_stack->clear_screens(); } void Game::clear_screens() { screen_stack->clear_screens(); }
void Game::clear_and_push_trunner() {
screen_stack->clear_screens();
screen_stack->push_constructing_screen<TRunnerScreen>();
}

View file

@ -23,6 +23,7 @@ class Game {
void draw(); void draw();
void clear_screens(); void clear_screens();
void clear_and_push_trunner();
private: private:
ScreenStack::Ptr screen_stack; ScreenStack::Ptr screen_stack;

View file

@ -16,7 +16,7 @@
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
extern Game *global_game_ptr = nullptr; extern Game *global_game_ptr;
extern "C" { extern "C" {
@ -37,6 +37,14 @@ int EMSCRIPTEN_KEEPALIVE clear_all_screens() {
return 1; 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" } // extern "C"
#endif #endif

View file

@ -60,7 +60,10 @@
console.log("onerror: " + event); console.log("onerror: " + event);
}; };
function demo0_clear_all_screens() { 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>
{{{ SCRIPT }}} {{{ SCRIPT }}}