Using the Clear() method?

BlitzMax Forums/BlitzMax Beginners Area/Using the Clear() method?

po(Posted 2006) [#1]
For my gorrilla remake I have a list that holds all of the crater objects. When a new game is made, I don't want the craters there anymore, but want to start a fresh list. All I see in the docs is that there is a Clear() method, but how do I use it to clear the list?
My type:
Type Crater

	Field x:Int,y:Int,size:Int

	Global CraterList:TList=New(TList)
	
	Method Draw()
	
		CollideRect(x+12,y+12,size-12,size-12,0,2)
	
		SetColor(55,155,255)
		DrawOval(x,y,size,size)
	
	End Method
	
	Method New()
		CraterList.AddLast(Self)
	End Method
	
	Method Clear()
	End Method
	
	Function Create:Crater(x:Int,y:Int,size:Int)
		Local c:Crater=New Crater
			c.x=x-size
			c.y=y-size
			c.size=size*2				
		Return c	
	End Function

End Type



tonyg(Posted 2006) [#2]
Either clearlist(createlist) or craterlist.clear() from within your creater type.
Alternatively, clearlist(crater.craterlist) or crater.clearlist.clear from anywhere else in your program.
For x = 0 To 5
	temp:crater = New crater
Next
Print crater.craterlist.count()
crater.craterlist.clear()
Print crater.craterlist.count()



FlameDuck(Posted 2006) [#3]
Function Clear()
  CraterList.Clear()
EndFunction



po(Posted 2006) [#4]
Awesome, thanks.