Exemplo n.º 1
0
    public void Draw(Vector position, Vector scale, Sprite sprite, bool useWorldSpace)
    {
        if (sprite != null)// && camera.viewport.Contain(gameObject.transform.position))
        {
            Vector    delta         = scale * 0.5f;
            Matrix3x3 currentMatrix = useWorldSpace ? worldViewMatrix : screenViewMatrix;

            Vector from = Matrix3x3.Multiply(currentMatrix, position - delta);
            Vector to   = Matrix3x3.Multiply(currentMatrix, position + delta);

            float x = (from.X + to.X) * 0.5F;
            float y = (from.Y + to.Y) * 0.5F;

            float w = GameMath.Abs(from.X - to.X);
            float h = GameMath.Abs(from.Y - to.Y);

            draw(x, y, w, h, sprite.GetIntPtr(), sprite.Width, sprite.Height);
        }
    }