3

I want to present SCNScene with SKTransition.fadeWithColor. It works good with standart colors like UIColor.greenColor(), but id does not work with color made with patternImage. Transition in this case is just transparent. Here is the code:

 guard let patternImage = UIImage(named: "pattern") else {return}
 let patternColor = UIColor(patternImage: patternImage)
 scnView.presentScene(scene, withTransition: SKTransition.fadeWithColor(patternColor, duration: 1), incomingPointOfView: nil) {
  ...
 }

Same color is used to fill the background of view and it works like a charm, but not with transition. So the questions are:

  • Why color becomes transparent during transition?
  • Is there a way to make it work with such a color?
  • If no - what is the alternative solution for making fade-like or dissolve-like transition (scene1 -> Image -> scene2)?

Thanks in advance!

Yurii Koval
  • 419
  • 5
  • 16
  • Is the image you are using just a color, for example, a green rectangle? – sicvayne Jun 14 '17 at 13:36
  • I use png image and it contains "real picture" inside. Note that it works for filling UIView's background. – Yurii Koval Jun 14 '17 at 13:47
  • It wont work because that certain transition creates a transition that first fades to a constant color and then fades to the new scene.So by my understanding it will only work with colors. Have you tried using crossfade.with duration instead? Might get the same effect you're looking for. – sicvayne Jun 14 '17 at 13:59
  • I tried, but in this case transition is Scene1->Scene2, and I need Scene1->Image->Scene2, that is why I want to "replace" color with image. – Yurii Koval Jun 14 '17 at 14:11
  • I get you now. Only thing that comes to mind would be to animate you "background image" in a way that it fades out and immediately transition to scene 2, if that makes sense. – sicvayne Jun 14 '17 at 14:48
  • You can add the image to both old scene and new scene as an SKSpriteNode, and have the scene continue to run while transitioning. Apply whatever affects you need to these SKSpriteNodes to achieve your result – Knight0fDragon Jun 15 '17 at 19:14

0 Answers0