Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 797
Rishi Pochiraju Avatar asked Jun 26 '17 01:06

Rishi Pochiraju


1 Answers

UPDATE: Just figured it out.

let presetTexture = SKTexture(imageNamed: "YOURIMAGE.png")
presetObject = SKSpriteNode(texture: presetTexture)
presetObject.physicsBody = SKPhysicsBody(texture: presetTexture, size: presetTexture.size())
like image 67
Rishi Pochiraju Avatar answered Nov 15 '22 03:11

Rishi Pochiraju