前段时间在看C++版本的五子棋,于是花了点时间直接Ctrl+C/V下来了。
遇到的问题
1,路径问题
中文路径在加载时,图片读取会出现问题
string pic_path = getCurrentPath() + "\\res\\tips\\tips-" + to_string(pos-> row + 1) + "-" + to_string(pos->col + 1) + ".jpg";
pic_path = "\\res\\tips\\tips-" + to_string(pos->row + 1) + "-" + to_string(pos->col + 1) + ".jpg";
std::wstring strWide = std::wstring(pic_path.begin(), pic_path.end());
const wchar_t* wcstr = strWide.c_str();
LPCTSTR str = wcstr;
loadimage(&tmpTipImg, str, chessSize, chessSize, true);
2,图片覆盖问题
比较笨的办法,初始化时加载

//初始化提醒背景图片
for (int i = 0; i < gradeSize; i++) {
vector<IMAGE> row;
for (int j = 0; j < gradeSize; j++) {
//row.push_back(0);
IMAGE img;
string pic_path =getCurrentPath() + "\\res\\tips\\tips-" + to_string(i+1) + "-" + to_string(j+1) + ".jpg";
std::wstring strWide = std::wstring(pic_path.begin(), pic_path.end());
const wchar_t* wcstr = strWide.c_str();
LPCTSTR str = wcstr;
loadimage(&img, str, chessSize, chessSize, true);
row.push_back(img);
}
chessTipsBGImgMap.push_back(row);
}

433

被折叠的 条评论
为什么被折叠?



