Greetings,
And Thank You for Your reply once again Firlefranz
Please tak a look at the example.
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXDraws, DXClass, DXSprite;
type
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXSpriteEngine1: TDXSpriteEngine;
DXTimer1: TDXTimer;
DXImageList1: TDXImageList;
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMySmallSprite = class(TImageSprite)
public
procedure DoMove(MoveCount: Integer); override;
procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;
end;
var
Form1: TForm1;
MySmallSprite: TMySmallSprite;
MyLargeSprite: TImageSprite;
implementation
{$R *.dfm}
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
if not DXDraw1.CanDraw then Exit;
DXDraw1.Surface.Fill(0);
DXSpriteEngine1.Draw;
DXSpriteEngine1.Move(0);
with DXDraw1.Surface.Canvas do
begin
Release;
end;
DXDraw1.Flip;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyLargeSprite:=TImageSprite.Create(DXSpriteEngine1.Engine);
with MyLargeSprite do
begin
Image := DXImageList1.Items.Find('1');
X:=50;
Y:=100;
Z := 1;
Width := Image.Width;
Height := Image.Height;
PixelCheck:=True;
end;
MySmallSprite:=TMySmallSprite.Create(DXSpriteEngine1.Engine);
with MySmallSprite do
begin
Image := DXImageList1.Items.Find('2');
X:=300;
Y:=150;
Z := 1;
Width := Image.Width;
Height := Image.Height;
PixelCheck:=True;
end;
end;
procedure TMySmallSprite.DoCollision(Sprite: TSprite; var Done: Boolean);
begin
inherited;
if Sprite is TImageSprite then
X:=300;
end;
procedure TMySmallSprite.DoMove(MoveCount: Integer);
begin
inherited;
X:=X-1;
PixelCheck:=True; //in example which doesnt work also, this line was here
Collision;
end;
end.
Bookmarks