Jump to content

Embedding a Hyperlink


Vithar
 Share

Recommended Posts

Something like this:

button = game.add.button(game.world.centerX, game.world.centerY, 'button', function() {  // open in the same window (like clicking a link)  window.location.href = "http://www.google.com";  // open in a new window instead (this will likely be blocked by popup blockers though)  // window.open("http://www.google.com", "_blank");}, this);
Link to comment
Share on other sites

  • 11 months later...

I did in this way, it seems to work but i am not sure if its the way to do.

added working version :http://www.oyuntt.com/hayvan-bulmaca-hayvanciklari-kurtar/oyna/

create: function () {if (this.game.device.desktop || this.game.device.android ) {var gp = this.add.button(0, this.game.height- this.game.height / 3 , 'googleplayimg', this.openga, this, 1, 0);gp.anchor.setTo(0, 0.5);}}openga : function(){if (this.game.device.desktop ) {window.open("https://play.google.com/store/apps/details?id=com.vohogames.animalpuzzle", "_blank");}else{window.open("market://details?id=com.vohogames.animalpuzzle","_blank");}}
Link to comment
Share on other sites

  • 9 months later...

If your game permits it, you could save the state of the game before changing window location and then reload the game when/if the user returns. You may be doing this already.

You'd probably do this via local storage of some sort and then reload the game from server (if necessary) based on those local stored variables. Given that you have control over the url you could also use query parameters to have some control over the users' actions i.e. in pseudo-code

// Generate secret key, related to saved game state
// Pass secret key to external link
//   http://externallink.com?KEY=xxx
// Use query param in embedded link so that
//   http://yourgame.com?KEY=xxx
// Use query param in game to load the state associated with the key

Of course, you can't force anyone to come back to your game, might be a better solution to host the page in an iframe inside your game, that way you have a course for dialogue using emitters between parent and child windows, similar to websocket or web worker dialogue.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...