#include "StdAfx.h"
#include "SplashScreen.h"
#include "Game.h"
void SplashScreen::Show(sf::RenderWindow & renderWindow)
{
sf::Image image;
if(image.loadFromFile("images/SplashScreen.png") != true)
{
return;
}
sf::Sprite sprite(image);
renderWindow.draw(sprite);
renderWindow.display();
sf::Event event;
while(true)
{
while(renderWindow.pollEvent(event))
{
if(event.type == sf::Event::EventType::KeyPressed
|| event.type == sf::Event::EventType::MouseButtonPressed
|| event.type == sf::Event::EventType::Closed )
{
return;
}
}
}
}
where it says "" sf::Sprite sprite(image); "" the image in the brackets is underlined and comes up with the error - no instance of constructor matches the argument list
Any help ?
sf::Sprite
doesn't take a sf::Image
as constructor but a sf::Texture
. Use a sf::Texture
instead of a sf::Image
and it should work.
So your code to initialize Sprite shoud be something like:
sf::Texture texture;
if(texture.loadFromFile("images/SplashScreen.png") != true)
{
return;
}
sf::Sprite sprite(texture);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.