CollideImage Question

BlitzMax Forums/BlitzMax Programming/CollideImage Question

mangoo(Posted 2005) [#1]
Hi, either its a bug or i missconcieve CollideImage.
I thought the id parameter can be used to get an Object Address later on but it doesnt work.


In this example i create an Instance of a class and add it to a dynamic list, then i check collision and if collision occurs the object should be removed from list, but it doesnt work :(

i also tried to cast treffer[0] to Test, but no way.

Can somebody help me?




Note: The imagefile has to exist ;-)

Code:


Graphics 640,480,0
image$ = "tower.png"



Type Test
Field image:Timage
End Type


' Create an Instance of Test and add it to List
t:test = New test
t.image = LoadImage(image$)

list:TList = CreateList()
ListAddLast(list,t)



' Own Image
img:Timage =LoadImage(image$)



While Not KeyDown(KEY_ESCAPE)
Cls


ResetCollisions

'Instance Image
DrawImage t.image,100,100
CollideImage(t.image,100,100,0,0,1,t) '<----------------- Id = t, use Col Layer 1


' Own Image and Collision Check
DrawImage img,MouseX(),MouseY()
Local treffer:Object[] = CollideImage(img,MouseX(),MouseY(),0,1,0) ' Check Col Layer 1
If treffer
DebugLog "HIT"
' Remove id from list
ListRemove(list,treffer[0]) ' Use first Object in List
EndIf

'How big is da List???!? always 1 :-(
DrawText Len(list),0,0
Flip
Wend


teamonkey(Posted 2005) [#2]
That's very strange. I'm sure it should work like that, but treffer[0] is Null, which is why ListRemove doesn't work.

It's a bug in CollideQuads, I think, but I can't work out where.


mangoo(Posted 2005) [#3]
me neither :-(

such a good idea and then a bug *arggggg*


skidracer(Posted 2005) [#4]
The function len does not return how many elements in a list CountList() does.


teamonkey(Posted 2005) [#5]
I saw that - it's not the problem.


skidracer(Posted 2005) [#6]
arrgh, the fix I think is line 1326 in max2d.bmx:

q.id=id

replaces

q.id=p.id


teamonkey(Posted 2005) [#7]
That fixes it. Job's a good 'un. :D