try this:
It is always good practice to explicitly type the objects. The Freeentity command is looking for a Tentity.
I would *highly* recommend using strict or superstrict while coding in blitzmax. It forces you to declare stuff but makes for much cleaner and easier to debug code. Here is your example using strict.
freeentity now removes the mesh and frees the memory. (I commented out the texture stuff so i could run it without your media, don't really need it for this test)
Type TestBall Field BallEntity:Tentity
It is always good practice to explicitly type the objects. The Freeentity command is looking for a Tentity.
I would *highly* recommend using strict or superstrict while coding in blitzmax. It forces you to declare stuff but makes for much cleaner and easier to debug code. Here is your example using strict.
freeentity now removes the mesh and frees the memory. (I commented out the texture stuff so i could run it without your media, don't really need it for this test)
'Import sidesign.minib3d Import "minib3d.bmx" Strict Local width=640,height=480,depth=16,mode=0 Graphics3D width,height,depth,mode Local cam:Tentity =CreateCamera() PositionEntity cam,0,0,-10 Local light:Tentity =CreateLight(1) Local MrBall:TestBall 'Global tex:TTexture =LoadTexture("examples\media\test.png") Global BallList:TList=CreateList() ;' used by camera code Local mxs#=0 Local mys#=0 Local move#=0.5 MouseXSpeed() ;' flush MouseYSpeed() ;' flush ;' used by fps code Local old_ms=MilliSecs() Local renders:Int Local fps:Int While Not KeyDown(KEY_ESCAPE) If KeyHit(KEY_ENTER) Then DebugStop ;'' control camera ;' mouse look If KeyDown(KEY_SPACE)=False mxs#=mxs#+(MouseXSpeed()/5.0) mys#=mys#+(MouseYSpeed()/5.0) RotateEntity cam,mys#,-mxs#,0 MoveMouse width/2,height/2 EndIf If KeyDown(Key_1) Then TestBall.Add FlushKeys EndIf If KeyDown(Key_2) Then If CountList(BallList) > 0 Then For MrBall = EachIn BallList 'Sloppy way to get last Ball Next MrBall.Remove FlushKeys EndIf EndIf MouseXSpeed() ;' flush MouseYSpeed() ;' flush ;' move camera forwards/backwards/left/right with cursor keys If KeyDown(KEY_UP)=True Then MoveEntity cam,0,0,move# ;' move camera forward If KeyDown(KEY_DOWN)=True Then MoveEntity cam,0,0,-move# ;' move camera back If KeyDown(KEY_LEFT)=True Then MoveEntity cam,-move#,0,0 ;' move camera left If KeyDown(KEY_RIGHT)=True Then MoveEntity cam,move#,0,0 ;' move camera right For MrBall = EachIn BallList MrBall.Spin Next RenderWorld renders=renders+1 ;' calculate fps If MilliSecs()-old_ms>=1000 old_ms=MilliSecs() fps=renders renders=0 EndIf Text 0,0,"FPS: "+fps Text 0,15,"Mem in Use: " + ((GCMemAlloced()) / 1000) + " KBs" Text 0,30,"Balls in World: "+CountList(BallList) Text 0,60,"Press 1 to Add a Ball" Text 0,75,"Press 2 to Remove a Ball" Flip Wend End Type TestBall Field BallEntity:Tentity Function Add() Local obj:TestBall obj:TestBall = New TestBall obj.BallEntity=CreateSphere(24) PositionEntity obj.BallEntity,CountList(BallList)*3,0,0 'EntityTexture obj.BallEntity,tex ListAddLast(BallList,obj:TestBall) End Function Method Remove() FreeEntity BallEntity BallList.Remove Self End Method Method Spin() TurnEntity BallEntity,0.2,1,0.1 End Method End Type