Looking at the Code snipet Below. In the Universe Type, UpdateAllObjects function. How can I cast if the Objects:Universe is a Tplanet or TShip.
What I have does not work. This code will not run as is because I removed a lot of stuff to post.
The Error I get is Expression of Type Universe can't be invoked.
Thanks in Advance for any help
What I have does not work. This code will not run as is because I removed a lot of stuff to post.
The Error I get is Expression of Type Universe can't be invoked.
Thanks in Advance for any help
Global ObjectList:Tlist=New Tlist Type Universe Method Draw() Abstract Method remove() Link.Remove End Method Method AddLast( list:TList ) Link=List.AddLast( Self ) End Method Function DrawAllObjects() For Local Objects:Universe=EachIn ObjectList If Objects(TPlanet)<>Null ' DrawText "Planet",Objects.Position.X,Objects.Position.Y+60 End If Objects.Draw() Next End Function End Type Type TPlanet Extends Universe Method Draw() DrawOval Position.X-25,Position.Y-25,50,50 End Method Function Create:TPlanet(X:Float,Y:Float,M:Float) Local Planet:TPlanet=New TPlanet Planet.AddLast(ObjectList:Tlist) Return Planet End Function End Type Type TShip Extends Universe Method Draw() DrawRect Position.X-2,Position.Y-2,5,5 End Method Function Create:TShip(X:Float,Y:Float,M:Float) Local Ship:TShip=New TShip Ship.AddLast(ObjectList:Tlist) Return Ship End Function End Type Repeat Cls Universe.DrawAllObjects() Flip Until KeyHit(Key_Escape)