Collision detection (again)

BlitzMax Forums/BlitzMax Programming/Collision detection (again)

Regular K(Posted 2006) [#1]
I can't get collision detection to return an object, well, I can but I can't use methods in that object. That which makes it pretty useless. I check to see if the object is the correct type (TPill), then I try to call a method in the super of TPill (that is TEntity, method is Destory).

The compile error I get is: Identifier 'Destroy' not found

Checking for a collision:
Local c:Object[]=CollideRect(X-8,Y-8,24,24,1,0)
If c.length>0 And c[0]<>Null
	If TPill(c[0])
		c[0].Destroy()
	EndIf
EndIf


Adding the collision thingy to the thingy system before collision code is ran: (in a method)
CollideRect(X*32+12,Y*32+12,4,4,0,1,Self)


Actual collision works, but its useless if I can't access the methods of the object it collides with.

Thanks ;)


Perturbatio(Posted 2006) [#2]
you might want to post the source portion that contains TEntity and TPill as well.


Dreamora(Posted 2006) [#3]
If you get the collision array back, do you parse the object (yes you get back an object, not a TEntity or a TPill ie without casting no methods!) correctly to their types?


Regular K(Posted 2006) [#4]
That must be my problem, how do I cast the object to a TPill?

(I still dont understand OOP 100%)


Perturbatio(Posted 2006) [#5]

If TPill(c[0])
c[0].Destroy()
EndIf




Regular K(Posted 2006) [#6]
:) Thanks for that hint Perurbatio, I got it ;)