Sprite Kit Particle Emitter Shape - ios

How can a particle emitter be set to produce shapes (solid shapes/Core Graphics?), instead of texture images (png)?
In the documentation Manipulating the Particle Emitter, it looks like only a texture image can be set.

Only a SKTexture can be used, but that doesn't stop you from using SKShapeNode to create shapes and then create a SKTexture of that shape via the SKView method textureFromNode:.

Related

How to mask a mesh with cube mesh in sceneKit?

I'd like to mask model with cube. I have 2 SCNNode in scene: a cube and a GameModel, they have some part intersection. how can I do mask effect with cube? some kind of sceneKit shader modifie I guess?

Converting SKSpriteNode into SKShapeNode

I'm working in Swift 3.1. I want to create a shadow for a SKSpriteNode. I'm thinking of doing a SKShapeNode from my SKSpriteNode and giving it some glow and alpha.
But how can I convert SKSpriteNode into SKShapeNode?
If your plan is to make a shadow that looks like your sprite, then using another SpriteNode instead would be advisable. SKShapeNodes have poor performance and the process of converting the sprite into a vector shape will be processing heavy.
You should have read about SKEffectNode because you could use them to create a SpriteNode with your current texture and apply some effects on it to turn your texture black, blured ans maybe even use affine transformation to distort and rotate the texture so it looks like a shadow.
To make things more GPU/CPU efficient in the case where you have many shadows, you could simply put all the shadow sprites as child of a single SKEffectNode that will apply the effects on every shadow sprite all at once. I assume that positionning the shadow under the main sprite would not be a challenge for you.
Having the shadow as a child of the main sprite would force you to put an effect node for every sprite casting a shadow, and would cause the effects to be processed over and over. By putting every shadow as a child of the same node, they will get rendered all at once and the effect will be processed only once every frame.
I hope it helps!
SKShapeNode's are known to have poor performance in SpriteKit. Instead, you should add another SKSpriteNode for the shadow, and add it as a child to the main SKSpriteNode.
If you want the shadow to appear below its parent, you may have to adjust it's relative z-position as well.

How to using SKEmitterNode effect to drawing like SKShapeNode does?

I want to make a drawing app by using SKEmitterNode effect.
I know that SKShapeNode are used to stroke or fill a CGPath and I can use SKShapeNode to do it,
But what I want is using SKEmitterNode effect like following images to do the same work.
Is it possible ?
Yes, and this is a very good use of SKEmitterNodes.
First, you'll need to use Additive blend mode on your particles to get this effect.
And you should then set the pace (motion) of the particles to 0 in all directions, and not have them impacted by gravity. When they're emitted, they should be stationary.
The particle emitter should move with the touch of the artist/user, and emit at a rate slightly inverse to the rate of change in position of the emitter.

iOS: How I can make edges of sprite smooth when it is rotated?

I am making a simple sprite kit game. When I rotate my sprite the edges are jagged. I try texture images and image assets but the results are all the same.
Here is my code with filtering mode:
let sprite = SKSpriteNode(imagedNamed: "textureName")
sprite.texture!.filteringMode = SKTextureFilteringMode.Nearest // Also Try .Linear
Changing the sprite's size to its original value or a smaller scale, result does not change.
Is it possible to use antialiased property for sprite nodes ?
Is there any suggestion? Similar problem on this link:
Make edges of SKSpriteNode look smooth after rotation

How to add lighting effect in SKShapeNode

I am using SpriteKit, does SKLightNode can only work with SKSpriteNode? because there is no shadowCastBitMask property on SKShapeNode, I cannot make SKLightNode work with SKShapeNode. Is there a way can make them work together? Thanks!
SKShapeNode does not have lighting properties like SKSpriteNode. If you create a SKShapeNode you can make it disappear into a shadow but you cannot make it cast a shadow or set any other lighting properties.

Resources