SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Public Member Functions | Protected Attributes | List of all members
SDX::ImagePack Class Reference

複数のImageをまとめるクラス. More...

#include <ImagePack.h>

Inherited by SDX::Film.

Public Member Functions

 ImagePack (const char *ファイル名, int 総コマ数, int コマ割り横, int コマ割り縦)
 1つの画像を分割して読み込む. More...
 
 ImagePack (const char *ファイル名, const char *拡張子, int 総コマ数, const char *書式="%03d.")
 連番ファイルを一括して読み込む. More...
 
bool Load (const char *ファイル名, int 総コマ数, int コマ割り横, int コマ割り縦)
 1つの画像を分割して読み込む. More...
 
bool Load (const char *ファイル名, const char *拡張子, int 総コマ数, const char *書式="%03d.")
 連番ファイルを一括して読み込む. More...
 
bool LoadTmx (const char *tmxファイル名)
 tmxファイルのタイルセット情報を元に画像を読み込む. More...
 
void Add (Image *追加イメージ)
 Imageを末尾に追加. More...
 
void Add (const char *ファイル名)
 Imageを末尾に追加. More...
 
virtual void Release ()
 Imageをメモリから開放. More...
 
int GetSize () const
 要素数を取得. More...
 
int GetWidth () const
 最大幅を取得. More...
 
int GetHeight () const
 最大高さを取得. More...
 
void SetColor (const Color &描画色)
 描画色をまとめて変更. More...
 
void AdjustWidth (std::vector< int > 幅)
 先頭からimageの幅を差分修正. More...
 
Imageoperator[] (int index)
 オペレータ. More...
 
Imageoperator[] (int index) const
 オペレータ. More...
 
auto begin () -> decltype(imageS.begin())
 イテレータ用. More...
 
auto end () -> decltype(imageS.end())
 イテレータ用. More...
 
auto begin () const -> decltype(imageS.begin())
 イテレータ用. More...
 
auto end () const -> decltype(imageS.end())
 イテレータ用. More...
 

Protected Attributes

std::vector< Image * > imageS
 保持するImage
 
int widthMax = 0
 最大幅
 
int heightMax = 0
 最大高さ
 

Detailed Description

複数のImageをまとめるクラス.

Todo:
リソース解放周り色々未実装
//Copyright © 2014 SDXFramework
//[License]GNU Affero General Public License, version 3
//[Contact]http://sourceforge.jp/projects/dxframework/
//ライブラリの初期化等を行う
bool SampleImagePack()
{
using namespace SDX;
System::Initialise("sample", 640, 480);//ウィンドウタイトルを指定して、初期化する
ImagePack imageA("data/number.png", 10, 10, 1);//分割読み込み
ImagePack imageB("data/icon", "png", 10);//連番ファイル読み込み
ImagePack imageC("data/dekakabocha.png", 12, 3, 4);//分割読み込み
Point pos(300,240);
int count = 0;
int direct = 0;
while (System::Update())
{
++count;
imageA[count / 60 % 10]->DrawExtend({ 200, 240, 30, 40 });
imageB[count / 5 % 10]->Draw({ 400, 240 });
int no = direct * 3 + (count / 12) % 2;
imageC[no]->Draw( pos );
//キーで移動
if (Input::key.Up.hold)
{
pos.Move(0, -5);
direct = 3;
}
if (Input::key.Down.hold)
{
pos.Move(0, 5);
direct = 0;
}
if (Input::key.Left.hold)
{
pos.Move(-5, 0);
direct = 1;
}
if (Input::key.Right.hold)
{
pos.Move(5, 0);
direct = 2;
}
if (Input::key.Return.on){ break; }//Enterで終了
}
System::End();//ライブラリの終了処理を行う
return true;
}

Constructor & Destructor Documentation

SDX::ImagePack::ImagePack ( const char *  ファイル名,
int  総コマ数,
int  コマ割り横,
int  コマ割り縦 
)
inline

1つの画像を分割して読み込む.

SDX::ImagePack::ImagePack ( const char *  ファイル名,
const char *  拡張子,
int  総コマ数,
const char *  書式 = "%03d." 
)
inline

連番ファイルを一括して読み込む.

ファイル名の後に三桁の連番が付いたファイルを連続して読み込む
例:「ファイル名***.拡張子」

Member Function Documentation

bool SDX::ImagePack::Load ( const char *  ファイル名,
int  総コマ数,
int  コマ割り横,
int  コマ割り縦 
)
inline

1つの画像を分割して読み込む.

総コマ数=14,コマ割り横=4,コマ割り縦=4の場合
[ 0][ 1][ 2][ 3]
[ 4][ 5][ 6][ 7]
[ 8][ 9][10][11]
[12][13][ ][ ]
のように分割して、ImagePackのサイズは14になる

bool SDX::ImagePack::Load ( const char *  ファイル名,
const char *  拡張子,
int  総コマ数,
const char *  書式 = "%03d." 
)
inline

連番ファイルを一括して読み込む.

ファイル名の後に三桁の連番が付いたファイルを連続して読み込む
例:「ファイル名***.拡張子」

bool SDX::ImagePack::LoadTmx ( const char *  tmxファイル名)
inline

tmxファイルのタイルセット情報を元に画像を読み込む.

void SDX::ImagePack::Add ( Image 追加イメージ)
inline

Imageを末尾に追加.

void SDX::ImagePack::Add ( const char *  ファイル名)
inline

Imageを末尾に追加.

virtual void SDX::ImagePack::Release ( )
inlinevirtual

Imageをメモリから開放.

Reimplemented in SDX::Film.

int SDX::ImagePack::GetSize ( ) const
inline

要素数を取得.

int SDX::ImagePack::GetWidth ( ) const
inline

最大幅を取得.

int SDX::ImagePack::GetHeight ( ) const
inline

最大高さを取得.

void SDX::ImagePack::SetColor ( const Color 描画色)
inline

描画色をまとめて変更.

void SDX::ImagePack::AdjustWidth ( std::vector< int >  )
inline

先頭からimageの幅を差分修正.

BMPフォント用の画像を文字幅を調整する時に使う 分割読み込み時

Image* SDX::ImagePack::operator[] ( int  index)
inline

オペレータ.

Image* SDX::ImagePack::operator[] ( int  index) const
inline

オペレータ.

auto SDX::ImagePack::begin ( ) -> decltype(imageS.begin())
inline

イテレータ用.

auto SDX::ImagePack::end ( ) -> decltype(imageS.end())
inline

イテレータ用.

auto SDX::ImagePack::begin ( ) const -> decltype(imageS.begin())
inline

イテレータ用.

auto SDX::ImagePack::end ( ) const -> decltype(imageS.end())
inline

イテレータ用.