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

Author Topic: Rotating a sprite is causing some really weird bugs  (Read 6454 times)

0 Members and 1 Guest are viewing this topic.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Rotating a sprite is causing some really weird bugs
« Reply #15 on: October 05, 2014, 02:48:56 pm »
I did think the casts was more than I usually use. My earlier suggestion (using width instead of x though etc.) will be setting the origin to the centre of the pieceShape.
I suppose the next question is:
Is pieceShape the entire shape or just one of the squares?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

wh1t3crayon

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
Re: Rotating a sprite is causing some really weird bugs
« Reply #16 on: October 06, 2014, 04:24:04 am »
I did think the casts was more than I usually use. My earlier suggestion (using width instead of x though etc.) will be setting the origin to the centre of the pieceShape.
I suppose the next question is:
Is pieceShape the entire shape or just one of the squares?

pieceShape is the entire shape. Each shape has one sprite to draw, and four invisible sf::RectangleShapes for collision detection. The blue shapes in the images I posted are the rectangle shapes, and are where the sprite (red) should be turning. But what has me so confused is whenever I print the values of the sprite's origin after explicitly changing the origin, the output is still 0,0

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Rotating a sprite is causing some really weird bugs
« Reply #17 on: October 09, 2014, 12:56:02 am »
Did you output the origin immediately after changing it?
If not, then it's being changed back somewhere else, but if so, there is something wrong.
First, try placing the output immediately after to confirm it's actually getting changed as expected then, either move that output further away and find out when it changes, or try to use your debugger to step through it.

Is pieceShape a sprite, rectangle, or a container class with those things in it?
If it's a container class, you might have to get the local bounds of its internal element for the origin.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*