Jump to content

can i make a button collide with a sprite in phaser?


Anshu
 Share

Recommended Posts

HI Guys,

 

Need a help. How can I make a button collidable object?

 

I am using a group of buttons each having a different label. when a bullet hits any button i want to extract that label of that particular button.

 

 

    var bullets;

    bullets = game.add.group();
    bullets.enableBody = true;
    bullets.physicsBodyType = Phaser.Physics.ARCADE;
   game.physics.enable(bullets, Phaser.Physics.ARCADE);
    var button = game.add.button(100, 400, 'button');
 
     game.physics.enable(button, Phaser.Physics.ARCADE);
 
 
     game.physics.arcade.collide(bullets, button, collisionHandler, null, this);
 
function collisionHandler (bullet, button) {
    button.kill();
bullet.kill();

}

 

But my bullet is not colliding with the button. Please help!!!!!

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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