Jump to content

On Collision go to URL possible?


Chris_Hawkins
 Share

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!

Chris

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.kill();
 
    //  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

This is possibly the issue:

  var finish = finish.create(1000, 300, 'finish');

You're assigning both the sprite and the group it's in to 'finish'; it can only be one or the other. Change it to the following and see if it works:

  var finishSprite = finish.create(1000, 300, 'finish');
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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