CollideImage Question
BlitzMax Forums/BlitzMax Programming/CollideImage Question
| ||
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 |
| ||
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. |
| ||
me neither :-( such a good idea and then a bug *arggggg* |
| ||
The function len does not return how many elements in a list CountList() does. |
| ||
I saw that - it's not the problem. |
| ||
arrgh, the fix I think is line 1326 in max2d.bmx: q.id=id replaces q.id=p.id |
| ||
That fixes it. Job's a good 'un. :D |