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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ShadoWhy

Pages: [1]
1
Graphics / Re: Rotate a Sprite centered
« on: May 30, 2017, 05:53:36 pm »
Thanks.
It works.

2
Graphics / Rotate a Sprite centered
« on: May 25, 2017, 01:35:34 pm »
I using SFML 2.4.2
My english is not the best sorry for mistakes.
I try to make a Pseudo3D Object(an Emerald or something like this) and have tried to Rotate the Picture.

The Variables of the Code are:
Defines:
#define DEFAULT_BIT_SCALE 4
#define DEFAULT_BIT_SIZE    8
 
Objects:
sf::Texture texture;
sf::Sprite sprite[DEFAULT_BIT_SIZE];
 

The Code in the Init look like this:
void bit8::Cube::init()
{      
        //Its an test Texture
        this->texture.loadFromFile("gfx/8x8x8.png");
        this->texture.setRepeated(false);
        this->texture.setSmooth(false);
       
        //This is the code for creation for test a cube
        for (int i = 0; i < DEFAULT_BIT_SIZE; i++) {
                this->sprite[i].setTexture(texture);
                this->sprite[i].setTextureRect(sf::IntRect(i * DEFAULT_BIT_SIZE, 0, DEFAULT_BIT_SIZE, DEFAULT_BIT_SIZE));
                this->sprite[i].setScale(DEFAULT_BIT_SCALE, DEFAULT_BIT_SCALE);
                this->sprite[i].setPosition(200, 300 + i*DEFAULT_BIT_SCALE);
               
        }
}
 

The Code for the Rotate look like this:
float degrees = 0
for (int i = 0; i < DEFAULT_BIT_SIZE; i++) {
                if (degrees > 359.90) {
                        degrees = 0;
                }
                degrees += 0.1f;
                this->sprite[i].setRotation(degrees);
        }
 
I don't know if the Question is in the right place.
And I have the problem that I have to change the Rotation axis to the Center and dont know a way to do that.
So is the question how to do the axis in the center.
Thanks for any answers.

Pages: [1]
anything