Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi [Andorra 2D] Array of TAndorraColor (https://www.delphipraxis.net/149845-%5Bandorra-2d%5D-array-tandorracolor.html)

Spezi 31. Mär 2010 20:56


[Andorra 2D] Array of TAndorraColor
 
Hallo DP,

ich bin gerade dabei mein eigenes kleines Tower Defense zu programmieren.
An sich funktioniert auch alles, aber es ist doch etwas langweilig nur mit der StandardCanvas.
Außerdem auch nicht so flink.

Deshalb habe ich vor das ganze mit Andorra 2D zum laufen zu bringen.

Da ich ein Array meiner ganzen Türme habe, gehe ich das beim Zeichnen durch, und anhand ihres Typs bestimme ich den Index mit dem ich die Farbe aus meinem Farben-Array auslese.
Vorher:
Delphi-Quellcode:
towercolors: Array[0..7] of TColor=(clred,claqua,clwhite,clyellow,clblack,cllime,clblue,clred);
Jetzt:
Delphi-Quellcode:
towercolors: Array[0..7] of TAndorraColor=(AdCol32_Red,AdCol32_aqua,AdCol32_white,AdCol32_yellow,AdCol32_black,AdCol32_lime,AdCol32_blue,AdCol32_red);
Und da liegt das Problem.
Ich bekomme beim Kompilieren die Meldung:
[Fehler] main.pas(90): E2029 '(' erwartet, aber Bezeichner 'AdCol32_Red' gefunden
Wenn ich die Farbe in Klammer setze gehts immer noch nicht.
Auch
Delphi-Quellcode:
Ad_ARGB(255, 255, 0, 0);
funktioniert nicht.

Woran liegt das Problem?

MfG
Spezi

PS: Ist es evtl sinnvoll die Türme zu Sprites zu machen, um sie automatisch zeichnen zu lassen?
(Muss ich dann meine Klasse TTower von TSprite [Oder TImageSprite,Oder ...] anstatt von TObject ableiten?)

igel457 31. Mär 2010 21:57

Re: [Andorra 2D] Array of TAndorraColor
 
Das Problem ist, dass es sich bei "TAndorraColor" um einen Record handelt.

Der Delphi-Compiler scheint nun das einfügen von Record-Konstanten in eine Array-Konstante nicht zu mögen. Folgendermaßen funktioniert es aber:
Delphi-Quellcode:
const
  colors: array[0..1] of TAndorraColor = (
    (r: 100; g: 100; b: 100; a: 100),
    (r: 150; g: 100; b: 150; a: 100)
  );
Die Werte können entsprechend aus der AdConsts.pas kopiert werden.

Spezi 31. Mär 2010 22:10

Re: [Andorra 2D] Array of TAndorraColor
 
Funktioniert :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz