No. I actually meant this ...
' Main.bmx
Strict
Global TestAlien:Alien
Global TestCar:Car
Global MyList:TList
MyList = CreateList()
' the base object
Type BaseObject
Field Active:Int = False ' Is the object active ( alive )
Field x:Float = 0.0 ' x position
Field y:Float = 0.0 ' y psoition
Method Setup() Abstract
Method Info()
Print Active
Print x
Print y
End Method
End Type
' A derived object
Type Alien Extends BaseObject
Field Colour:String = "Red"
Method Setup()
Active = True
x = 10
y = 100
Colour = "Green"
End Method
Method Info()
Super.Info()
Print Colour
End Method
End Type
' Another derived Object
Type Car Extends BaseObject
Field CarType:String = "lorry"
Method Setup()
Active = True
x = 1000000
y = 1000000
CarType = "Boat"
End Method
Method Info()
Super.Info()
Print CarType
End Method
End Type
TestAlien:Alien = New Alien
TestCar:Car = New Car
MyList.AddLast(TestAlien)
MyList.AddLast(TestCar)
For Local TempObject:BaseObject = EachIn MyList
TempObject.Setup()
TempObject.Info()
Next
... I just couldnt find some of this stuff in the docs.
Cheers anyway.
' Main.bmx
Strict
Global TestAlien:Alien
Global TestCar:Car
Global MyList:TList
MyList = CreateList()
' the base object
Type BaseObject
Field Active:Int = False ' Is the object active ( alive )
Field x:Float = 0.0 ' x position
Field y:Float = 0.0 ' y psoition
Method Setup() Abstract
Method Info()
Print Active
Print x
Print y
End Method
End Type
' A derived object
Type Alien Extends BaseObject
Field Colour:String = "Red"
Method Setup()
Active = True
x = 10
y = 100
Colour = "Green"
End Method
Method Info()
Super.Info()
Print Colour
End Method
End Type
' Another derived Object
Type Car Extends BaseObject
Field CarType:String = "lorry"
Method Setup()
Active = True
x = 1000000
y = 1000000
CarType = "Boat"
End Method
Method Info()
Super.Info()
Print CarType
End Method
End Type
TestAlien:Alien = New Alien
TestCar:Car = New Car
MyList.AddLast(TestAlien)
MyList.AddLast(TestCar)
For Local TempObject:BaseObject = EachIn MyList
TempObject.Setup()
TempObject.Info()
Next
... I just couldnt find some of this stuff in the docs.
Cheers anyway.