Here's the thing ...
- I have a TSprite with a Draw() method and a SpecialDraw() method.
- I extend the TSprite to TPlayer
- TPlayer also has a draw() method (overriding TSprite.draw())
- In TPlayer.Draw() I call Super.Draw() then I call Super.SpecialDraw()
- SpecialDraw() changes SetBlend to LIGHTBLEND and then draws the sprite again over the top of the original by calling Draw(). This is where the problem lies. It get's stuck in an infinite loop because when SpecialDraw() calls Draw() it doesn't called TSprite.Draw() it must be calling TPlayer.Draw() which calls SpecialDraw() again and so on.
here's some example code:
I tried changing the draw call in SpecialDraw() with a typecast:
I tried changing typecasting Super as a TPlayer:
So then ... any bright ideas about how I can instruct it to call TSprite.Draw()? I know I could make TSprite.Draw() into a wrapper for another method called DoDraw() or something and then in SpecialDraw() call DoDraw() which, providing it isn't overridden in the extended type, will work (I've tested this), but that's pretty lame. There must be an easier way to do this. Ideas? Thanks in advance.
- I have a TSprite with a Draw() method and a SpecialDraw() method.
- I extend the TSprite to TPlayer
- TPlayer also has a draw() method (overriding TSprite.draw())
- In TPlayer.Draw() I call Super.Draw() then I call Super.SpecialDraw()
- SpecialDraw() changes SetBlend to LIGHTBLEND and then draws the sprite again over the top of the original by calling Draw(). This is where the problem lies. It get's stuck in an infinite loop because when SpecialDraw() calls Draw() it doesn't called TSprite.Draw() it must be calling TPlayer.Draw() which calls SpecialDraw() again and so on.
here's some example code:
Type TSprite Method Draw() End MEthod MEthod SpecialDraw() SetBlend LIGHTBLEND Draw() End Method End Type Type TPlayer extends TSprite Method Draw() 'overridden Super.Draw() Super.DrawSpecial End Method End Type
I tried changing the draw call in SpecialDraw() with a typecast:
TSprite(self).Draw()and this has the same hang.
I tried changing typecasting Super as a TPlayer:
TPlayer(Super).Draw()and this still hangs. Anyway this would be undersireable as it would only work for TPlayer and the whole point is I want sprites and exended sprites to be able to use SpecialDraw().
So then ... any bright ideas about how I can instruct it to call TSprite.Draw()? I know I could make TSprite.Draw() into a wrapper for another method called DoDraw() or something and then in SpecialDraw() call DoDraw() which, providing it isn't overridden in the extended type, will work (I've tested this), but that's pretty lame. There must be an easier way to do this. Ideas? Thanks in advance.