Search code examples
swiftxcodeanimationgame-physicsskphysicsbody

Best way to implement a "floating bubble" object


As the title says, I'm trying to find a way to implement a kind of floating bubble (a SKSpriteNode object) inside my game. I'm using SpriteKitbut I really don't know which is the best way to approach this problem. In particular:

  • Should I "play" with values inside Xcode Physic Body in order to find good stats which reflects the physic of a soap bubble?

enter image description here

  • Or I should change the gravity to 0.0 and handle the animations through code? If so, what if I need to implement other objects who need to be affected by the standard -9,8 gravity value?

Solution

  • If i understood what you are thinking....a good idea would be using a Particle Emitter, there you can use a texture and play with lots of options. There you can have lots of bubble, emit them.

    If your idea is just animate one or two bubbles....then you may do this with spritekit code (gravity to 0.0), using SKAction to move the bubbles, fade in/out or just play with .alpha.

    You can also use gravity to move it...but you will have less control about what bubble is doing...

    If you need more help just comment this. Hope i helped you!