SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Static Public Member Functions | Friends | List of all members
SDX::Loading Class Reference

リソースの非同期読み込み支援関数. More...

#include <Loading.h>

Static Public Member Functions

static void Start ()
 非同期読み込みするResorceを登録開始. More...
 
static void End ()
 非同期読み込みするResorceの読込開始. More...
 
static int GetLoadingCount ()
 読み込み中と読み込んだリソース数を取得. More...
 
static int GetSuccesCount ()
 読み込んだリソース数を取得. More...
 
static bool IsLoading ()
 非同期読み込み登録中かどうか. More...
 
static void AddLoading (std::function< void(void)> &&読み込み関数)
 非同期読み込み処理に追加. More...
 

Friends

class Image
 
class ImagePack
 
class Font
 
class MixFont
 
class Sound
 
class Music
 
class Movie
 

Detailed Description

リソースの非同期読み込み支援関数.

Image,Font,Sound,Music,ImagePack,Filmで有効
Loading::End()後は、全リソースの読み込みが終わるまでリソースの読み込み等を行ってはいけない 特にFont::DrawやDrawing::Fontで新しい文字を出すとたまにエラーが出るので注意が必要

Todo:
Windows以外ではエラーが出る
//Copyright © 2014 SDXFramework
//[License]GNU Affero General Public License, version 3
//[Contact]http://sourceforge.jp/projects/dxframework/
//リソースを非同期で読み込む
bool SampleLoading()
{
using namespace SDX;
System::Initialise("sample", 640, 480);
//他ImagePackとFilmクラスも有効
Image imageS[100];
Sound soundS[100];
Music musicS[100];
Font fontS[100];
//Loadingが完了していない時に新しい文字を出すとエラーがたまに発生するため
//事前に使いそうな文字を生成しておく
Drawing::GetFont().GetDrawStringWidth("読み込み完了数/0123456789");
Loading::Start();//非同期読み込み開始
//それぞれ100回読み込み
for (int a = 0; a < 100;++a)
{
imageS[a].Load("data/icon000.png");
}
for (int a = 0; a < 100; ++a)
{
soundS[a].Load("se_maoudamashii_onepoint14.wav");
}
for (int a = 0; a < 100; ++a)
{
musicS[a].Load("data/bgm_maoudamashii_piano14.ogg");
}
for (int a = 0; a < 100; ++a)
{
fontS[a].Load(SystemFont::Gothic,10);
}
Loading::End();//非同期読み込み終了
while (System::Update())
{
//読み込み中のリソースの数を表示
Drawing::String({ 10, 10 }, Color::White, { "読み込み完了数", Loading::GetSuccesCount() ,"/",Loading::GetLoadingCount()});
if (Input::key.Return.on){ break;}//Enterで終了
}
return true;
}

Member Function Documentation

static void SDX::Loading::Start ( )
inlinestatic

非同期読み込みするResorceを登録開始.

static void SDX::Loading::End ( )
inlinestatic

非同期読み込みするResorceの読込開始.

static int SDX::Loading::GetLoadingCount ( )
inlinestatic

読み込み中と読み込んだリソース数を取得.

static int SDX::Loading::GetSuccesCount ( )
inlinestatic

読み込んだリソース数を取得.

static bool SDX::Loading::IsLoading ( )
inlinestatic

非同期読み込み登録中かどうか.

static void SDX::Loading::AddLoading ( std::function< void(void)> &&  読み込み関数)
inlinestatic

非同期読み込み処理に追加.