Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

[please help :O] how do i get the objects a sprite is currently colliding with?


psyconiak
 Share

Recommended Posts

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

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 ! :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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