07-03-2013, 09:33 AM
Guest
07-03-2013, 11:51 AM
Try putting this at the end of the
tag in the game's HTML page:
<pre>
</pre>
Does this work?
Code:
<body>
<pre>
Code:
<script>
game.interpreter.bus.subscribe(function () {
location.href = "http://example.com/foo/bar/";
}, "wse.interpreter.end");
</script>
Does this work?
Guest
07-03-2013, 12:32 PM
I tried it, but I got this error in Chrome's debug console:
Uncaught ReferenceError: game is not defined
I tried putting that inside the function that starts the game and got:
Uncaught TypeError: Cannot call method 'subscribe' of undefined
It's no big deal really. I'll just end the last line of the dialogue with a link to the credits page.
Uncaught ReferenceError: game is not defined
I tried putting that inside the function that starts the game and got:
Uncaught TypeError: Cannot call method 'subscribe' of undefined
It's no big deal really. I'll just end the last line of the dialogue with a link to the credits page.
Guest
07-03-2013, 12:44 PM
There are basically two index.html files in use, one where the game object is global and one where it isn't. So you were right with putting the code into the function.
As for the second error: I guess the bus is not yet loaded at that point. Try it with
game.bus.subscribe(...
instead.
As for the second error: I guess the bus is not yet loaded at that point. Try it with
game.bus.subscribe(...
instead.
Guest
07-03-2013, 12:52 PM
It works!!!
Thank you!
Thank you!
Guest
08-29-2013, 10:18 AM
Sorry to be a bother. I noticed that this code causes the page to redirect to the credits page, if the user clicks on the screen during loading of assets. any way to prevent that?
Here's what I'm using:
Here's what I'm using:
Code:
<script>
(function ()
{
var game = new WSE.Game({
url: "game.xml",
host: typeof HOST === "undefined" ? false : HOST
});
WSE.extensions.sideImages.inject(game);
if (location.href.match(/action=load/)) {
WSE.functions.savegames(game.interpreter);
}
game.bus.subscribe(function () {
location.href = "http://lalala.com/web/credits.html";
}, "wse.interpreter.end");
game.start();
}());
</script>
Guest
08-29-2013, 03:07 PM
I guess you could hook the subscribing to the end event to the assets.loading.finished event like this:
<pre>
</pre>
Does it work?
<pre>
Code:
<script>
(function ()
{
var game = new WSE.Game({
url: "game.xml",
host: typeof HOST === "undefined" ? false : HOST
});
WSE.extensions.sideImages.inject(game);
if (location.href.match(/action=load/)) {
WSE.functions.savegames(game.interpreter);
}
game.bus.subscribe(function () {
game.bus.subscribe(function () {
location.href = "http://example.com/web/credits.html";
}, "wse.interpreter.end");
}, "wse.assets.loading.finished");
game.start();
}());
</script>
Does it work?
Guest
08-29-2013, 04:07 PM
Thank you! Works great!