Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Adam Smith
Adam Smith
2,437 Points

SWIFT: Physics bodies for irregular shapes in spritekit

I am creating an IOS app that requires me to create a physics body around a sprite node. this sprite node is not a regular polygon. how would I go about creating an irregular shaped physics body around this spritenode

1 Answer

Reed Carson
Reed Carson
8,306 Points

you can set your physicsbody to be equal to the texture provided. something like this:

physicsBody = SKPhysicsBody(texture: SKTexture, size: CGSize)