#include <iostream>
#include <fstream>
#include <string>
#include "SFML\Graphics.hpp"
#include "Tree.h"
template <class type>
class loader{
private:
tree<type> *seq;
sf::Sprite BG_img;
sf::Texture texture;
int seq_c;
//node<sf::String> cp1;
//node<sf::String> *temp;
//declaring text object
sf::Text text;
sf::Text sfoption1;
sf::Text sfoption2;
sf::Text sfoption3;
sf::String path;
public:
loader(){
seq=NULL;
seq_c=1;
//setting text
text.setCharacterSize(15);
text.setColor(sf::Color::Black);
sfoption1.setCharacterSize(15);
sfoption1.setColor(sf::Color::Black);
sfoption2.setCharacterSize(15);
sfoption2.setColor(sf::Color::Black);
sfoption3.setCharacterSize(15);
sfoption3.setColor(sf::Color::Black);
//cp1.setData(1);
//cp1.setopt1(newnode(temp,1));
}
void set_tree(tree<type> *a,int deep,sf::String Root_name="1"){
seq=a;
add_data(seq,deep,Root_name);
}
void add_data(tree<type> *a, int counter=0, sf::String nama="1"){
if(counter == 3);
else {
a->add(nama);
counter++;
add_data(a, counter, nama + ".1");
add_data(a, counter, nama + ".2");
add_data(a, counter, nama + ".3");
}
}
int Load_now(sf::String seq='1'){
path = "Sequence/" + seq +".png";
texture.loadFromFile(path);
BG_img.setTexture(texture);
ifstream ff;
string data, option1, option2, option3;
string s_path = "Sequence/" + seq + ".txt";
ff.open(s_path, ios::in);
getline(ff,data);
getline(ff,option1);
if(!ff.eof()) getline(ff,option2);
if(!ff.eof()) getline(ff,option3);
ff.close();
//setting text position
text.setPosition(0,0);
sfoption1.setPosition(0,1);
sfoption2.setPosition(0,2);
sfoption3.setPosition(0,3);
//passing text
text.setString(data);
sfoption1.setString(option1);
if(option1 == "Main menu") return 0;
else return 1;
if(option2 != "") sfoption2.setString(option2);
if(option3 != "") sfoption3.setString(option3);
}
int next(int inp){
return load_now(seq->get_data(inp));
}
void draw(sf::RenderWindow &window){
window.draw(BG_img);
//draW TO DISPLAY text
window.draw(text);
window.draw(sfoption1);
if(sfoption2 != NULL) window.draw(sfoption2);
if(sfoption3 != NULL) window.draw(sfoption3);
}
void chhose(int x){
}
};
所以我有学校项目,我在c ++中创建它作为头文件。 但是当我编译这个错误时出现了 “错误C3861:'load_now':未找到标识符第92行”。 我不明白为什么以及如何解决它。
答案 0 :(得分:0)
什么是seq->get_data(inp)
返回?我认为编译器不确定seq->get_data(inp)
的数据类型。
而Load_now
不是load_now
答案 1 :(得分:0)
您的代码中存在轻微问题。你有Load_now
。所以,
return load_now(seq->get_data(inp));
替换为
return Load_now(seq->get_data(inp));