How can we apply particle effects to our project? In order to do that, we need to create a new
particle effects file. To do this, we need to navigate to the File menu and then to New
| New File. On the left-hand side table, click on Resource under the iOS section and
from the right-hand side of the screen, select SpriteKit Particle File, as shown in the
following screenshot:
On the next screen, you will be asked what preset type of particle effect you want to create. Pick a Rain type. Name it as "rain.sks".
After you have done that, two new files will appear in your project, rain.sks and spark.png. Click on the first one and you will see the particle effect in action,
then select SKNode Inspector on the right-hand side of the screen. Make sure the Utilities pane is visible on the right-hand side (the top-right icon in the Xcode
window). Next, click on the rightmost icon below the toolbar, which looks like a small cube. You will see Particle Editor, which is a built-in tool to customize
particle effects.
Then in code, you create an SKEmitterNode with the file, like this:
let rainEmitter = SKEmitterNode(fileNamed: "rain.sks")
rainEmitter.position = CGPoint(x: 100, y: 100)
addChild(rainEmitter)
Gopinath T B,
CEO, Meteora Gaming


Excellent article!
ReplyDeleteThanks Praveen :)
Delete