# Spritekit water flowing [closed]

I'm wondering if there is a way in spritekit to implement water flowing through a path?

like this water flow

Right now I'm generating the path using UIBezierPath and PaintCode

Any suggestion?

Thanks.

## closed as too broad by bummzack, Anko, Kromster, Vaughan Hilts, Josh♦Apr 20 '15 at 15:24

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• From the description of the linked video: "During the last scene, one frame took 10 seconds to simulate and render." It sounds more like film vfx production than game development! Are you really sure a simpler water model is insufficient? – Anko Apr 3 '15 at 14:13
• Also, what do you mean by using UIBezierPath? Isn't that a rendering thing? I thought you were asking about the cool physics. – Anko Apr 3 '15 at 14:15
• @Anko Thanks for your comments, After searching I found that I have to use liquidfun. Do you know how to implement liquid flooding using liquid fun and spritekit? – Mariam Apr 3 '15 at 14:17
• Wow, Liquidfun does look fun. I've not used it, but looks like they have a programmer's guide. – Anko Apr 3 '15 at 14:30

This is a very interesting topic.

You can build the water effect using SpriteKit and its integrated physics engine.

## Step 1

1. Create a Physics World
2. Create many little circular SKSpriteNode(s), each one will have a circular physics body matching the graphics representation

## Step 2

Then every frame you'll need to:

1. Draw all the sprites on a buffer
2. Apply a blur effect
3. Apply a threshold effect
4. Draw the buffer on the screen

You can get a better understanding of the process by playing with this interactive demo: http://www.patrickmatte.com/stuff/physicsLiquid/

• what do you mean by Draw all the sprites on a buffer? Do you mean I have to save sprites in an array? – Mariam Apr 6 '15 at 13:23
• It's a technique used to draw on the screen objects after having applied some effects. In SpriteKit you can draw sprites on a private buffer and apply effects on them using an SKEffectNode: developer.apple.com/library/mac/documentation/SpriteKit/… – Luca Angeletti Apr 6 '15 at 13:52
• Sorry for bothering. But After I read the link you provide me I have a question: Do you mean by Drawing all the sprites on a buffer this? effectsNode.addChild(sprite) // the buffer is effectsNode which is SKEffectNode correct? Thanks again. – Mariam Apr 6 '15 at 14:24
• what do you mean by a threshold effect? do you mean: SKPhysicsBody(texture: sprite.texture, alphaThreshold: 0.9, size: sprite.size)? – Mariam Apr 6 '15 at 14:29
• Very useful link. Thanks again :) Can I take your opinion on this approach, tech.theplayhub.com/… I think it bad do you agree with me? or do you recommended that I follow this approach? – Mariam Apr 6 '15 at 16:04