Results 1 to 7 of 7

Thread: Pixelcheck Collision Method Does Not Work

  1. #1

    Pixelcheck Collision Method Does Not Work

    Greetings,

    Well first of all, i discovered this bug in early 2003 :lol: and still doesn't know how to solve it. I am sure that You know what I mean, but if not I try to explain.

    When I setup PixelCheck:=True;
    in TImageSprite its behaviour doesn't change. I mean the Collision is detected by rectangles not by Pixels like It should be.
    What should I do? Is there any patches to this bug?

    Regards and thank You for Your time.

    Wodzu

  2. #2

    Pixelcheck Collision Method Does Not Work

    Hi!

    perhaps you should post your Sprite.Create method here and we have a look if we see some error.

    As far as I remember (years ago), the pixelcheck worked out well...

    Firle

  3. #3

    Pixelcheck Collision Method Does Not Work

    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.

  4. #4

    Pixelcheck Collision Method Does Not Work

    Hmm,.. perhaps not exactly what you want to hear but I tried your sample and I have a pixel perfect collision. :think:
    Code looks pretty much okay to me as well.

  5. #5

    Pixelcheck Collision Method Does Not Work

    Thank You for Your interest.

    I have pixelcheck collision working fine too. I changed my DelphiX version for that proposed by ijcro.
    Probably the old version had a bug in DXSprite.

    Regards,
    Wodzu

  6. #6

    Pixelcheck Collision Method Does Not Work

    Fine. So it is solved?

    Firle

  7. #7

    Pixelcheck Collision Method Does Not Work

    Yeah atleast.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •