wow the debate rages on.
Sswift: I've had a TSprite for ages in the framework. I was just adding some extra functionality today for when the player/alien gets hit, so they can flash brighter. Glad you can see my point. The rest of the OOP is fine, but there ought to be a way to call the base type Draw() in fact that's what I'm expecting it to do in this case, but it doesn't... Actually there are cases where you *wouldn't* want it to call the base type Draw() as well when in TSprite so I guess it's swings and roundabouts.
Alex.O: nice bit of code thanks.
Nelvin: Don't worry I understand OOP and Polymorphism fine. I already thought of making a wrapper for Draw() as per my first post where I mentioned DoDraw(). But I decided this was less desirable if there was a quick and easy way to be able to call the basetype's draw() from within itself, rather than it calling the exended type's overridden draw().
If you are able to call super.draw() from within TPlayer, why can't you can't draw() in some special way within TSprite and have it call TSprite's draw()? I can see why "self" fails, because self is still a TPlayer. So I typecasted self as TSprite but that still didn't work because polymorphism is still working of course. So it sounds like basically there is no way to do this without making a wrapper function to avoid "cycling contexts", or using renderstates ... sigh. The code is working fine right now using a wrapper function, I just found that a bid sad :-(
Sswift: I've had a TSprite for ages in the framework. I was just adding some extra functionality today for when the player/alien gets hit, so they can flash brighter. Glad you can see my point. The rest of the OOP is fine, but there ought to be a way to call the base type Draw() in fact that's what I'm expecting it to do in this case, but it doesn't... Actually there are cases where you *wouldn't* want it to call the base type Draw() as well when in TSprite so I guess it's swings and roundabouts.
Alex.O: nice bit of code thanks.
Nelvin: Don't worry I understand OOP and Polymorphism fine. I already thought of making a wrapper for Draw() as per my first post where I mentioned DoDraw(). But I decided this was less desirable if there was a quick and easy way to be able to call the basetype's draw() from within itself, rather than it calling the exended type's overridden draw().
If you are able to call super.draw() from within TPlayer, why can't you can't draw() in some special way within TSprite and have it call TSprite's draw()? I can see why "self" fails, because self is still a TPlayer. So I typecasted self as TSprite but that still didn't work because polymorphism is still working of course. So it sounds like basically there is no way to do this without making a wrapper function to avoid "cycling contexts", or using renderstates ... sigh. The code is working fine right now using a wrapper function, I just found that a bid sad :-(