---
title: "init(texture:size:)"
framework: spritekit
role: symbol
role_heading: Initializer
path: "spritekit/skphysicsbody/init(texture:size:)"
---

# init(texture:size:)

Creates a physics body from the contents of a texture.

## Declaration

```swift
init(texture: SKTexture, size: CGSize)
```

## Parameters

- `texture`: The texture to convert into a physics body.
- `size`: The size of the physics body to return.

## Return Value

Return Value A new volume-based physics body.

## Discussion

Discussion Use this method when your sprite has a shape that you want replicated in its physics body. The texture is scaled to the new size and then analyzed. A new physics body is created that includes all of the texels in the texture that have a nonzero alpha value. The shape of this body attempts to strike a good balance between performance and accuracy. For example, fine details may be ignored if keeping them would cause a significant performance penalty.

## See Also

### Creating a Body from a Texture

- [Shaping a Physics Body to Match a Node’s Graphics](spritekit/shaping-a-physics-body-to-match-a-node-s-graphics.md)
- [init(texture:alphaThreshold:size:)](spritekit/skphysicsbody/init(texture:alphathreshold:size:).md)
