newDeveloper Posted January 4, 2016 Share Posted January 4, 2016 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.input.enableDrag(true); tempTwo.body.collideWorldBounds = true; } //add number buckets bucketTwo = game.add.sprite(500, 400, 'numberTwo'); bucketTwo.scale.setTo(2,2); game.physics.arcade.enable(bucketTwo);}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){ MY MISSING PIECE } function twoCollision(bucket, number){ console.log("collideit?"); number.kill(); } Link to comment Share on other sites More sharing options...
Recommended Posts