4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\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
8
\$\begingroup\$

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/

\$\endgroup\$
  • \$\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.