Rishi Pochiraju
Rishi Pochiraju

Reputation: 165

iOS: How to set programmatic alpha mask of SKSpriteNode

I am able to set the alpha mask of my own custom object in the .sks file of the project, but I'm not sure how to do it programmatically.

Upvotes: 6

Views: 1472

Answers (1)

Rishi Pochiraju
Rishi Pochiraju

Reputation: 165

UPDATE: Just figured it out.

let presetTexture = SKTexture(imageNamed: "YOURIMAGE.png")
presetObject = SKSpriteNode(texture: presetTexture)
presetObject.physicsBody = SKPhysicsBody(texture: presetTexture, size: presetTexture.size())

Upvotes: 6

Related Questions