Jump to content

On Collision go to URL possible?


Recommended Posts

Hello! First time posting and I've got a question (2 actually).


1)  I'm in the process of making my first game and when you reach an object, I want to launch a URL for score submission & time.  Is it possible? (I think it is, just not sure how to accomplish it.)


2)  I've got a timer countdown and if you run out of time before you get to colide with the end object I want a couple text boxes to come up you can click on (Try Again) & (Submit).


Thanks in advance for the help!


Link to comment
Share on other sites

Ok, I've got my finish object preloaded:


game.load.image('finish', 'assets/finish.png');



Called as a variable   

var finish;



Made a group and gave it physics


          //  The Finish Line collision group
        finish = game.add.group();

         //  We will enable physics for finish image
        finish.enableBody = true;

       //  Create the finish object inside of the 'finish' group
            var finish = finish.create(1000, 300, 'finish');


Update it to see if our dude collides with it.


    //  Checks to see if the player overlaps with the finish image, if he does call the finish function
    game.physics.arcade.overlap(player, finish, gameFinish, null, this);


Have it do something when they collide

function gameFinish (player, finish) {
    // Removes the star from the screen
    //  Finish Game and Submit Score
    window.location.href = "http://URL.com";



It's in the game, just isn't removing the finish object or executing the URL.  Yes, I've changed it to an actual URL.  Any help on what I'm missing?  Is it syntax?


Thanks again.

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...