Jump to content

Phaser - Trying to have the sprites bounce off if they are not the same.


Recommended Posts

Hi, I am looking for some help with Phaser. I have a click and drag game with numbers. I have it set up to where the numbers that match get "killed", but I am trying to get when the user drags to the wrong bucket, they bounce off the bucket and it states try again. But I can not seem to get that to work. Any suggestions for function reject?

function create() {

  // Group Two
      numberTwoGroup = game.add.group();
      numberTwoGroup.enableBody = true;
        //  And add 4 sprites to it
      for (var i = 0; i < 4; i++)
      {//  Create a new sprite at a random world location
          var randomY = game.rnd.integerInRange(0, 370);
          var randomX = game.rnd.integerInRange(20, 750);
          var tempTwo = numberTwoGroup.create(randomX, randomY, 'numberTwo');
          tempTwo.inputEnabled = true;
          tempTwo.body.collideWorldBounds = true;
      //add number buckets
    bucketTwo = game.add.sprite(500, 400, 'numberTwo');
function update(){
     game.physics.arcade.overlap(numberTwoGroup, bucketTwo, twoCollision, null, this);
     if(game.physics.arcade.collide(numberTwoGroup, bucketThree, reject, null, this));
     if(game.physics.arcade.collide(numberTwoGroup, bucketSeven, reject, null, this));
    function reject(bucket, number){
 function twoCollision(bucket, number){


Link to comment
Share on other sites


  • Recently Browsing   0 members

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