Problems with Abstract Type's New Method overload
Monkey Forums/Monkey Programming/Problems with Abstract Type's New Method overload
| ||
Class SpriteLogic Abstract
Field spritePtr:Sprite
Method New (sprite:Sprite)
spritePtr = sprite
OnInit()
End
Method New()
Error ("SpriteLogic.New: Extended classes of SpriteLogic require a Sprite as an argument.")
End
Method OnInit:Void() Abstract
Method Update:Void() Abstract
Method OnEvent:Void (id:Int) Abstract
End
Class CommonLogic Extends SpriteLogic
Method OnInit:Void()
End
Method Update:Void()
End
Method OnEvent:Void (id:Int)
End
End
I want it so that all Classes extending from SpriteLogic have to use the New(sprite) Method. But if i now try to call: New CommonLogic(someSprite) the compiler fails: Unable to find overload for new(Sprite). If I just call New() it will throw my error as expected. Is this not allowed? There is nothing in the docs(language reference) about Abstract. |
| ||
| Nope, monkey will always generate a default constructor and will call it by default if you don't manually call one. This is a problem I've been complaining about to Mark for months with no response. Edit: Sorry I DID get a response, but I don't think it was really an acceptable one... >_> <3 Mark |
| ||
| Ok thanks, will work around it then. |
| ||
| Ok thanks, will work around it then. If you look in the diddy GUI you'll see a lot of: Method New() NoParent() End Which calls: Function NoParent:Void()
AssertError("Must pass a parent component.")
End |