Intersect is not intersecting ... sometimes

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Peacfulrvr
Posts: 34
Joined: Mon Nov 03, 2014 7:11 pm

Intersect is not intersecting ... sometimes

Post by Peacfulrvr » Tue Nov 25, 2014 1:24 am

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

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Intersect is not intersecting ... sometimes

Post by [-hh] » Tue Nov 25, 2014 7:40 am

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).
shiftLock happens

Peacfulrvr
Posts: 34
Joined: Mon Nov 03, 2014 7:11 pm

Re: Intersect is not intersecting ... sometimes

Post by Peacfulrvr » Wed Nov 26, 2014 12:10 am

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?

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Intersect is not intersecting ... sometimes

Post by SparkOut » Wed Nov 26, 2014 12:19 am

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?

Peacfulrvr
Posts: 34
Joined: Mon Nov 03, 2014 7:11 pm

Re: Intersect is not intersecting ... sometimes

Post by Peacfulrvr » Wed Nov 26, 2014 1:09 am

No but I will give that a try and get back to you

Post Reply