I have sprite node over all screen, but images are only somewhere, not over all screen. How to set touch only on non transparent images or how to delete transparent pixels or something... Maybe use physicsBody? Thanks for help!
node = SKSpriteNode()
node.texture = SKTexture(imageNamed: "yes.png")
node.name = "yes"
node.size = self.frame.size
node.position = CGPoint(x: 0, y: node.size.height)
node.zPosition = 3
self.addChild(node)
Without seeing your picture it's quite hard to give you a clear answer other than what I assume your issue looks like.
You can use SKPhysicsBody to solve your issue by doing this.
let texture = SKTexture(imageNamed: "yes.png")
let node = SKSpriteNode(texture: texture)
node.name = "yes"
node.size = self.frame.size
node.position = CGPoint(x: 0, y: node.size.height)
node.zPosition = 3
node.physicsBody = SKPhysicsBody(texture: texture, size: texture.size())
self.addChild(node)
You will need to configure your physics body as well in order to get the correct collision behaviour.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.