Sign in to follow this  

Arcade overlap capture all sprite?

Recommended Posts

I wish to capture more that one "person" sprites using the arcade overlap method but could only return the latest sprite which is "person3" instead of "person0", "person1", "person2", "person3"? How do I capture all?

for(var i=0;i<4;i++){person = game.add.sprite(500, 140+(i*20), 'pSprite');"person"+iperson.enableBody = true;person.physicsBodyType = Phaser.Physics.ARCADE;game.physics.enable(person, Phaser.Physics.ARCADE);}robot = game.add.sprite(520, 200, 'robot');robot.enableBody = true;game.physics.enable(robot, Phaser.Physics.ARCADE);setTimeout(function(){game.physics.arcade.overlap(robot, person, HitsButton, null, this);}, 3000);function HitsButton(a,{console.log("hits",}

Share this post

Link to post
Share on other sites

Put all your people in a group and check for overlap against the group. Arcade will walk the group and test for overlap on all of them separately.



Put sprites and images into a group, that's really works! Thanks!

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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.