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?



closed as too broad by bummzack, Anko, Kromster says support Monica, 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.

  • \$\begingroup\$ 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? \$\endgroup\$ – Anko Apr 3 '15 at 14:13
  • \$\begingroup\$ Also, what do you mean by using UIBezierPath? Isn't that a rendering thing? I thought you were asking about the cool physics. \$\endgroup\$ – Anko Apr 3 '15 at 14:15
  • 1
    \$\begingroup\$ @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? \$\endgroup\$ – Mariam Apr 3 '15 at 14:17
  • \$\begingroup\$ Wow, Liquidfun does look fun. I've not used it, but looks like they have a programmer's guide. \$\endgroup\$ – 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/

  • \$\begingroup\$ what do you mean by Draw all the sprites on a buffer? Do you mean I have to save sprites in an array? \$\endgroup\$ – Mariam Apr 6 '15 at 13:23
  • \$\begingroup\$ 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/… \$\endgroup\$ – Luca Angeletti Apr 6 '15 at 13:52
  • \$\begingroup\$ 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. \$\endgroup\$ – Mariam Apr 6 '15 at 14:24
  • \$\begingroup\$ what do you mean by a threshold effect? do you mean: SKPhysicsBody(texture: sprite.texture, alphaThreshold: 0.9, size: sprite.size)? \$\endgroup\$ – Mariam Apr 6 '15 at 14:29
  • \$\begingroup\$ 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? \$\endgroup\$ – Mariam Apr 6 '15 at 16:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.