Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
[2016.10] Sprite skew effects — Gideros Forum

[2016.10] Sprite skew effects

n1cken1cke Maintainer
edited November 2016 in Announcements
What is 'skew' (aka 'shear mapping')? I will quote Wikipedia (https://en.wikipedia.org/wiki/Shear_mapping):
In plane geometry, a shear mapping is a linear map that displaces each point in fixed direction, by an amount proportional to its signed distance from a line that is parallel to that direction
A picture here is worth a thousand words:
image
In Gideros you can apply skew effect to any Sprite class with `Sprite:setSkew(kx, ky)` where `kx` and `ky` are horizontal and vertical skew factors in range from -90 to 90 degrees. There are short versions too: `setSkewX(kx)` and `setSkewY(ky)`.
Skew effects are very useful, for example @SinisterSoft uses them for shadows:
http://giderosmobile.com/forum/discussion/6729/using-a-mask-and-the-new-sprite-skew-commands-to-make-a-shadow#Item_7
And this YouTube video demonstrates skew-based animation in Cocos2D:

You may use `Sprite:setSkewX` in ENTER_FRAME event to achieve same animation effect in Gideros.
And of course you can easily create italics text with skewX:
image
Note: to left align skewed text use following snippet:
local offsetX = -math.tan(math.rad(math.min(text:getSkewX(), 0))) * text:getHeight()
text:setX(offsetX)
skewedhart.png
755 x 752 - 107K
skewedText.png
725 x 355 - 30K
+1 -1 (+4 / -0 )Share on Facebook
Sign In or Register to comment.