Created
September 7, 2016 12:39
-
-
Save patrickgill/4004fd0324117394e53e4824d8449552 to your computer and use it in GitHub Desktop.
Simulating physics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you do not want to create your own shapes, you can use SpriteKit to create a shape for you based on the sprite’s texture. | |
//objc | |
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"Spaceship"]; | |
sprite.physicsBody = [SKPhysicsBody bodyWithTexture:sprite.texture size:sprite.texture.size]; | |
//swift | |
let sprite = SKSpriteNode(imageNamed:"Spaceship") | |
sprite.physicsBody = SKPhysicsBody(texture: sprite.texture!, size: sprite.size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment