Sign in to follow this  
veggis

body touching callback?

Recommended Posts

I have a class that extends phaser.sprite, and in update i want to do something to the object that its body is touching.

Is there a way to get the sprite/object from body.touching?

.. If that makes sense.

Share this post


Link to post
Share on other sites

I'm pretty sure 

body.touching

never cares to check to see what it's touching.  

In order to do this, you'll probably want to add all the sprites that you want to affect by touching to a group, then call 

game.physics.arcade.collide(sprite, group, function(sprite, collidedSpriteFromGroup) {
  //affect collidedSpriteFromGroup here
});

inside your update loop.

This example uses overlap instead of collide, but it's effectively the same thing:
http://phaser.io/examples/v2/arcade-physics/custom-sprite-vs-group

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.