Wywala coś takiego:
Error reading PaintBox1->ExplicitLeft: Property ExplicitLeft does not exist. Ignore the error and continue? NOTE: Ignoring the error may cause components to be deleted or property values to be lost |
Error reading PaintBox1->ExplicitLeft: Property ExplicitLeft does not exist. Ignore the error and continue? NOTE: Ignoring the error may cause components to be deleted or property values to be lost |
void __fastcall TForm1::DrawCards(void)
{
auto_ptr<Graphics::TBitmap> bCard(new Graphics::TBitmap);
bCard->Width = 114;
bCard->Height = 154;
int m = 10; // margines
int s = 4; // przerwa między kartami
int l = 0, t = 0;
for(int i = 0; i < vCards.size(); i++)
{
bCard->LoadFromResourceName((int)HInstance, vCards[i]);
if( (i % 6) == 0 && i > 0)
{
l = 0;
t += 164;
}
int cLeft = m + (l * s) + (l * bCard->Width);
int cTop = m + t;
PaintBox1->Canvas->Draw( cLeft, cTop, bCard.get());
l++;
}
}
PaintBox1->Canvas->Draw( cLeft, cTop, bCard.get());
Image1->Canvas->Draw( cLeft, cTop, bCard.get(0));
Image2->Canvas->Draw( cLeft, cTop, bCard.get(1));
Image3->Canvas->Draw( cLeft, cTop, bCard.get(2));
...
for(int i = 0; i < vCards.size(); i++)
{
bCard->LoadFromResourceName((int)HInstance, vCards[i]);
switch(i)
{
case 1: Image1->Canvas->Draw( cLeft, cTop, bCard.get()); break;
case 2: Image2->Canvas->Draw( cLeft, cTop, bCard.get()); break;
case 3: Image3->Canvas->Draw( cLeft, cTop, bCard.get()); break;
case 4: Image4->Canvas->Draw( cLeft, cTop, bCard.get()); break;
case 5: Image5->Canvas->Draw( cLeft, cTop, bCard.get()); break;
...
}
}
Takie pytanie obiekt bCard przechowuje wszystkie załadowane bitmapy jako całość czy mogę się do nich odwołać pojedynczo po indeksach.
Zamiast rysowania w Paintboxie kart chciałbym każdą kartę załadować do obiektu Image
Wiem, że ten kawałek kodu jest zły chciałem tylko zoobrazować o co mi chodzi
Po co? Przecież w ostatecznym rozrachunku wszystko jest rysowane na formularzu.
Pokażę Tobie jak można przesuwać karty po jednym obiekcie TImage będący planszą dla kart.
mCards[vCards[1]] = TPoint(10, 10);
mCards[vCards[2]] = TPoint(10, 10);
mCards[vCards[3]] = TPoint(10, 10);
mCards[vCards[4]] = TPoint(10, 10);
mCards[vCards[5]] = TPoint(10, 10);
mCards[vCards[6]] = TPoint(10, 10);
mCards[vCards[7]] = TPoint(10, 10);
mCards[vCards[8]] = TPoint(10, 10);
mCards[vCards[9]] = TPoint(10, 10);
mCards[vCards[10]] = TPoint(10, 10);
mCards[vCards[11]] = TPoint(10, 10);
mCards[vCards[12]] = TPoint(10, 10);
mCards[vCards[13]] = TPoint(10, 10);
mCards[vCards[14]] = TPoint(10, 10);
mCards[vCards[15]] = TPoint(10, 10);
mCards[vCards[16]] = TPoint(10, 10);
mCards[vCards[17]] = TPoint(10, 10);
mCards[vCards[18]] = TPoint(10, 10);
mCards[vCards[19]] = TPoint(10, 10);
mCards[vCards[20]] = TPoint(10, 10);
mCards[vCards[21]] = TPoint(10, 10);
mCards[vCards[22]] = TPoint(10, 10);
mCards[vCards[23]] = TPoint(10, 10);
mCards[vCards[24]] = TPoint(10, 10);
mCards[vCards[25]] = TPoint(10, 300);
mCards[vCards[26]] = TPoint(140, 300);
mCards[vCards[27]] = TPoint(140, 310);
mCards[vCards[28]] = TPoint(270, 300);
mCards[vCards[29]] = TPoint(270, 310);
mCards[vCards[30]] = TPoint(270, 320);
mCards[vCards[31]] = TPoint(400, 300);
mCards[vCards[32]] = TPoint(400, 310);
mCards[vCards[33]] = TPoint(400, 320);
mCards[vCards[34]] = TPoint(400, 330);
mCards[vCards[35]] = TPoint(530, 300);
mCards[vCards[36]] = TPoint(530, 310);
mCards[vCards[37]] = TPoint(530, 320);
mCards[vCards[38]] = TPoint(530, 330);
mCards[vCards[39]] = TPoint(530, 340);
mCards[vCards[40]] = TPoint(660, 300);
mCards[vCards[41]] = TPoint(660, 310);
mCards[vCards[42]] = TPoint(660, 320);
mCards[vCards[43]] = TPoint(660, 330);
mCards[vCards[44]] = TPoint(660, 340);
mCards[vCards[45]] = TPoint(660, 350);
mCards[vCards[46]] = TPoint(790, 300);
mCards[vCards[47]] = TPoint(790, 310);
mCards[vCards[48]] = TPoint(790, 320);
mCards[vCards[49]] = TPoint(790, 330);
mCards[vCards[50]] = TPoint(790, 340);
mCards[vCards[51]] = TPoint(790, 350);
mCards[vCards[52]] = TPoint(790, 360);
map<String, INT> wCards;
map<String, String> kCards;
Rozmieszczenie kart zrobiłem tak:
To teraz jeśli dobrze zrozumiałem to będe potrzebował 2 map
Powrót do Ogólne problemy z programowaniem
Użytkownicy przeglądający ten dział: Brak zalogowanych użytkowników i 2 gości