Julia Posted November 10, 2014 Share Posted November 10, 2014 Hey, First of all I would like to thank you for the great support, learning a lot here from a great framework I have another question: Is it possible to check for an overlap between two sprites (in this case a sprite and a child from a group) in an if statement? This is in my update function:game.physics.arcade.overlap(player, enemyGroup, this.collisionHandler, null, this);And this in my collisionHandler:if(game.physics.arcade.overlap(player, enemyGroup.children[0])) {this.vow1();} Link to comment Share on other sites More sharing options...
Julia Posted November 10, 2014 Author Share Posted November 10, 2014 Wooops, posted the question a bit too often. How can I delete questions? Link to comment Share on other sites More sharing options...
Skeptron Posted November 10, 2014 Share Posted November 10, 2014 Hmmm sorry but I don't understand the question... What is wrong with your code? I mean it seems to perfectly answer to your issue... And I think objects need a body for the overlap method to work, so you may have to apply physics to both objects. And I'm bot sure about this but you may also want to check for collisions after your objects are updated in your update loop. Edit : Why don't you just write :game.physics.arcade.overlap(player, enemyGroup.children[0], this.callbackFn, null, this);And avoir the second overlap check? Link to comment Share on other sites More sharing options...
Julia Posted November 10, 2014 Author Share Posted November 10, 2014 Thanks for your answer! I guess the error should be in the vow1 function then... But you say it is possible to check for an overlap in an if statement like this?I already have physics applied to the objects. Link to comment Share on other sites More sharing options...
Skeptron Posted November 10, 2014 Share Posted November 10, 2014 I think it should work... The intersects() method is also interesting in that case. Do not hesitate to provide a small demo of your code if it's not working the way expected. Link to comment Share on other sites More sharing options...
Julia Posted November 10, 2014 Author Share Posted November 10, 2014 I guess the code is a bit too much to place a snippet. I put a console.log in the if statement, but it isn't firing at all, so something must be wrong in the if statement I guess? Link to comment Share on other sites More sharing options...
Skeptron Posted November 10, 2014 Share Posted November 10, 2014 Is your collisionHandler called at least? Link to comment Share on other sites More sharing options...
Julia Posted November 10, 2014 Author Share Posted November 10, 2014 Ah, thanks for your edit, it's working now!! Great! Link to comment Share on other sites More sharing options...
Skeptron Posted November 10, 2014 Share Posted November 10, 2014 Nice! I'm glad I could help! =) Julia 1 Link to comment Share on other sites More sharing options...
Recommended Posts