I have a single webpage that I want to be able to run three JavaScript games, sequentially. I start one with
//jQuery to start a game
$(document).ready(() => {
//When the logo image is clicked
$("#logo").click(() => {
//Get the archery game
$.getScript('archery.js', () => {
//Start it
startArchGame();
//Remove the image from the HTML doc
$("#logo").remove();
});
})
})
Then, inside archery.js
, once a condition is met, the following code is executed
$.getScript('skateboarding.js', () => {
startSkateGame();
});
game.destroy();
The game.destroy();
stops the game from running in Phaser 3, but the next game is just loaded below the first one, so you can't see it. How can I fix this? Is it possible to delete the first script I got entirely?
I have a single webpage that I want to be able to run three JavaScript games, sequentially. I start one with
//jQuery to start a game
$(document).ready(() => {
//When the logo image is clicked
$("#logo").click(() => {
//Get the archery game
$.getScript('archery.js', () => {
//Start it
startArchGame();
//Remove the image from the HTML doc
$("#logo").remove();
});
})
})
Then, inside archery.js
, once a condition is met, the following code is executed
$.getScript('skateboarding.js', () => {
startSkateGame();
});
game.destroy();
The game.destroy();
stops the game from running in Phaser 3, but the next game is just loaded below the first one, so you can't see it. How can I fix this? Is it possible to delete the first script I got entirely?
- is there an example that you demonstrate the issue? – Nidhin Joseph Commented Dec 23, 2019 at 0:08
- @NidhinJoseph would a GitHub repo work for you? – Robert Smith Commented Dec 23, 2019 at 0:09
- yes, share the link please – Nidhin Joseph Commented Dec 23, 2019 at 0:11
- @NidhinJoseph github./roberto257/Olympic-Games – Robert Smith Commented Dec 23, 2019 at 0:14
- @RobertSmith have you found an answer to this issue? – Manuel Abascal Commented Dec 31, 2019 at 1:41
1 Answer
Reset to default 8I was able to solve this issue within the Phaser framework.
I changed game.destroy()
to game.destroy(true, false)
.
The first argument of the destroy method, true
, says that I want to remove the game from the canvas element of the page when I destroy the game. The second argument, false
, says to NOT remove all of Phaser and its plugins for the page. I set this to false because I want to create another game in Phaser on the page after I destroy my first one.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744810530a4595031.html
评论列表(0条)