SFML community forums

Bindings - other languages => DotNet => Topic started by: timothy.s.dev on July 17, 2014, 01:53:38 am

Title: Transform.Translate doesn't seem to change anything
Post by: timothy.s.dev on July 17, 2014, 01:53:38 am
In the beginning of my program I have the following:

GameObject transTest = new GameObject("transTest");
Console.WriteLine(transTest.Position.ToString());
transTest.Transform.Translate(new Vector2f(50.0f, 50.0f));
Console.WriteLine(transTest.Position.ToString());

GameObject is a class which inherits from Transformable.  The output is as follows:

[Vector2f] X(0) Y(0)
[Vector2f] X(0) Y(0)

Clearly, the object isn't moving.  I did some googling and discovered that you're supposed to adjust Transformables with "move", "setPosition", "rotate" etc.  But none of those appear to exist in the .Net release (don't appear in intellisense, or in the documentation).  The only things Transformable appears to add is "position", "rotation" and "scale" attributes, none of which can be changed directly, and the Transform itself, and changing it doesn't appear to do anything.

What am I doing wrong?
Title: Re: Transform.Translate doesn't seem to change anything
Post by: Laurent on July 17, 2014, 08:15:29 am
Quote
What am I doing wrong?
Using the Transform property, as you discovered.

Quote
I did some googling and discovered that you're supposed to adjust Transformables with "move", "setPosition", "rotate" etc.  But none of those appear to exist in the .Net release (don't appear in intellisense, or in the documentation).  The only things Transformable appears to add is "position", "rotation" and "scale"
move, setPosition, rotate are not needed in SFML.Net:
sprite.Position += new Vector2f(x, y); // = move
sprite.Rotation += 45; // = rotate
// etc.

Quote
none of which can be changed directly
Of course they can!

Don't hesitate to have a look at the provided examples when you're unsure about something that differs too much from the C++ API.
Title: Re: Transform.Translate doesn't seem to change anything
Post by: timothy.s.dev on July 17, 2014, 11:05:42 pm
Welp, I feel rather foolish now :P  Thanks for the quick response!  Not sure how I missed that!