I sometimes create a mask of a sprite to have pixel perfect collision detection and to allow a sprite to flash a particular colour if hit by a bullet - like old arcade games used to flash a sprite white.
This mask can now also be used to make a nice shadow effect by using new sprite 'skew' commands available in the next version of Gideros (2016.10 ?)...
p.shadow=Bitmap.new(c.mask)
p.shadow:setAnchorPosition(0.5,0.5)
p.shadow:setSkewX(-40)
p.shadow:setX(30)
p.shadow:setScaleY(1.4)
p.shadow:setY(-14)
p.shadow:setColorTransform(0,0,0)
p.shadow:setAlpha(0.5) |
The code first makes the anchor point to the middle of the sprite (like the main sprite). It then sets the x skew so that it leans to the right, the x is adjusted so that shadow and the feet line up. I increase the Y scale as shadows are usually quite tall and adjust the Y so the shadow and feet line up again. My mask is white, but shadows are usually black - so I adjust the colour transform (multipliers) to get rid of any colour. Shadows are also usually transparent so the alpha is adjusted to make this happen.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
https://deluxepixel.com
Comments
You're using the pixel class for your radar at the top left right? That's a very handy class the Pixel class. You can even use it for a laser beam which just shows how flexible it really is.
Likes: SinisterSoft
I was going to use a different viewport and just redraw everything there - but the pitch lines and players were actually too small when it scaled. They look better thicker than real life.
https://deluxepixel.com
@antix: [spoiler] in upcoming release Pixel will become most flexible and useful class in Gideros
Likes: SinisterSoft, totebo, antix, simwhi
Likes: SinisterSoft
Since the radar will never change is a path more efficient than just plopping a bitmap there instead?
Likes: antix
https://deluxepixel.com