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

Author Topic: setOrigin fails  (Read 2587 times)

0 Members and 1 Guest are viewing this topic.

jerryd

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
setOrigin fails
« on: May 03, 2013, 04:30:30 am »
SFML forum,

 SFML 1.6,  Visual C++ 2010

 I load an image and set it as a sprite:

   MyImage.LoadFromFile("Sprite2.bmp"))

   // Create a sprite called Rocket from MyImage
   sf::Sprite Rocket(MyImage);

 This all works and the sprite appears on the screen.

 Now when I try to set the origin of the sprite:
   Rocket.setOrigin(25, 25);

 I get a compiler error saying:
 error C2039: 'setOrigin' : is not a member of 'sf::Sprite'

 What am I doing wrong here?

jerryd

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: setOrigin fails
« Reply #1 on: May 03, 2013, 04:34:07 am »
SFML 1.6 uses CamelCase where as the new SFML 2.0 uses camelCase. Try Rocket.SetOrigin(25, 25); instead and it'll probably work.

That said, if you haven't yet please check out SFML 2.0 which was just released and is MUCH better than 1.6.
DSFML - SFML for the D Programming Language.

jerryd

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: setOrigin fails
« Reply #2 on: May 03, 2013, 05:04:51 am »
Jebbs,
 Thanks for the reply.

 Tried SetOrigin but got the same error message.

 I have downloaded and compiled SFML20 but can't seem to get
 the include files to work yet.

Any more suggestions about the SetOrigin?

jerryd

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: setOrigin fails
« Reply #3 on: May 03, 2013, 05:08:36 am »
Looks like I have been using SFML 2.0 longer than I thought!

The function you are looking for is SetCenter, not SetOrigin.

When in doubt, the documentation is your friend. ;)

What issues are you having with the 2.0 include files?
DSFML - SFML for the D Programming Language.

jerryd

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: setOrigin fails
« Reply #4 on: May 03, 2013, 05:40:22 am »
Jebbs,

 That worked.

 I had read about and tried setCenter() but it
 also failed.  Probably because of the wrong case.

 Using Visual C++ 2010 I set all the properties to the SFML20
 include and lib files but when I leave the properties menu
 it doesn't load them?  I know the paths are correct because
 I use the "edit" function to set the paths.

 The only thing that works is Render Window.  Every other sf
 type command, such as "SetFramerateLimit()" or "LoadFromFile",
 is colored red in the editor.  All works with SFML-1.6

jerryd

Cornstalks

  • Full Member
  • ***
  • Posts: 180
    • View Profile
    • My Website
Re: setOrigin fails
« Reply #5 on: May 03, 2013, 05:43:51 am »
The only thing that works is Render Window.  Every other sf
 type command, such as "SetFramerateLimit()" or "LoadFromFile",
 is colored red in the editor.  All works with SFML-1.6
Again, as Jebbs said, the casing changed in 2.0. It's "loadFromFile" and "setFramerateLimit" etc.