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.


Topics - another27

Pages: [1]
1
Window / Window style
« on: February 17, 2020, 07:33:05 pm »
How can I change style of the Window, after creation?

I have a sf::RenderWindow mainWindow; variable in my game class, and I want change style after creation.

thx in advance 4 ur attention

2
Graphics / Vector of structs which contains sprites
« on: February 08, 2020, 01:44:41 am »
Im trying to do a vector of struct elements to draw them in RenderWindow;

my struct for non-ui objects:

struct element{
    sf::Texture texture;
    sf::Sprite sprite;
    sf::IntRect rect;
    sf::Text text;
};


my struct for ui objects:

struct uiElement: element{
    sf::Text text;
    bool clickable;
};


Im adding elements like that:

std::vector<uiElement> ui;

uiElement el;

el.texture.loadFromFile("../res/textures/background.jpg");
ui.push_back(el);
ui.back().sprite.setTexture(ui.back().texture);


and it works!But, only if my "std::vector<uiElement> ui;" has one element;

when i try to add more with cycle:

for (int i = 0;i < 4;i++){
                    uiElement btn;
                    btn.texture.loadFromFile("../res/textures/button.png");
                    ui.push_back(btn);
                    ui.back().sprite.setTexture(ui.back().texture);
}


draws only last object in my "std::vector<uiElement> ui;" and the other are just white

my drawing part of code:

for (auto & element : ui){
        window.draw(element.sprite);
}


How can I fix it??

thanks in advance :)

Pages: [1]