Exist any way to overload methods in type declaration? Or other similar solution to simulate it?
Overloading methods?
BlitzMax Forums/BlitzMax Programming/Overloading methods? Method and function overloading is not supported on BlitzMax. A way to emulate it? Having several methods with different name and signature? Not sure... what are you trying to do exactly?
I want to make it
Type myObject1
Field sprite:TImage
Function Create:myObject1(sprite:TImage)
local obj:myObject1 = new myObject1
obj.sprite = sprite
return obj
End Function
EndType
Type myObject2 Extends myObject1
Field physic:myPhysicObject
Function Create:myObject1(sprite:TImage, physic:myPhysicObject)
local obj:myObject1 = new myObject1
obj.sprite = sprite
obj.physic = physic
return obj
End Function
EndType
Type myObject1
Field sprite:TImage
Function Create:myObject1(sprite:TImage)
local obj:myObject1 = new myObject1
obj.sprite = sprite
return obj
End Function
EndType
Type myObject2 Extends myObject1
Field physic:myPhysicObject
Function Create:myObject1(sprite:TImage, physic:myPhysicObject)
local obj:myObject1 = new myObject1
obj.sprite = sprite
obj.physic = physic
return obj
End Function
EndType
Sorry, it's not possible in bmax! Really inconvenient, I know. You can either use a different function name, like ziggy suggested, or abstract it out:
It's not very elegant, I know...
Type rootobject Field sprite:timage End Type Type myObject1 Extends rootObject Function Create:myObject1(sprite:TImage) Local obj:myObject1 = New myObject1 obj.sprite = sprite Return obj End Function EndType Type myObject2 Extends rootobject Field physic:myPhysicObject Function Create:myObject1(sprite:TImage, physic:myPhysicObject) Local obj:myObject1 = New myObject1 obj.sprite = sprite obj.physic = physic Return obj End Function EndType
It's not very elegant, I know...
Thanks Warpy.
Not apear to be other solution.
Hope this feature can be implemented on blitmaz future versions.
Not apear to be other solution.
Hope this feature can be implemented on blitmaz future versions.