1
Graphics / Program crashes on Image.LoadFromFile()
« on: September 23, 2009, 10:44:30 pm »
Why people use pointers everywhere? It's like an epidemy
![Tongue :P](https://www.sfml-dev.org/forums/Smileys/default/tongue.gif)
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.
#include <SFML/Graphics.hpp>
#include "AnimatedSprite.hpp"
using namespace Engine;
int main(int argc, char* argv[])
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "AnimatedSprite Demo");
std::string file = "avion rojo 66x85 c3 f1.png"; // image file of the sprite
Tile tileSettings; // structure that hold the tile settings
tileSettings.Width = 67;
tileSettings.Height = 85;
tileSettings.Columns = 3;
tileSettings.Rows = 1;
float animationTime = 0.2f; // time between frame-to-frame in the animation
AnimatedSprite aircraft(&App, file, tileSettings, animationTime);
// Sets an animation with name "default", wich frames are 0,1 and 2 (frames start from zero)
aircraft.setAnimation("0,1,2", "default");
aircraft.SetPosition(400.f, 300.f);
sf::Event Event;
while(App.IsOpened())
{
aircraft.getFrameTime(); // to manage internal time stuff
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
App.Close();
}
if(App.GetInput().IsKeyDown(sf::Key::Escape))
App.Close();
aircraft.playAnimation("default"); // plays the animation "default"
App.Clear(sf::Color(192, 192, 192));
aircraft.draw(); // draw the sprite
App.Display();
}
return EXIT_SUCCESS;
}
// 0,1,2,3 are the frames of the animation
sprite.setAnimation("0,1,2,3", "default");
// tons of useful code...
// play the animation
sprite.playAnimation("default");
EntityPlayer.cpp
78: if (GetPosition().x > GetSize().x / 2)
84: if (GetPosition().x < GetEngine().GetRenderWindow().GetWidth() - (GetSize().x / 2))
90: if (GetPosition().y > GetSize().y / 2)
98: if (GetPosition().y < GetEngine().GetRenderWindow().GetHeight() - (GetSize().y / 2))
while(App.IsOpened())
{
for(;;)
{
if(App.GetInput().IsKeyDown(sf::Key::Escape) break;
App.Clear(sf::Color(192, 192, 192));
}
// LOTS OF USEFUL CODE...
}
#include <SFML/Window.hpp>
int main(int argc, char* argv[])
{
sf::Window App(sf::VideoMode(800, 600, 32), "Testing SFML");
sf::Event Event;
while(App.IsOpened())
{
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed) App.Close();
}
if(App.GetInput().IsKeyDown(sf::Key::Escape)) App.Close();
App.Display();
}
return EXIT_SUCCESS;
}