Array of class

Monkey Forums/Monkey Programming/Array of class

Tri|Ga|De(Posted 2011) [#1]
I have a class like this:
Class ball
	Field ballI:Image
	Field ballX:Int
	Field ballY:Int	
End

And in my code I do like this:
	Global AmigaBall:ball[2]

Is this possible because if I do like this:
		AmigaBall[0].ballI = LoadImage("AmigaBall.png")
		AmigaBall[0].ballI.SetHandle(40, 40)

I do get an error running this

I want to make an array of the class ball


Canardian(Posted 2011) [#2]
You always need to instance a class with the New keyword:
Global amigaball:Ball[2]
amigaball[0]=New Ball
amigaball[1]=New Ball



Tri|Ga|De(Posted 2011) [#3]
Thanks thats it.