1
Graphics / Sprite not displaying?
« on: April 14, 2010, 05:44:14 pm »
Whenever I run my program, I don't get the messagebox that should pop up if I don't have the image in the right spot, but I don't see it on the screen.
Head.png
And my code:
Head.png
And my code:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <windows.h>
#include <vector>
#include <iostream>
int main()
{
std::string wordArr[32] = {"integer", "character", "void", "main", "function", "implicit", "null", "include", "typename", "cast", "debug", "command"};
for(int i = 0; i < 32; i++)
{
std::cout << wordArr[i] << "\n";
}
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Hangman: Programmer's edition");
const sf::Input& Input = App.GetInput();
sf::Image img;
if(!img.LoadFromFile("sprites/head.png"))
{
MessageBox(NULL, "Error loading headsprite", "Error loading sprite part: head, located in 'sprites/head.png'.", MB_OK);
}
sf::Sprite Sprite;
Sprite.SetColor(sf::Color(0, 255, 255, 128));
Sprite.SetX(200.f);
Sprite.SetY(100.f);
Sprite.SetPosition(200.f, 100.f);
Sprite.SetRotation(30.f);
Sprite.SetCenter(0, 0);
Sprite.SetScaleX(2.f);
Sprite.SetScaleY(0.5f);
Sprite.SetScale(2.f, 0.5f);
Sprite.SetBlendMode(sf::Blend::Multiply);
Sprite.Move(10, 5);
Sprite.Rotate(90);
Sprite.Scale(1.5f, 1.5f);
Sprite.SetImage(img);
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
App.Draw(Sprite);
App.Display();
}
return EXIT_SUCCESS;
}
[/code]