Beste,
Momenteel wil ik een vector vullen met 4 textures die ik nodig heb om in een sprite in te laden (ik gebruik SFML en opengl, maar dit is dus buiten de kwestie). Het probleem is momenteel dat het laatste element nooit niet getoond wordt.
Ik moet dus nog een push_back() call doen een dummy texture om het laatste (nu dus het voorlaatste element in de vector) te kunnen laten zien.
Dit werkt niet
Code:
void RulesScreen::setResources(std::vector<sf::Texture> AllTextures, std::vector<sf::Sprite> AllSprites){
if(!loaded){
t_mAll_Textures=AllTextures;
s_mAll_Sprites=AllSprites;
....
t_mFirstPanelRules=t_mAll_Textures[2];
t_mSecondPanelRules=t_mAll_Textures[3];
t_mThirdPanelRules=t_mAll_Textures[4];
t_mFourthPanelRules=t_mAll_Textures[5];
t_mPanel_Textures.push_back(t_mFirstPanelRules);
t_mPanel_Textures.push_back(t_mSecondPanelRules);
t_mPanel_Textures.push_back(t_mThirdPanelRules);
t_mPanel_Textures.push_back(t_mFourthPanelRules);
......
s_mPanel.setTexture(t_mPanel_Textures[3]); //DIT WERKT NIET
loaded=true;
}
}
Dit werkt wel
Code:
void RulesScreen::setResources(std::vector<sf::Texture> AllTextures, std::vector<sf::Sprite> AllSprites){
if(!loaded){
t_mAll_Textures=AllTextures;
s_mAll_Sprites=AllSprites;
....
t_mFirstPanelRules=t_mAll_Textures[2];
t_mSecondPanelRules=t_mAll_Textures[3];
t_mThirdPanelRules=t_mAll_Textures[4];
t_mFourthPanelRules=t_mAll_Textures[5];
t_mPanel_Textures.push_back(t_mFirstPanelRules);
t_mPanel_Textures.push_back(t_mSecondPanelRules);
t_mPanel_Textures.push_back(t_mThirdPanelRules);
t_mPanel_Textures.push_back(t_mFourthPanelRules);
t_mPanel_Textures.push_back(DUMMY);
......
s_mPanel.setTexture(t_mPanel_Textures[3]); //DIT WERKT NU WEL
//s_mPanel.setTexture(t_mPanel_Textures[4]); //DIT WERKT NIET
loaded=true;
}
}
Ik heb alle vectors de juiste grootte gegeven mbv .reserve. Iemand een idee?
Mvg