How to add particle effects to an iOS App that is not a game using iOS 7 SpriteKit Particle?

后端 未结 7 1713
攒了一身酷
攒了一身酷 2020-12-07 10:48

I need to add a rain particle effect to my app, I have been having a tough time finding ways to actually execute this idea.

I tried following this CALayer approach

7条回答
  •  Happy的楠姐
    2020-12-07 11:11

    Putting this here for visibility reasons.

    The answers regarding the user of a .clear backgroundColor are correct, except that you must also set the allowsTransparency property on SKView to 'true'.

    skView.allowsTransparency = true
    skView.backgroundColor = .clear  // (not nil)
    scene.backgroundColor = .clear
    

    If you don't set allowsTransparency to true, and you layout your SKView over, say, a UIImageView, the composition engine will have a fit, and will send your GPU red-lining, even if only a single particle is drawn. (In the Simulator, the CPU will spike instead.)

提交回复
热议问题