Page 1 of 1

Intersect is not intersecting ... sometimes

Posted: Tue Nov 25, 2014 1:24 am
by Peacfulrvr
I have a hand grabbing a phone...it is supposed to detect the collision between hand and phone but...
When the phone is moving it works
When the phone is stationary is does not
Here is the code.

command confiscated
if intersect (image"grabber.gif",image"phone.gif","pixels")then go to last card
end confiscated

command movephone pDirection
if pDirection is "right" then
set the right of image "phone.gif" to the right of image "phone.gif" +35
if right of the image "phone.gif" >800 then
set the right of image "phone.gif" to 800
end if

else if pDirection is "left" then
set the left of image "phone.gif" to the left of image "phone.gif" -35
if left of the image "phone.gif" <-120 then
set the left of image "phone.gif" to -120
end if
end if
confiscated
end movephone

Re: Intersect is not intersecting ... sometimes

Posted: Tue Nov 25, 2014 7:40 am
by [-hh]
Presumably you mean with "when the phone is stationary it does not" that you are moving the hand.

Obviously the rect of the hand is not continuously updated.

We have no chance to judge what's wrong because we don't know how you do this (by which handler).

Re: Intersect is not intersecting ... sometimes

Posted: Wed Nov 26, 2014 12:10 am
by Peacfulrvr
both the hand and the phone move at the same time. However if the player stops and does not move the phone then the intersect does not work. shouldn't the intersect work every time regardless of whether one of the objects is moving or not?

Re: Intersect is not intersecting ... sometimes

Posted: Wed Nov 26, 2014 12:19 am
by SparkOut
The intersect state will occur whenever there is an intersection. You need to check for this state in an appropriate way. You are testing for an intersect every time the movephone handler runs, when you execute the confiscated command. Do you execute the same confiscated command within the hand moving handler?

Re: Intersect is not intersecting ... sometimes

Posted: Wed Nov 26, 2014 1:09 am
by Peacfulrvr
No but I will give that a try and get back to you