Results 1 to 3 of 3

Thread: Overriding the DoDraw Procedure

  1. #1

    Overriding the DoDraw Procedure

    When creating a class in delphiX for a character and, for instance, I wanted to draw the sprite rotated at an angle using the sprite engine, my code looked as follows:
    Code:
     THero = class(TImageSprite)
      Speed : Integer;
      Public
       Procedure DoMove(MoveCount: Integer); override;
       procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;
       Procedure DoDraw; override;
      end;
    It works... but the sprite gets drawn twice!! Once rotated and once normal. I probably set up the DoDraw incorrectly
    Any ideas?

  2. #2

    Re: Overriding the DoDraw Procedure

    and how does your dodraw-procedure look like?
    perhaps there is an 'inherited' too much in it

  3. #3

    Re: Overriding the DoDraw Procedure

    First of all, do you call OnDraw yourself? You should call SpriteEngine.Draw instead

    If that's not the sollution, does your DoDraw procedure contain "inherited;". This reserved-word calls the DoDraw procedure implemented by the ancestor class (Probably TImageSprite), which means that the sprite will be rendered twice.

    If the problem persists, i suggest you to step through your code using breakpoints. Put breakpoints in the DoDraw procedures and one at "SpriteEngine.Draw". Start stepping through your code from there to what get's called. No doubt you'll be able to figure it out.

    As a last resort you can also use TSprite instead and implement all specific rendering yourself.

    Hope it helps.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

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
  •