相关代码如下:
我已经分别测试了每个 Nurse 对象分配和整个事情,并且数据存储正确,但由于某种原因我无法访问它来确定要显示哪些图块。我也尝试过在没有迭代器的情况下访问数据,但这也不起作用。任何想法都非常感谢,我已经尝试了好几个小时:/
for(unsigned int j = 42; j < EntityManager::getInstance()->nurses.size() * 42 + 42; j += 42) //increment y axis
{
int rosterCounter = 0;
int count = 0;
vector<string> roster = EntityManager::getInstance()->nurses[count]->getRosterData();
vector<string>::const_iterator iter;
iter = roster.begin();
for(unsigned int i = GraphicsCore::getInstance()->screenWidth; rosterCounter <= EntityManager::getInstance()->getSize() && iter != roster.end(); i -= 64) //iterate through each column, RTL
{
TextBox * text;
if(*iter == "D")
{
text = new TextBox("resources/tiles/textboxshortd.png", i, j, (TextBox::type) 4);
}
else if(*iter == "N")
{
text = new TextBox("resources/tiles/textboxshortn.png", i, j, (TextBox::type) 4);
}
else if(*iter == "O")
{
text = new TextBox("resources/tiles/textboxshorto.png", i, j, (TextBox::type) 4);
}
else
{
text = new TextBox("resources/tiles/textboxshort.png", i, j, (TextBox::type) 4);
}
iter++;
rosterCounter++;
}
count++;
}
编辑:它现在运行,但第一次迭代似乎什么都不做,出于某种原因,第一列中根本没有放置任何图块,而且它似乎完全偏移了 1。我尝试了 begin()-1 但这没有用任何一个。谢谢你们的帮助:)