Hi. I'm very familiar with Blitz but unfamiliar with BlitzMax. I'm having trouble figuring out how to retrieve data from objects stored in the list I pass to my create function.
I originally tried writing this line like this:
vertex = vertexlist.first()
but that generated this error message:
Unable to convert from 'Object' to 'TVertex'
So I converted it to this:
vertex.x = vertexlist.removefirst()
vertex.y = vertexlist.removefirst()
but x and y just equal the values of "1" and not the actual value they should have (which in this case, should be "0" and "500")
Type TVertex Field X:Int Field Y:Int End Type Type TGameObject Field X:Int Field Y:Int Field XSpeed:Float=3 Field YSpeed:Float=-3 'Field Image:TImage Field XScale:Float Field YScale:Float Method DrawSelf() SetScale XScale, YScale 'DrawImage Image,X,Y End Method Method UpdateSelf() Abstract End Type
Function LoadLevel(level) RestoreData level1 ReadData LvlTitle$ ReadData LvlNumObjects For iter = 1 To LvlNumObjects ReadData(ObjectType) Select ObjectType Case 1 'Rubberband Local vertex:TVertex = New TVertex Local vertexlist:TList = CreateList() For iter2 = 1 To 2 ReadData(vertex.X) ReadData(vertex.Y) ListAddLast vertexlist, vertex Next TRubberBand.Create(vertexlist) End Select Next End Function
Type TRubberBand Extends TGameObject Function Create:TRubberBand(vertexlist:TList) Local B:TRubberBand = New TRubberBand vertex:TVertex = New TVertex vertex.x = vertexlist.removefirst() 'doesn't work vertex.y = vertexlist.removefirst() 'doesn't work CreateObject(B, vertex.x, vertex.y) Return B End Function Method UpdateSelf() 'do nothing End Method EndType
I originally tried writing this line like this:
vertex = vertexlist.first()
but that generated this error message:
Unable to convert from 'Object' to 'TVertex'
So I converted it to this:
vertex.x = vertexlist.removefirst()
vertex.y = vertexlist.removefirst()
but x and y just equal the values of "1" and not the actual value they should have (which in this case, should be "0" and "500")