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

[P2] Physics with sprite groups


literky
 Share

Recommended Posts

Hello!

 

I'm still beginner in game programming, and I have headache right now because of physics with sprite groups.

 

I know how to make sprite with P2 physics, and how to make them kinematic. But what I'm trying right now is to make group with same settings, and after couple of hours today, couple of tutorials I have no idea how to make it proper way.

grounds = this.add.group(); // Create a group  grounds.enableBody = true;grounds.physicsBodyType = Phaser.Physics.ARCADE; grounds.kinematic = true;

This code don't collide with player (arcade/p2js)

grounds = this.add.group(); // Create a group  grounds.enableBody = true;grounds.physicsBodyType = Phaser.Physics.P2JS;grounds.kinematic = true;

This could collide, but "grounds" aren't kinematic.

 

Can someone help me? I have no idea.

 

Link to comment
Share on other sites

Phaser.Groups don't have physics bodies themselves, think of them as just being like buckets full of sprites. It's the sprites that have the physics bodies and properties. So if you want to make a Group and fill it with kinematic bodies, you can use some of the Group methods like "setAll" to do this, or just a normal 'for loop', creating sprites, setting their body and adding them into the Group.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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