The Power of Hexagons: Falling down a hole, that sinking feeling in Swift (CGPath, CALayer, CoreGraphics)
This is a brief post in which I'm going to look at sending an imaginary block down an imaginary hole from the last power of hexagons post. For this to happen we need to divide our tiles and blocks into three types: (1) ones that will be behind the object that will descend down the hole, (2) ones that will be in front of the descending object, and (3) cosmetic ones that don't matter whether they are in front or behind. Once we've established which is which, we can then decide on the drawing order (and/or zPosition) assignment. So first let's draw the blocks and tiles placed behind our block.
Rear blocks and tiles
By drawing the objects that are furthest back, we've created a range of three starting positions, and now I'll add the block (to be animated) at one of these positions:
Just for fun let's see what happens when the block moves through the hole right now:
Front blocks and tiles
Clearly we need the blocks that will conceal our yellow block as it descends a depth of two blocks. Otherwise the illusion will be broken.
Animation
Until it is almost obscured.
Comments
Post a Comment