/ /すべてのオブジェクトの変数を変更するベクトルを修正するには? -c ++、winapi、visual-c ++、vector、directx

どのようにベクトルを修正するには、すべてのオブジェクトの変数を変更するには? - c ++、winapi、visual-c ++、ベクトル、directx

ビットマップをロードしてからビットマップを描画して処理するイメージクラスを作成しましたが、このイメージクラスのベクトルを作成して3つのオブジェクトのビットマップをロードすると 最後のオブジェクト(3番目)は、すべてのオブジェクトをビットマップに設定します。

ビットマップの読み込み:

PlayerCard[0].GetBitmap(L"program files/Creature Cards/Mana_Wyrm.png");
PlayerCard[1].GetBitmap(L"program files/Creature Cards/Snowchugger.png");
PlayerCard[2].GetBitmap(L"program files/Creature Cards/Water_Elemental.png");

ウィンドウに表示されるのは3つのウォーターエレメンタルです。

GetBitmap(wchar_t * filename):画像関数

CoCreateInstance(CLSID_WICImagingFactory, 0, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)&wicFactory);

wicFactory->CreateDecoderFromFilename(filename, 0, GENERIC_READ, WICDecodeMetadataCacheOnLoad, &wicDecoder);

wicDecoder->GetFrame(0, &wicFrame);

wicFactory->CreateFormatConverter(&wicConverter);

wicConverter->Initialize(wicFrame, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, 0, 0.0, WICBitmapPaletteTypeCustom);

graphics.GetRenderTarget()->CreateBitmapFromWicBitmap(wicConverter, 0, &bmp);

if (wicFactory) wicFactory->Release();
if (wicDecoder) wicDecoder->Release();
if (wicFrame) wicFrame->Release();
if (wicConverter) wicConverter->Release();

画像ヘッダー:Image.h

public:
void PassGraphics(Graphics gfx);
void Init();
void Unload();
void GetBitmap(wchar_t* filename);
void Draw(float x, float y);
private:
IWICImagingFactory *wicFactory;
IWICBitmapDecoder *wicDecoder;
IWICBitmapFrameDecode *wicFrame;
IWICFormatConverter *wicConverter;
ID2D1Bitmap* bmp;
Graphics graphics;

回答:

回答№1は0

理由はわかりませんが、ベクター画像の描画に使用されたforループが問題でした。

for (float i = 0; i <= 769; i += 384)
{
for (int c = 0; c < 3; c++)
{
PlayerCard[c].Draw(i, 100);
}
}

このforループを手動描画呼び出し関数に置き換えました。

PlayerCard[0].Draw(0, 100);
PlayerCard[1].Draw(384, 100);
PlayerCard[2].Draw(769, 100);