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 - patilanz

Pages: [1]
1
Graphics / Re: Change size of texture, sprite without scale
« on: September 02, 2016, 05:21:21 pm »
Gracias solucionado con setTextureRect

2
Graphics / Change size of texture, sprite without scale [SOLUCIONADO]
« on: August 29, 2016, 12:26:30 pm »
Hello,
I am doing an animation which is changing the size and the color of a sprite with texture created by:

struct rect_s{
        int width;
        int height;
        sf::Color color;
        sf::Texture texture;
        sf::Sprite sprite;
} object;

sf::Uint8* updateMatrix(sf::Uint8 * matrix, sf::Color color, int size){
        if (matrix != 0)delete[]matrix;
        matrix = new sf::Uint8[size];
        for (int i = 0; i < size; i++){
                matrix[i++] = color.r;
                matrix[i++] = color.g;
                matrix[i++] = color.b;
                matrix[i] = color.a;
        }
        return matrix;
}
        object.width = 50;
        object.height = 50;
        object.color = sf::Color::Red;

        sf::Uint8 * matrix = 0;
        matrix = updateMatrix(matrix, object.color, object.width * object.height * 4);

       
        object.texture.create(object.width, object.height);
        object.texture.update(matrix);
        object.sprite.setTexture(object.texture);
 

Later i am doing that:

                if (((float)(clock() - last_t)/CLOCKS_PER_SEC) * 1000 > 30){

                        switch (control.cycle)
                        {
                        case 0:
                                object.color.g++;
                                object.color.r--;
                                object.width++;
                                if (object.color.g > 240)control.cycle = 1;
                                break;
......
//I update the texture size with calling create again but is not working
                        object.texture.create(object.width, object.height);
                        matrix = updateMatrix(matrix, object.color, object.width * object.height * 4);
                        object.texture.update(matrix);
 


How can i do that?

Pages: [1]
anything