I have done a character that starts spawning bubbles when he is under water.The way i have done it, is another sprite that is pinned to characters mouth and when that sprite is under water (overlapping water), character will start spawning the bubbles.
Now the problem is that that i want the bubbles not be able to be anywhere else except into the water. (air flying bubbles are not realistic)
I'll show you a picture:
So how do i destroy those bubbles when they are not anymore in water?
You might want to change timeout and or other properties based on the position of the particle object compared to the water surface..
Another way would be to use a blendmode to only show the particles overlapped by the water..
That first one does not work, because the water level can be anything.
About the blend mode. How should I do that? Is there some sort of layer mask thing that I can use for this? I know i can change the blend mode, but should i put the particles over water layer and which blend mode then would be best?
Now the particles are pinned to character, because i don't wanna them appear from wrong part of character. (only mouth and nose) Can this be problem?) If character is not in water, it has spawn rate 0 and in water it's 2.
edit: now the bubbles appear at the same layer with water, but i cannot find any good blend mode for it. The problem is that the background color and contrast and everything can change and the water color can change also. So it may be impossible to find some easy "color trick" for this. :/
I'm not sure why the first one wouldn't work..
Water.BBoxTop should get you the y-coordinate of the top of the water, compare the distance between it and your particle-objkect and it should work fine..
If you want to use the blendmode putting the particle object above the water and setting it's blendmode to source-atop should do the trick..
Just put the water and the particle-object in one layer and set force own texture in the layer properties to yes..
I tried that "source atop" thing, but the particles still appear in places they should not. The particles are at the same layer with water with source atop and they are top of everything. On that layer is not anything else than bubbles and water sprite.
Water is basically one alpha channeled big sprite that has a water wave effect applied and it is rising with custom movement to up.
I also tried destination atop, but it did not work either.
Is the layer with the water and the particles set to Force own texture?
https://dl.dropboxusercontent.com/u/485 ... icles.capx
About the force own texture, I do not know what that means. (And now i don't still know, but it worked.) Thank you again LittleStain! You have helped me a lot with this project!
Oh, another question about this. Now the bubbles are masked with the water layer's alpha channel, but they are hardly visible, because water is almost transparent. Can i do anything to that?
This is a quick example of the other method without blendmodes (you can drag the particles):
https://dl.dropboxusercontent.com/u/485 ... dmode.capx
Offcourse these settings can be optimized to get even more the effect you would like to achieve..
Develop games in your browser. Powerful, performant & highly capable.
Thank you also about that another way to set this.