Autor Beitrag
Xearox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260
Erhaltene Danke: 3



BeitragVerfasst: So 21.03.10 07:25 
Vorinformationen:
Ich bin z.Z. ein kleine Spiel am programmieren, welches aber noch lange nicht Fertig ist, im Anhang hab ich mal das Spiel hinzugefügt.
So nun hab ich ein Problem, beim verschieben der AIShips flackern alle bilder, und eine Option wie Buffering o.ä. hab ich nicht gefunden.

Um die Images auf die Form zu bringen, nutze ich Arrays und TImage
Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
procedure Ship1Init;
var
  AIShip1 : integer;
  PosY  : integer;
begin
  ButtonKlick:=true;
  PosY:=10;
  for AIShip1 := 0  to ShipProRunde -1 do
  begin
    Main.AIShip1Typ[AIShip1]:=TImage.Create(Form1);
    AIShip1Typ[AIShip1].Parent:= Form1;
    AIShip1Typ[AIShip1].picture.LoadFromFile(ExtractFilePath(ParamStr(0))+'ship1.png');
    AIShip1Typ[AIShip1].autosize:=true;
    AIShip1Typ[AIShip1].Visible:=true;
    AIShip1Typ[AIShip1].Top:=PosX;
    AIShip1Typ[AIShip1].Left:=PosY;
//------------------------------------------------------------------------------
    AIShip1AttTyp[AIShip1]:=AIShip1Att;
    AIShip1DeffTyp[AIShip1]:=AIShip1Deff;
    AIShip1RangeTyp[AIShip1]:=AIShip1Range;
//------------------------------------------------------------------------------
    ShipVisi:=false;
    PosY:=PosY+50;
    //Posx:=PosX+2;
    if (PosY>=600then
    begin
      PosY:=0;
    end;
  end;
end;


und hier das bewegen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
for Ship1 := 0  to ShipProRunde -1 do
  begin
    //AIShip1Typ[Ship1].Visible:=false;//nur zu test zwecke vorhanden
    AIShip1Typ[Ship1].Top:=AIShip1Typ[Ship1].Top+stepX;
    AIShip1Typ[Ship1].Left:=PosY;
    //ShipVisi:=false;                 //nur zu test zwecke vorhanden
    //AIShip1Typ[Ship1].Visible:=true; //nur zu test zwecke vorhanden
    //AIShip1Typ[Ship1].Refresh;       //nur zu test zwecke vorhanden
    PosY:=PosY+50;
    if (PosY>=600then
    begin
      PosY:=0;
      PosX:=PosX+1;
    end;
  end;



wie ihr im Programm sehen könnt, flackern die Bilder richtig heftig, sobald man die Spiel Geschwindigkeit hoch dreht.
Aber wie kann ich das verhindern?
Einloggen, um Attachments anzusehen!
Stundenplan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 32

Win 7
Delphi 7 Pers., C# (VS 2010 Express)
BeitragVerfasst: So 21.03.10 09:13 
Zitat:
... eine Option wie Buffering o.ä. hab ich nicht gefunden.

:arrow: Form1.DoubleBuffered auf true setzen!
Xearox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260
Erhaltene Danke: 3



BeitragVerfasst: So 21.03.10 09:28 
super, ich danke dir...
wieso steht das denn niergends, überall steht zwar was von Double Buffer, aber niergends, das man Form1. davor schreiben kann... :(
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: So 21.03.10 16:51 
Das Form1. davor könntest du dir sparen wenn du DoubleBuffered := true; aus einer Methode von Form1 aufrufst. ;)

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.