2

I'm using a simple SKCropNode with a standard XCode Swift Game Template. Everything works fine in an emulator, but on a real iPhone 4S with iOS 8.3 I see just a green mask (although my shape is red) - no texture sprite is being displayed. The funny thing is that on iPhone 5S with iOS 9 everything works fine too. So the problem is with iPhone 4S or iOS 8.3

Here's a Screenshot of a problem I've could update my device to iOS 9, but I was thinking about supporting iOS 8 users too. Is that fixable, or is that an Apple bug?

Here's the code to reproduce, it's based on a standard SpriteKit Game Template from XCode:

    let center = CGPoint(x: self.frame.width*0.5, y: self.frame.height*0.5)

    let sprite = SKSpriteNode(imageNamed:"Spaceship")
    sprite.position = center

    let mask = SKShapeNode(rectOfSize: CGSize(width: 200, height: 200))
    mask.fillColor = SKColor.redColor()
    mask.position = center

    let crop = SKCropNode()
    crop.maskNode = mask
    crop.addChild(sprite)

    self.addChild(crop)
  • Even if picture describes well enough what is happening, it would be better if you update your question with the code which can reproduce what you are saying. – Whirlwind Jan 29 '16 at 23:12
  • Sure. Added the code. – Victor Naumik Jan 30 '16 at 20:48
  • In this case you don't need SKShapeNode as a mask. You can use SKSpriteNode. It will work like that. If you need a custom shape as a mask, try to create a texture from a SKShapeNode, and initialize a SKSpriteNode with it... – Whirlwind Jan 30 '16 at 21:01
  • That's a simplified bug scenario code. In real application I'm generating many custom shapes dynamically and applying a stone texture on each of them via CropNode mask (which is displayed on the device as plain green color). – Victor Naumik Jan 30 '16 at 21:08
  • Okay. So, as I said, create a SKShapeNode from path, convert it to a texture with SKView's [textureFromNode](https://developer.apple.com/library/prerelease/ios/documentation/SpriteKit/Reference/SKView/index.html#//apple_ref/occ/instm/SKView/textureFromNode:) method, and use SKSpriteNode initialized with that texture as a mask. – Whirlwind Jan 30 '16 at 21:12

0 Answers0