Skip to content

Instantly share code, notes, and snippets.

@patrickgill
Created September 7, 2016 12:39
Show Gist options
  • Save patrickgill/4004fd0324117394e53e4824d8449552 to your computer and use it in GitHub Desktop.
Save patrickgill/4004fd0324117394e53e4824d8449552 to your computer and use it in GitHub Desktop.
Simulating physics
// 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