Strict
Type Ball
Field x
Field y
Field bl:TList
Function Create:Ball(_x:Int, _y:Int)
Local b:Ball
b=New Ball
b.x=_x
b.y=_y
If b.bl=Null Then b.bl=New TList
Return(b)
End Function
Function ShowBalls()
Local b:Ball=New Ball
For b:Ball=EachIn b.bl
Print "lol"
Next
End Function
End Type
Local b:Ball=Ball.Create(50,50)
b.ShowBalls()
WaitKey()
I just want to create an object called Ball, if i call ShowBalls, i get this Error:
Unhandled Exception: Attempt to access field or method of Null object
ShowBalls [$BMXPATH/regaa/temp/temp.bmx;21;3]
I know where the mistake is, but dont know how to solv this without global variables :(.
Type Ball
Field x
Field y
Field bl:TList
Function Create:Ball(_x:Int, _y:Int)
Local b:Ball
b=New Ball
b.x=_x
b.y=_y
If b.bl=Null Then b.bl=New TList
Return(b)
End Function
Function ShowBalls()
Local b:Ball=New Ball
For b:Ball=EachIn b.bl
Print "lol"
Next
End Function
End Type
Local b:Ball=Ball.Create(50,50)
b.ShowBalls()
WaitKey()
I just want to create an object called Ball, if i call ShowBalls, i get this Error:
Unhandled Exception: Attempt to access field or method of Null object
ShowBalls [$BMXPATH/regaa/temp/temp.bmx;21;3]
I know where the mistake is, but dont know how to solv this without global variables :(.