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\$
4
  • \$\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
    Commented Apr 3, 2015 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
    Commented Apr 3, 2015 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
    Commented Apr 3, 2015 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
    Commented Apr 3, 2015 at 14:30

1 Answer 1

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\$
5
  • \$\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
    Commented Apr 6, 2015 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\$ Commented Apr 6, 2015 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
    Commented Apr 6, 2015 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
    Commented Apr 6, 2015 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
    Commented Apr 6, 2015 at 16:04

Not the answer you're looking for? Browse other questions tagged .