Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to get the sprite value as it is from a particular frame of Movie #333

Open
ramachandran-prazas opened this issue Mar 12, 2015 · 1 comment

Comments

@ramachandran-prazas
Copy link

Is there a way to get the sprite value as it is from a particular frame of Movie (flump exported).

For example if i have a animation where rotation of a balloon is changing, and I want the contents of a particular frame along with its rotation applied instead of the original symbol image.

Thanks.

@markknol
Copy link
Contributor

You can get this from the Sprite local matrix using mySprite.getLocalMatrix(). I wrote a utilty class to grab the rotation out of it.

import flambe.math.Matrix;

/**
 * Utility mixins for Matrix. Designed to be imported with 'using'.
 * @author Mark Knol
 */
class MatrixUtils
{
    inline public static function getX(matrix:Matrix):Float
    {
        return matrix.m02;
    }   

    inline public static function getY(matrix:Matrix):Float
    {
        return matrix.m12;
    }   

    inline public static function getScaleX(matrix:Matrix):Float
    {
        return Math.sqrt(matrix.m00 * matrix.m00 + matrix.m01 * matrix.m01);
    }   

    inline public static function getScaleY(matrix:Matrix):Float
    {
        return Math.sqrt(matrix.m10 * matrix.m10 + matrix.m11 * matrix.m11);
    }   

    inline public static function getRotation(matrix:Matrix):Float
    {
        return Math.atan(-matrix.m01  / matrix.m00);
    }   
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants