Functions

Blitz3D Forums/Blitz3D Beginners Area/Functions

Ross C(Posted 2003) [#1]
Hey, do functions reset the type pointer? Say i create a single type object, say a ball for break-out. When i call a function to do something to the type, it says it doesn't exist.

Function Check_Ball()
     If B\x>400 Then B\direction_x=-1
End Function



Now, if i add:

Function Check_Ball()
     For B.Ball=Each Ball
          If B\x>400 Then B\direction_x=-1
     Next
End Function


It works. Is this normal behaviour. Seems strange, as i though types were always Global. The exact error is,

"Variable is not a Type"

When i add the for next loop in to cycle thru the one object, it works.


Beaker(Posted 2003) [#2]
The Type objects are global but the pointers to them are not (unless you declare them as such).
Global B.Ball = New Ball
Function Check_Ball()
     If B\x>400 Then B\direction_x=-1
End Function



Ross C(Posted 2003) [#3]
Oh, i never knew you could do that! Thanks man, saved me a headache ;)