Hi all. My problem is that I can't draw classes. Can anyone help me?
#include <SFML\Graphics.hpp>
using namespace sf;
class Rysunek : public Drawable
{
public:
private:
virtual void draw(RenderTarget &target, RenderStates states) const;
};
int main()
{
RenderWindow window(VideoMode(512, 512, 32), " aaa " , Style::Close);
bool b = 1;
Rysunek rys;
while (b = 1)
{
Event a;
while (window.pollEvent(a))
{
if (a.key.code == Keyboard::Escape){
b = 0;
window.close();
}
}
window.clear(Color::Blue);
window.draw(rys);
window.display();
}
return 0;
}
1>------ Build started: Project: TEST, Configuration: Debug Win32 ------
1> Source.cpp
1>Source.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall Rysunek::draw(class sf::RenderTarget &,class sf::RenderStates)const " (?draw@Rysunek@@EBEXAAVRenderTarget@sf@@VRenderStates@3@@Z)
1>C:\Users\user\Documents\Visual Studio 2013\Projects\TEST\Debug\TEST.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
And second code:
#include <SFML\Graphics.hpp>
using namespace sf;
class Rysunek : public Drawable
{
public:
Texture texture;
Sprite sprite(texture);
private:
virtual void draw(RenderTarget &target, RenderStates states) const
{
target.draw(sprite);
}
};
int main()
{
RenderWindow window(VideoMode(512, 512, 32), " aaa ", Style::Close);
bool b = 1;
Rysunek rys;
rys.texture.loadFromFile("a.png");
while (b = 1)
{
Event a;
while (window.pollEvent(a))
{
if (a.key.code == Keyboard::Escape){
b = 0;
window.close();
}
}
window.clear(Color::Blue);
window.draw(rys);
window.display();
}
return 0;
}
{
RenderWindow window(VideoMode(512, 512, 32), " aaa " , Style::Close);
bool b = 1;
Rysunek rys;
while (b = 1)
{
Event a;
while (window.pollEvent(a))
{
if (a.key.code == Keyboard::Escape){
b = 0;
window.close();
}
}
window.clear(Color::Blue);
window.draw(rys);
window.display();
}
return 0;
}
1>------ Build started: Project: TEST, Configuration: Debug Win32 ------
1> Source.cpp
1>c:\users\user\documents\visual studio 2013\projects\test\test\source.cpp(7): error C2061: syntax error : identifier 'texture'
1>c:\users\user\documents\visual studio 2013\projects\test\test\source.cpp(11): error C3867: 'Rysunek::sprite': function call missing argument list; use '&Rysunek::sprite' to create a pointer to member
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========