AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Array von TShapes visible machen

Ein Thema von Shoqez · begonnen am 19. Nov 2020 · letzter Beitrag vom 19. Nov 2020
 
Shoqez

Registriert seit: 19. Nov 2020
5 Beiträge
 
#6

AW: Array von TShapes visible machen

  Alt 19. Nov 2020, 11:04
Ich fülle den array mit den shapes 1 bis 50 aber ich dachte wenn der array [1..50] eingestellt ist, nimmt das Programm automatisch die ersten 50 Shapes in meiner Form.
Du widersprichst dir. Einerseits schreibst du, dass du sie füllst (Schleife mit shape[i] := ...), andererseits schreibst du, dass du von einer Automatik "die ersten 50 Shapes in meiner Form" ausgehst.

Wie wäre es, wenn du einfach mal mehr Quelltext zeigst?
Das Problem ist, dass ich das Prinzip Schleife noch nicht so wirklich durchschaut habe. Alles Klar, hier mein Quelltext:
Delphi-Quellcode:
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  Buttons;

type

  { TForm1 }

  TForm1 = class(TForm)
    btngo: TButton;
    Button1: TButton;
    Image1: TImage;
    Shape1: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape2: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    Shape28: TShape;
    Shape29: TShape;
    Shape3: TShape;
    Shape30: TShape;
    Shape31: TShape;
    Shape32: TShape;
    Shape33: TShape;
    Shape34: TShape;
    Shape35: TShape;
    Shape36: TShape;
    Shape37: TShape;
    Shape38: TShape;
    Shape39: TShape;
    Shape4: TShape;
    Shape40: TShape;
    Shape41: TShape;
    Shape42: TShape;
    Shape43: TShape;
    Shape44: TShape;
    Shape45: TShape;
    Shape46: TShape;
    Shape47: TShape;
    Shape48: TShape;
    Shape49: TShape;
    Shape5: TShape;
    Shape50: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    procedure btngoClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Image1Click(Sender: TObject);
    procedure Timer1StartTimer(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;
  inils,iemmi,iphillip,ipauline,imichi,z1,z2,z3,z4,i:integer;
  shape: array [1..50] of tshape;



implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Image1Click(Sender: TObject);
begin

end;

procedure TForm1.Timer1StartTimer(Sender: TObject);
begin
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin

end;


procedure TForm1.FormCreate(Sender: TObject);
begin

 inils:=0;
 iemmi:=0;
 iphillip:=0;
 ipauline:=0;
 imichi:=0;


end;

procedure TForm1.btngoClick(Sender: TObject);
begin
 //Zufallsgen
  randomize;
  z1:=random(2);
  z2:=random(2);
  z3:=random(2);
  z4:=random(2);
//Implementation
  If z1 =0
  then if z2=0
       then if z3=0
            then if z4=0
                 then inils:=inils+1
                 else iemmi:=iemmi+1
            else if z4=0
                 then iemmi:=iemmi+1
                 else iphillip:=iphillip+1
       else if z3=0
            then if z4=0
                 then iemmi:=iemmi+1
                 else iphillip:=iphillip+1
            else if z4=0
                 then iphillip:=iphillip+1
                 else ipauline:=ipauline+1
  else if z2=0
       then if z3=0
            then if z4=0
                 then iemmi:=iemmi+1
                 else iphillip:=iphillip+1
            else if z4=0
                 then iphillip:=iphillip+1
                 else ipauline:=ipauline+1
       else if z3=0
            then if z4=0
                 then iphillip:=iphillip+1
                 else ipauline:=ipauline+1
            else if z4=0
                 then ipauline:=ipauline+1
                 else imichi:=imichi+1;
//button deaktivieren
if imichi+ipauline+iemmi+iphillip+inils=10
then btngo.enabled:= false;

//Kugel sichtbarkeit
case inils of
     1: shape1.visible:=true;
     2: shape2.visible:=true;
     3: shape3.visible:=true;
     4: shape4.visible:=true;
     5: shape5.visible:=true;
     6: shape6.visible:=true;
     7: shape7.visible:=true;
     8: shape8.visible:=true;
     9: shape9.visible:=true;
     10: shape10.visible:=true;
end;

case iemmi of
     1: shape11.visible:=true;
     2: shape12.visible:=true;
     3: shape13.visible:=true;
     4: shape14.visible:=true;
     5: shape15.visible:=true;
     6: shape16.visible:=true;
     7: shape17.visible:=true;
     8: shape18.visible:=true;
     9: shape19.visible:=true;
     10: shape20.visible:=true;
end;

case iphillip of
     1: shape21.visible:=true;
     2: shape22.visible:=true;
     3: shape23.visible:=true;
     4: shape24.visible:=true;
     5: shape25.visible:=true;
     6: shape26.visible:=true;
     7: shape27.visible:=true;
     8: shape28.visible:=true;
     9: shape29.visible:=true;
     10: shape30.visible:=true;
end;

case ipauline of
     1: shape31.visible:=true;
     2: shape32.visible:=true;
     3: shape33.visible:=true;
     4: shape34.visible:=true;
     5: shape35.visible:=true;
     6: shape36.visible:=true;
     7: shape37.visible:=true;
     8: shape38.visible:=true;
     9: shape39.visible:=true;
     10: shape40.visible:=true;
end;

case imichi of
     1: shape41.visible:=true;
     2: shape42.visible:=true;
     3: shape43.visible:=true;
     4: shape44.visible:=true;
     5: shape45.visible:=true;
     6: shape46.visible:=true;
     7: shape47.visible:=true;
     8: shape48.visible:=true;
     9: shape49.visible:=true;
     10: shape50.visible:=true;
end;





end;

procedure TForm1.Button1Click(Sender: TObject);
begin

inils:=0;
 iemmi:=0;
 iphillip:=0;
 ipauline:=0;
 imichi:=0;
 btngo.enabled:=true;


for i:=1 to 50 do
begin
shape[i].visible:=false;
end;




end ;



end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:13 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