Einzelnen Beitrag anzeigen

ferby

Registriert seit: 15. Aug 2004
Ort: Wien
841 Beiträge
 
Delphi 2010 Enterprise
 
#6

Re: kollision bei delphix geht nicht

  Alt 29. Sep 2005, 19:05
Hallo,

geht leider immer noch nicht... es passiert nichts sobald sich die zwei grafiken berühren.

hier der etwas abgeänderte quellcode:

Delphi-Quellcode:
TGegenstand = class(TImageSprite)
  Public
    Procedure DoMove(MoveCount: Integer);override;
  end;

  TAnimation = class(TImageSprite)
  Public
    Procedure DoMove(MoveCount: Integer);override;
    Procedure DoCollision(Sprite: TSprite; var Done: Boolean);override;
  end;

var
  Form1: TForm1;

  Gegenstand: TGegenstand;
  Animation: TAnimation;

implementation

{$R *.dfm}
//////////////////////////////////////////////////////////////////////////////// FORM CREAT
procedure TForm1.FormCreate(Sender: TObject);
begin
  gegenstand := Tgegenstand.Create(DXSpriteEngine2.Engine);
  Animation := TAnimation.Create(DXSpriteEngine1.Engine);

  with gegenstand do
  begin
    Image := Form1.DXImageList1.Items.Find('planet1');
    X := 250;
    Y := 50;
    Width := Image.Width;
    Height := Image.Height;
    AnimCount := 4;
    AnimLooped := True;
    AnimSpeed :=1;
  end;

  with Animation do
  begin
    Image := Form1.DXImageList1.Items.Find('schiff');
    X := 50;
    Y := 100;
    Width := Image.Width;
    Height := Image.Height;
    AnimCount := 3;
    AnimLooped := True;
    AnimSpeed :=1;
  end;
end;

//////////////////////////////////////////////////////////////////////////////// Schiff
Procedure TAnimation.DoMove(MoveCount: Integer);
Begin
  Inherited DoMove(MoveCount);
  If IsUp in Form1.DXInput1.States Then Y:=Y-4;
  If IsLeft in form1.DXInput1.States Then X:=X-4;
  If IsDown in form1.DXInput1.States Then Y:=Y+4;
  If IsRight in form1.DXInput1.States Then X:=X+4;
  Collision;
end;

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
  DXInput1.Update;
  DXSpriteEngine1.Move(1);
  DXSpriteEngine2.Move(1);

  DXDraw1.Surface.Fill(0);
  DXSpriteEngine1.Draw;
  DXSpriteEngine2.Draw;

  DXDraw1.Flip;
end;


procedure TAnimation.DoCollision(Sprite: TSprite; var Done: Boolean);
begin
 if (sprite is TGegenstand) then showmessage('test');
end;

Procedure TGegenstand.DoMove(MoveCount: Integer);
Begin
  Inherited DoMove(MoveCount);
  X:=X-1;
end;


Was ist daran falsch??


Ferby
  Mit Zitat antworten Zitat