tipping glass of beer with G2.0? what would be the best approach?

I’m still pondering how one would best emulate the tipping glass of beer with Corona Graphics 2.0. 

Requirement:  Glass of beer where you can programmatically control the level of the beer in the glass, and can also control the angle of the top line of the beer (to emulate if the glass is tipped over).  So assume:

 - there is say a background scene

 - the glass is an image (with transparency inside the glass)

 - the beer in the glass will be based on an image (say with froth on top)

 

Question - Where I’m getting stuck is how to have a dynamic masking approach so that as your move the level of the beer image (with froth on th top) downwards, how to mask anything on the image out that is noting within the glass?  i.e. you can’t really move the mask down of the glass, as consider the shape of the glass, skinny at the bottom, and wider at the top.  So the mask really needs to stay linked to the glass image…but in Corona the mask is applied against the image you want to mask.  

 

Ideas?   (probably a simply approach but I’m not seeing it)

 

 

You might be looking at it the wrong way. One possible solution is to make an image that is the entire screen in size with the interior of the glass cut out. Then you draw the liquid behind this and it will naturally always only ever appear in the glass.

hi rakoonic - problem with this for me is that I will have objects/images both behind and in front of the glass, so I can’t have the implementation of the glass impact the visibility of these other layers…does that make sense?

so didn’t come up with a way to use Graphics 2.0 to assist here…but just having to stick with images & masks, and the ability to move and rotation the mask associated with the image to give the required illusion…

Yeah a mask combined with alpha-channeled images are likely your best bet then. You *might* be able to achieve what you want if snapshots can have masks applied to them (IE you draw the liquid into a snapshot however you want and the snapshot itself has the glass shaped mask), but I can’t confirm or deny if they work as I’ve not tested this. Might be worth looking into briefly just in case?

You could always move the bottom corners of your beer rect in a bit to make it glass shaped. Probably not what you were looking for though. Not very flexible.

You might be looking at it the wrong way. One possible solution is to make an image that is the entire screen in size with the interior of the glass cut out. Then you draw the liquid behind this and it will naturally always only ever appear in the glass.

hi rakoonic - problem with this for me is that I will have objects/images both behind and in front of the glass, so I can’t have the implementation of the glass impact the visibility of these other layers…does that make sense?

so didn’t come up with a way to use Graphics 2.0 to assist here…but just having to stick with images & masks, and the ability to move and rotation the mask associated with the image to give the required illusion…

Yeah a mask combined with alpha-channeled images are likely your best bet then. You *might* be able to achieve what you want if snapshots can have masks applied to them (IE you draw the liquid into a snapshot however you want and the snapshot itself has the glass shaped mask), but I can’t confirm or deny if they work as I’ve not tested this. Might be worth looking into briefly just in case?

You could always move the bottom corners of your beer rect in a bit to make it glass shaped. Probably not what you were looking for though. Not very flexible.