1
General / no match for call to `(sf::String) (...
« on: August 12, 2009, 09:26:49 pm »
Hi,
I´ve got an error saying:
and here is the code:
I´ve got an error saying:
Code: [Select]
In function `void lautstaerke_veraendern()':
no match for call to `(sf::String) (std::string&, sf::Font&, int)'
no match for call to `(sf::String) (std::string&, sf::Font&, int)'
||=== Build finished: 2 errors, 0 warnings ===|
and here is the code:
Code: [Select]
#include <iostream>
#include <string>
#include <SFML/Graphics.hpp>
#include <sstream>
sf::Font MyFont;
int lautstaerke_int = 100;
sf::Event Event;
int choice = 1;
float Speed = 150.f; //Bewegungsgeschwindigkeit der Spielfigur
float x = 0.f; //x-Koordinate der Spielfigur
float y = 0.f; //y-Koordinate der Spielfigur
bool game = 0;
std::stringstream out;
std::string lautst;
sf::String lautstaerke;
sf::Sprite zeiger_s;
sf::Image zeiger_i;
sf::Sprite spielfigur_s;
sf::Image spielfigur_i;
sf::Sprite hintergrund_s;
sf::Image hintergrund_i;
// Fenster erstellen
sf::RenderWindow App(sf::VideoMode(1440, 900, 32), "SFML Graphics");
void lautstaerke_veraendern()
{
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Add) && (choice == 2))
{
lautstaerke_int++;
out<<lautstaerke_int;
lautst = out.str();
lautstaerke(lautst, MyFont, 30);
lautstaerke.SetPosition(900,450);
}
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Subtract) && (choice == 2))
{
lautstaerke_int--;
out<<lautstaerke_int;
lautst = out.str();
lautstaerke(lautst, MyFont, 30);
lautstaerke.SetPosition(900,450);
}
}
void zeigermove()
{
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Down))
{
if (choice <= 2)
{
zeiger_s.Move(0,80);
choice += 1;
}
}
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Up))
{
if (choice >= 2)
{
zeiger_s.Move(0,-80);
choice -= 1;
}
}
}
int main()
{
MyFont.LoadFromFile("arial.ttf");
//Hauptmenü erstellen
sf::String men1("Start Game", MyFont, 30);
sf::String men2("Options", MyFont, 30);
sf::String men3("Exit", MyFont, 30);
men1.SetPosition(1200, 150);
men2.SetPosition(1200, 230);
men3.SetPosition(1200, 310);
//Optionenmenü erstellen
sf::String Optmen1("Fullscreen an", MyFont, 30);
sf::String Optmen2("Lautstärke: ", MyFont, 30);
sf::String Optmen3("Tastenbelegung festlegen", MyFont, 30);
Optmen1.SetPosition(720,370);
Optmen2.SetPosition(720,450);
Optmen3.SetPosition(720,530);
// Lade Sprites
hintergrund_i.LoadFromFile("hintergrund.tga");
spielfigur_i.LoadFromFile("sprite.tga");
zeiger_i.LoadFromFile("zeiger.tga");
hintergrund_s.SetImage(hintergrund_i);
spielfigur_s.SetImage(spielfigur_i);
zeiger_s.SetImage(zeiger_i);
zeiger_s.SetPosition(1190, 162);
// Starte Programm-Schleife
while (App.IsOpened())
{
//Menü-Schleife
while(true)
{
App.Clear();
App.Draw(hintergrund_s);
App.Draw(men1);
App.Draw(men2);
App.Draw(men3);
App.Draw(zeiger_s);
App.Display();
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
{
App.Close();
}
zeigermove();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Return)) // Wenn ein Menüpunkt angewählt wird
{
if(choice == 1) //Spiel starten
{
game = 1;
break;
}
if(choice == 2) //Optionen-Menü
{
zeiger_s.SetPosition(710,380);
choice = 1;
while(true)
{
App.Clear();
App.Draw(lautstaerke);
App.Draw(Optmen1);
App.Draw(Optmen2);
App.Draw(Optmen3);
App.Draw(zeiger_s);
while(App.GetEvent(Event))
{
zeigermove();
lautstaerke_veraendern();
}
App.Display();
}
}
if(choice == 3) //Anwendung beenden
{
App.Close();
}
}
}
}
// Game-Schleife
while(game == 1)
{
if (App.GetInput().IsKeyDown(sf::Key::Left)) x -= Speed * App.GetFrameTime();
if (App.GetInput().IsKeyDown(sf::Key::Right)) x += Speed * App.GetFrameTime();
if (App.GetInput().IsKeyDown(sf::Key::Up)) y -= Speed * App.GetFrameTime();
if (App.GetInput().IsKeyDown(sf::Key::Down)) y += Speed * App.GetFrameTime();
spielfigur_s.SetPosition(x, y);
// Events abarbeiten
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
{
App.Close();
}
}
// Bildschirm löschen(Mit schwarzer Farbe füllen)
App.Clear();
App.Draw(spielfigur_s);
// Fensterinhalte auf dem Bildschirm darstellen
App.Display();
}
}
return EXIT_SUCCESS;
}