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

Author Topic: Transform.Translate doesn't seem to change anything  (Read 2996 times)

0 Members and 1 Guest are viewing this topic.

timothy.s.dev

  • Newbie
  • *
  • Posts: 4
    • View Profile
Transform.Translate doesn't seem to change anything
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Transform.Translate doesn't seem to change anything
« Reply #1 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.
Laurent Gomila - SFML developer

timothy.s.dev

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Transform.Translate doesn't seem to change anything
« Reply #2 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!