Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Bindings - other languages
»
DotNet
»
'System.AccessViolationException' when using Inversetransform on a sprite
Print
Pages: [
1
]
Author
Topic: 'System.AccessViolationException' when using Inversetransform on a sprite (Read 3285 times)
0 Members and 1 Guest are viewing this topic.
RcColes
Newbie
Posts: 2
'System.AccessViolationException' when using Inversetransform on a sprite
«
on:
June 26, 2013, 01:21:56 pm »
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.
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: 'System.AccessViolationException' when using Inversetransform on a sprite
«
Reply #1 on:
June 26, 2013, 01:33:23 pm »
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.
Logged
Laurent Gomila - SFML developer
RcColes
Newbie
Posts: 2
Re: 'System.AccessViolationException' when using Inversetransform on a sprite
«
Reply #2 on:
June 26, 2013, 02:39:00 pm »
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
»
Logged
Print
Pages: [
1
]
SFML community forums
»
Bindings - other languages
»
DotNet
»
'System.AccessViolationException' when using Inversetransform on a sprite