Overloading SetScale SetAlpha etc.
BlitzMax Forums/BlitzMax Beginners Area/Overloading SetScale SetAlpha etc.
| ||
I've got a mod in the works and one of the things I have is a type called TObject and this object can have a sprite and properties such as x,y,alpha,rotation,direction etc. I have many methods at the moment, such as: getObjX, getObjScale, getObjRotation etc. ...but I'd like to overload the methods getScale and getRotation instead. When I do this I don't get any errors but my scaling is all wrong. If I on the other hand do a small scale isolated test: Type TType Field a:Int Method SetScale(b:Int,d:String,e:Float) Self.a = Self.b Print d End Method EndType c:TType = New TType Print c.a c.SetScale(2,"test",1.3) Print c.a ...it doesn't appear to be any problem. Is there a fundamental issue about overloading methods that I'm missing or should I just avoid it? |
| ||
obviously the code you posted above does not work and does give an error sense there is no b field. I assume you are trying to assign parameter b to field a. so it should be. self.a = b other than that I don't really understand what you are trying to do. that type of overloading is fine the only problem you would have is with reserved words like "and","If" etc. Last edited 2010 |
| ||
is this what you are looking for: |
| ||
Thanks for the replies, and sorry for the error in the demo code. Zeke, your example solved it for me! What an ace :) When I did a "search & replace" for my methods such as SetObjRotation and SetObjScale to SetRotation and SetScale etc. my code got confused by the "real" SetRotation and SetScale (which is what I feared.) What I didn't know was the "." (on line 17) which effectively used the proper graphics functions rather than my custom methods. Again this forum, and everyone in it, proves to be amazing =) |