Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: 'System.AccessViolationException' when using Inversetransform on a sprite  (Read 3278 times)

0 Members and 1 Guest are viewing this topic.

RcColes

  • Newbie
  • *
  • Posts: 2
    • View Profile
I'm not sure if this is a bug or if I'm fundamentally misunderstanding how this function works, but whenever I call InverseTransform on a sprite it crashes with  "'System.AccessViolationException' occurred in mscorlib.dll".


namespace Testcase
{
    class Program
    {
        static void Main(string[] args)
        {
            Sprite sp1 = new Sprite(new Texture("test.png")); //16*16 image

            sp1.Transform.Translate(1, 1); // make sure it has a transform applied

            Transform step1 = sp1.Transform;

            Transform step2 = step1.GetInverse(); //crashes here
        }
    }
}

Note that in the testcase I get the transform then call GetInverse, so that I could isolate the problem the the inversion of the transform.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
The Transform property is read-only (if only it was supported by C#...), you're not supposed to call Translate on it, the result is undefined.
Laurent Gomila - SFML developer

RcColes

  • Newbie
  • *
  • Posts: 2
    • View Profile
Unfortunately the problem is still occurring when the call to transform.translate is removed, and replaced with what I think is the correct method for translating sprites.

namespace Testcase
{
    class Program
    {
        static void Main(string[] args)
        {
            Sprite sp1 = new Sprite(new Texture("test.png")); //16*16 image
            sp1.Position = new Vector2f(1,1);

            Transform step1 = sp1.Transform;

            Transform step2 = step1.GetInverse(); //crashes here
        }
    }
}
 
« Last Edit: June 26, 2013, 04:52:35 pm by RcColes »