"type global initialisers must be constant" help

BlitzMax Forums/BlitzMax Beginners Area/"type global initialisers must be constant" help

Amon_old(Posted 2005) [#1]
In my current program it gives me this error. It points to the method below in my program.

	Method update_tiles()
	
		For Local i:Int = 0 To 8
		
			DrawImage tiles,t.txpos+50,t.typos,frame
			
			frame:+1
				
			If frame >= 8	 Then frame = 0
							
		Next
		
	End Method


Here is the whole code


Strict

Rem 
MapEditor Version 0.1
Author   : Amon
Compiler : BlitzMax
EndRem

Incbin "backblock.png"
Incbin "icon.png"

Graphics 800,600,16,0

tiles:TImage = LoadAnimImage("incbin::backblock.png",50,50,0,9,MASKEDIMAGE)

Global map:Int[16,12]

Global xoff:Int, yoff:Int, number:Int

number = 0

Type tile

	Global tilelist:TList = CreateList()
	
	Field xpos:Int,ypos:Int
	
End Type

Type tileset

	Global tilesetlist:TList = CreateList()

	Field txpos:Int, typos:Int
	
	Global frame = 0
	
	Function create_tileset()
		
		t:tileset = New tileset
		t.txpos = 0
		t.typos = 550
		ListAddLast tilesetlist,(t)
		
			
	End Function
	
	Method update_tiles()
	
		For Local i:Int = 0 To 8
		
			DrawImage tiles,t.txpos+50,t.typos,frame
			
			frame:+1
				
			If frame >= 8	 Then frame = 0
							
		Next
		
	End Method
	
End Type

create_tileset()		

Repeat 

	Cls
	
		For Local t:tileset = EachIn tilesetlist
	
			t.update_tiles()
			
		Next
	
	Flip
	
Until KeyHit(KEY_ESCAPE)





Perturbatio(Posted 2005) [#2]
without running the code or putting too much thought into it, this looks like a possible cause:

Type tileset

	Global tilesetlist:TList = CreateList()



Amon_old(Posted 2005) [#3]
yep. That fixed it. Thanx dude :0


BlitzSupport(Posted 2005) [#4]
Amon, you might want to take a look at rockout.bmx to see how I handled this, in the 'New' method of the GravityItem type. Dunno if it's considered 'proper' in the overly strict world of OO, but it works for me!


Dreamora(Posted 2005) [#5]
Yes it is considered the proper way as new is the constructor of a type instance while delete is the "destructor"