I'd like to apply a transformation to a sprite like in the attached image: from 1 to 2.
I tried using Sprite:setSkew from GiderosCodingEasy and using Matrix with the first example from the reference manual, but I couldn't skew my sprite.
I'd say both methods give the same result:
it seems that I can only rotate the sprite of the given angle using setSkewY, while setSkewX seems to apply just a slight scaling.
http://docs.giderosmobile.com/reference/gideros/Matrixlocal angle = math.rad(30)
-- create skew matrix
local m = Matrix.new(1, math.tan(angle), math.tan(angle), 1, 0, 0)
--aply to Sprite
local sprite = Sprite.new()
sprite:setMatrix(m) |
Thank you
Comments
Thanks
@hgy29 could this be a bug coming from your matrix updates or do we have to use different parameters/approach? (if this is the case the reference manual needs to be updated too )
Thank you
[edit: 2015.06.30 is the latest release where matrix skew works, but GiderosCodingEasy Sprite:setSkew just rotates the sprite ]
In 2015.06.30 matrix skew seems to be working, if this could help.
It will be in next release.
This is the code I'm using:
https://github.com/ar2rsawseen/GiderosCodingEasy/blob/master/GiderosCodingEasy.lua#L627
Test project is attached.
Matrix.new(1, math.tan(skewangleY), math.tan(skewangleX), 1, 0, 0)
try
Likes: pie
Probably it would work if frustum is 0.
Let me explain what happens under the hood: gideros sprites use position, scale, rotation and anchorPosition coordinates internally to build a transform matrix, which means that when you give the matrix directly, gideros has to compute position, rotation and translation from it, in case you'd like to query one of these parameters afterwise. If you do setRotation or setScale afterwise, the matrix previously set will be replaced by a new scale,rotate,translate matrix, thus you lose skew or other effects.
Notre that you can do setPosition freely, because when just translating only the translate part of the matrix is updated.