psyconiak Posted August 17, 2015 Share Posted August 17, 2015 hi, i am trying to make a platform game.I am currently working on my enemies and i would like them to walk up and down the platform they are currently on. therefore my first thought was to get the object the sprite is currently colliding with, get its length and make the guy walk that far, so he walks the length of the platform and doesnt fall off. But my platforms are all part of a group and the collision detects if the sprite is colliding with a group member. How can i get the object the sprite is currently colliding with, so i can get its length?? i'm also open for different techniques to achive the same thing!Thanks for your help, i really need it Link to comment Share on other sites More sharing options...
drhayes Posted August 18, 2015 Share Posted August 18, 2015 Here's the signature for Arcade#collide:collide(object1, object2, collideCallback, processCallback, callbackContext)Your collideCallback will receive the two objects that are colliding, even if you called it with a group. in mono and psyconiak 2 Link to comment Share on other sites More sharing options...
psyconiak Posted August 20, 2015 Author Share Posted August 20, 2015 my code looks like this: this.game.physics.arcade.collide(skeleton.sprite, platforms, function(){ //if i'd type "platforms.length" here it wouldn't give me the one platforms length right? //so how do i access the single platform instead of the whole group right here?}); Edit: Ohhhhh now i got it: this.game.physics.arcade.collide(skeleton.sprite, platforms, function(skeleton, singlePlatform){ singlePlatform.width; // Thats how it works }); thank you very much mate ! in mono and drhayes 2 Link to comment Share on other sites More sharing options...
Recommended Posts