1
System / Re: Error: Vector2 is not a template
« on: April 10, 2020, 01:12:16 pm »
Problem Solved, One of mine unfinished scripts made this error.
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.
Don't use globals. SFML doesn't support having it's resources (ContextSettings, Font and Text in your case) as globals. It's also a bad design.How Can I make this resources don't global? I tried something like that:
#include "stdafx.h"And I still got this error
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include "JQEText.h"
using namespace sf;
using namespace std;
map<int,string> numbers;
//numbers["count"] = 6;
int main()
{
#pragma region Start
ContextSettings settings;
Font font;
settings.antialiasingLevel = 8;
RenderWindow engine{ VideoMode{ 1920,1000 }, "JQEngine",0,settings };
engine.setFramerateLimit(60);
Event event;
engine.setPosition(Vector2i(0,0));
font.loadFromFile("Arkitech.ttf");
JQEText text = JQEText(25, font, "test", Vector2f(0, 0), Color(255, 255, 255));
//mousePosition.setColor(Color(0, 0, 0, 255));
#pragma endregion
//rest of code
}
#include "stdafx.h"Full class.h
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include "JQEText.h"
using namespace sf;
using namespace std;
ContextSettings settings;
Font font;
Text test;
map<int,string> numbers;
//numbers["count"] = 6;
int main()
{
#pragma region Start
settings.antialiasingLevel = 8;
RenderWindow engine{ VideoMode{ 1920,1000 }, "JQEngine",0,settings };
engine.setFramerateLimit(60);
Event event;
engine.setPosition(Vector2i(0,0));
font.loadFromFile("Arkitech.ttf");
JQEText text = JQEText(25, font, "test", Vector2f(0, 0), Color(255, 255, 255));
//mousePosition.setColor(Color(0, 0, 0, 255));
#pragma endregion
while (true)
{
engine.clear(Color(255 * 0.4, 255 * 0.4, 255*0.4, 255));
engine.pollEvent(event);
if (event.type == Event::Closed)
{
engine.close();
break;
}
else if (event.type == Event::MouseButtonPressed)
{
//Mouse::getPosition(engine).x Mouse::getPosition(engine).y;
}
engine.draw(test);
engine.draw(text);
engine.display();
}
return 0;
}
#pragma onceFull class.cpp
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include <cstdlib>
#include <ctime>
#include <string>
#include <Windows.h>
using namespace sf;
using namespace std;
class JQEText : public Drawable
{
public:
JQEText(int size, Font font, string ttext, Vector2f position, Color color);
~JQEText();
Text text;
private:
void draw(RenderTarget& target, RenderStates state) const override;
};
#include "stdafx.h"
#include "JQText.h"
JQText::JQText(int size, Font font, string ttext, Vector2f position, Color color)
{
text.setCharacterSize(size);
text.setFont(font); // when I added "//" before that command I don't get this error
text.setString(ttext);
text.setPosition(position);
text.setFillColor(color);
}
JQText::~JQText()
{
}
void JQText::draw(RenderTarget& target, RenderStates state) const
{
target.draw(text, state);
}
No, thanks. Now that workingI saw topics like that topic, but they don't help me with my actual error.Does that mean your version of Visual Studio is at least 15.7.0?