Search code examples
iossprite-kitcalayerskphysicsbody

Masking SKSpriteNode as liquid


I would like to create a liquid dynamics. I searched a lot, created balls moving with device motion, but I don't know how to make the balls look like liquid.. I guess it's some mask but I didn't find how to do it. Could someone help me with that? Thanks.


Solution

  • The idea was clear to me. Didn't know what's the actual filter. Figured it out, the SKSpriteNode is nodeWithImage, the image is a blur ball. Physics body is a ball with a smaller body than the image (so the balls can go a little over each other and become "one piece"). The filter of threshold is set on the scene, like that:

    CIFilter *filter = [CIFilter filterWithName:@"CIColorPosterize"];
    [filter setValue:@(2.0) forKey:@"inputLevels"];
    [scene setFilter:filter];
    [scene setShouldEnableEffects:YES];
    

    That's it, if anyone ever reads it and has a problem they're more than welcome to message me for help.