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
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