Method overwrites or callbacks... how to?
BlitzMax Forums/BlitzMax Programming/Method overwrites or callbacks... how to? Thansk!
ok, but this doesnt work.
(additionaly, i tried using no parameter and reference to Self. but that is not allowed outside a Type Method)
(additionaly, i tried using no parameter and reference to Self. but that is not allowed outside a Type Method)
Type test Field parent = Self Field text:String = "blahh!" Field call:Int() Method test() Self.call() End Method Method unload() Self.parent = Null End Method End Type a:test = New test a.call = movement a.test() Function movement(parent:Int) Print parent.text End Function
I guess it doesn't work because "movement" has a parameter, and "call" doesn't. :)
The parameter number and types have to match.
What are you trying to do?
Edit: fixed a bit...
Edit: And once more for clarity
Type TTest Field text:String = "blahh!" Field call:Int(parent:TTest) Method test() call(Self) End Method End Type Local a:TTest = New TTest a.call = movement a.test() Function movement(parent:TTest) Print parent.text End Function
Edit: fixed a bit...
Edit: And once more for clarity
Ok, im trying to make a custom movement, which is attachable in runtime.
I changed the proto code to something clear for other uses to see as well. Thanks for all the help guys.
I changed the proto code to something clear for other uses to see as well. Thanks for all the help guys.
Type Player Field x:Int Field y:Int Field movement:Int(player:Player) Method setPosition(x:Int, y:Int) Self.x = x Self.y = y End Method Method move() movement(Self) End Method End Type Local a:Player = New Player a.setPosition 32, 64 a.movement = mymovement a.move() Function myMovement(player:Player) Print "moving to: " + player.x + ", " + player.y End Function