SFML community forums
Help => General => Topic started by: Assimodeus on January 08, 2009, 12:22:51 am
-
I started a project, which used to run properly using 1.3, and i got a runtime error now:
(http://e.imagehost.org/0336/terminerr.jpg)
how could it be?
note: i did no changes in the source, just installed 1.4.
EDIT: Code
SfShapeSpriteMove.cpp
/*
* SfShapeSpriteMove.cpp
*
* Created on: 05.01.2009
* Author: Meta
*/
#include <iostream.h>
#include <SFML/Graphics.hpp>
#include "SfShapeSpriteMove.h"
//#include "MyKoords.h"
int main(){
/*INITIALISIERUNGEN */
sf::RenderWindow App(sf::VideoMode(1024,748,32),"SFML Bewegung",sf::Style::Close, sf::WindowSettings(24,8,0));
//App.SetBackgroundColor(sf::Color(0,0,0,255));
App.SetFramerateLimit(60);
//MyKoords myxysys(100,10,&App);
sf::Shape spr1 = sf::Shape::Circle(500,375,25,sf::Color::Green,1,sf::Color::Black);
sf::String success = sf::String("ERFOLG!",sf::Font::GetDefaultFont(),50.f);
success.SetColor(sf::Color(255,255,255));
while(App.IsOpened()){
sf::Event Event;
while(App.GetEvent(Event)) {
//Abarbeitung des Events "CLOSE"
if((Event.Type==sf::Event::Closed))
App.Close(); //falls das X geklickt wurde, schließe App
//geradlinige Bewegungen mit je einer Pfeil-Taste, Move: float x float ---> void
if((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Up))
spr1.Move(0,-10);
if((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Down))
spr1.Move(0,10);
if((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Right))
spr1.Move(10,0);
if((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Left))
spr1.Move(-10,0);
/*TODO schräge Bewegungen mit mehreren Pfeil-Tasten, Move: Vector2f ---> void
hmm will nich so recht
//falls das Event lautet "je beide Tasten gedrückt" ...
if(((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Up))&&((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Right)))
//...mache solange wie sie gedrückt sind
while((App.GetInput().IsKeyDown(sf::Key::Up))&&(App.GetInput().IsKeyDown(sf::Key::Right)))
//...einen Move
{spr1.Move(sf::Vector2f(10,-10));App.Draw(success);}
if(((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Down))&&((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Right)))
while((App.GetInput().IsKeyDown(sf::Key::Down))&&(App.GetInput().IsKeyDown(sf::Key::Right)))
{spr1.Move(sf::Vector2f(10,10));App.Draw(success);}
if(((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Down))&&((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Left)))
while((App.GetInput().IsKeyDown(sf::Key::Down))&&(App.GetInput().IsKeyDown(sf::Key::Left)))
{spr1.Move(sf::Vector2f(-10,10));App.Draw(success);}
if(((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Up))&&((Event.Type==sf::Event::KeyPressed)&&(Event.Key.Code == sf::Key::Right)))
while((App.GetInput().IsKeyDown(sf::Key::Up))&&(App.GetInput().IsKeyDown(sf::Key::Left)))
{spr1.Move(sf::Vector2f(-10,-10));App.Draw(success);}
*/
}
App.Draw(spr1);
/*Ausgabe der aktuellen Position von spr1 im Fenster auf die Standard Ausgabe*/
float xs1 = spr1.GetPosition().x;
float ys1 = spr1.GetPosition().y;
std::cout<<"Circle spr1 drawed"<<endl;
std::cout << "Position "<< "(" << xs1 <<","<< ys1 << ")" << endl;
//myxysys.drawKoord();
App.Display(); //erschaffenes Fenster anzeigen
}
return EXIT_SUCCESS;
}
SfShapeSpriteMove.h
/*
* SfShapeSpriteMove.h
*
* Created on: 05.01.2009
* Author: Meta
*/
#ifndef SFSHAPESPRITEMOVE_H_
#define SFSHAPESPRITEMOVE_H_
/*Klassendeklaration*/
class SfShapeSpriteMove {
public:
SfShapeSpriteMove();
virtual ~SfShapeSpriteMove();
};
#endif /* SFSHAPESPRITEMOVE_H_ */
-
Are you using the vs2008 libs when your are using vs2005?
-
Use your debugger to know what happens, and where.
-
Are you using the vs2008 libs when your are using vs2005?
i use mingW and therefore the mingW libs are linked.
After some debugging, is am able to determine the error.
sf::String success = sf::String("ERFOLG!",sf::Font::GetDefaultFont(),50.f);
success.SetColor(sf::Color(255,255,255));
If i comment both lines, the program ist executable (thus the sf::shape doesnt act as in 1.3 during moving).