openfl / openfl-html5

[deprecated] OpenFL HTML5 backend
Other
0 stars 1 forks source link

transform.matrix not being properly set? #4

Closed jgranick closed 10 years ago

jgranick commented 10 years ago

4 Issue by fserb,

So, I have a piece of code that does something like:

    var m = new flash.geom.Matrix();
    m.identity();
    m.translate(-width/2.0, -height/2.0);
    m.rotate(angle);
    m.translate(pos.x, pos.y);
    base_sprite.transform.matrix = m;

In Flash/native it works as expected (object gets rotated around center, and translated). In html5 the matrix is ignored. If I comment the last line, the flash/native looks identical to the html5 one, which made me conclude html5 is just ignoring the matrix.

I tried to check the code. I've double checked that the Matrix code seems fine (except that maybe the translation() could be optimized by just adding the values to tx,ty) but can't understand how the transform eventually gets to the world transformation matrix of the DisplayObject.

jgranick commented 10 years ago

Comment by evilWicked:

I am seeing something like this as well

If I have a transform matrix mtxTrans

then this works x = mtxTrans.tx; y = mtxTrans.ty;

while this transform.matrix = mtxTrans;

doesn't.

The first image uses x y assignment.

transform_test_tx_addition

The second transform.matrix = mtxTrans

transform_test_transform_assign

But there is something else wrong as well - there should be another image on the screen in both cases - that is nowhere to be seen - but I haven't narrowed that one down. Could be cumulative transforms I am applying. It has something to do with Bitmaps - if I draw directly it appears albeit slight off position, but not if I render to bitmap and then show that.

transform_test_flash

One hint - and only a weak hint - is that in flash if I use a transform.matrix.concat(mtxTrans); it makes it look like the wrong image.