Jump to content

Embedding a Hyperlink


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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