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

Author Topic: [Solved? Kind of...] Can't seem to get sf::Sprite to change positions...  (Read 886 times)

0 Members and 1 Guest are viewing this topic.

russjr08

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hello! I appear to have gotten stuck here... I have a player class with a sprite member, and it won't seem to change it's position.

Entity.h / Player.h -> http://pastebin.com/yQhDDPTi
Player.cpp -> http://pastebin.com/rmsy8Gxk

I'm calling my sprite's setPosition, and am passing an instance of sf::Vector2f to it.. Nothing happens. I've even tried calling setPosition(pos.x, pos.y) manually and it doesn't seem to work either. When I debug my render method, I see that my internal position is indeed correct, however looking into the entity's sprite variable, I see 'sf::Transformable', with a position member, and it has 0, 0 as the coordinates.. (http://prntscr.com/54c290) If I manually change these, the next render call overrides it with 0, 0 again...

Back in my game class, I can draw a CircleShape and manipulate it's position just fine..

I'm so stumped, I've worked with SFML before and it's always been fantastic for me! I'm sure there's something I overlooked, but I can't find it, and I've compared it with a previous game I've made...


I appreciate any help that you guys can give me :)




Edit: So apparently I can modify the sprite's position when I made it a pointer instead of a regular object... I have *no* clue why that works. But it works, so I guess I'm happy.
« Last Edit: November 09, 2014, 01:26:26 am by russjr08 »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Can't seem to get sf::Sprite to change positions...
« Reply #1 on: November 08, 2014, 07:53:11 pm »
When you update you use _pos, but I see nothing that updates that.

russjr08

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Can't seem to get sf::Sprite to change positions...
« Reply #2 on: November 08, 2014, 07:54:45 pm »
Currently, the only time it's being set is in the Player's constructor.