Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: how to load image files by order  (Read 1532 times)

0 Members and 1 Guest are viewing this topic.

Saud

  • Newbie
  • *
  • Posts: 9
    • View Profile
how to load image files by order
« on: November 09, 2018, 02:17:09 pm »
Hi  :), I'm a beginner programmer in general, and im new to SFML, I find SFML great so far :D.
I have an issue which is sfml seems to load images at the same time(mayb im wrong), what i want to do is to load an image from file and then display it, then after that, i want to load all images of my game
int main()
{
//RenderWindow window
sf::Image imgLS; // image loading screen

imgLS.loadFromFile("loadingScreen.png");

//setting up texture and sprite // sprLS

window.clear();
window.draw(sprLS);
window.display();

sf::Image img1, img2, ... imgn;
img1.loadFromFile("img1.png");
img2.loadFromFile("img2.png");
.
.
.
imgn.loadFromFile("imgn.png");


startFunction(); //function that uses n images displaying them

/*
while window is open stuff, with event
*/




}
 

its like a loading screen is shown while other images are being loaded, when all game images are loaded, function startFunction() starts.

OUTPUT:
black screen untill startFunction() starts;

QUESTION:
is it possible to load an image, display it and then load other images while displaying it?

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: how to load image files by order
« Reply #1 on: November 10, 2018, 01:25:16 pm »
All of those things are possible but first learn how to make a proper sfml program. You need a loop of event listening, updating and rendering. You can then implement a state machine (loading_state, game_state etc). For a proper loading screen you might also need to know about threads. I'm sure you can learn more about this if you google "c++ loading screen" or such.

Saud

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: how to load image files by order
« Reply #2 on: November 10, 2018, 04:37:19 pm »
You can then implement a state machine (loading_state, game_state etc).
Thank you for pointing me to what seems the right direction, threads is the thing i need. State machines it seems i should check it out, Thank you again  :)
and sorry if my post is too newbie to be posted in this forums.
« Last Edit: November 10, 2018, 05:34:33 pm by Saud »