Jump to content

Rotate WidgetSprite


photo

Recommended Posts

Posted

Dear support,

 

I 'm trying to rotate a sprite in the screen, the rotation aix is perpendicular to screen.The center of the sprite is (x, y), the angle is 60 degree.

1. I tried to use setLayerTexCoord (int layer, vec4 texcoord) , define the new coordinate of (x,y,z,w), but it doesn't work. the code I used is:

       float a1 =a*cos(m)-b*sin(m);
        float b1 =b*cos(m)+a*sin(m);
        float c1 =c*cos(m)-d*sin(m);
        float d1 =d*cos(m)+c*sin(m);
        vec4 xx =vec4(a1,b1,c1,d1);//this is the new coordinate
        sprite.setLayerTransform(0,xx)
;

2. I tried something like sprite.setLayerTransform(0,::rotate(x,y,0.0f,n)); but it looklikes strange for the rotation result, is this work? how to define the right coordinate in this case?

3. I tried another method, failed...

         Image image =sprite.getImage ();
                image.rotate(60);
            sprite.setTexture(image);

 

Best regards,

Joshua

Posted

Hi Joshua,

 

Have you checked samples/widgets/sprite_00 sample? There is a small example of sprites rotation. If you still have issues, please send us minimal test scene for reproduction.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...