Hi synaptic,
if you have animation engine then you could ask in the animation engine section.
Your script does not work because the repeat loop locks up the engine.
I changed your script to a non blocking one.
I declare 2 script local variables at the top of the script outside any handler. That way any handler in that script can access these variables. This way the final destination of img1 and img2 can be accessed.
Then I use a send in time construct to free Revolution from the lock-up. watchForCollision tests whether the images arrived at their destination, if not yet -> test for collision.
Code: Select all
local LOC1, LOC2
on mouseup
put random(500), random(500) into LOC1
put random(500), random(500) into LOC2
move img "img1" to LOC1 without waiting
move img "img2" to LOC2 without waiting
send watchForCollision to me in 130 milliseconds -- play with the intervall to let the two images get apart once they collided
end mouseup
on watchForCollision
if loc of image "img1" <> loc1 or the loc of image "img2" <> LOC2 then
if intersect(img "img1", img "img2") then
stop moving img "img1"
stop moving img "img2"
exit watchForCollision
end if
send watchForCollision to me in 5 milliseconds
end if
end watchForCollision
one problem with this is that once the images did collide then they have a tendency to collide again in the next move. In this version I allowed 130 milliseconds for the first collision test to let them get apart. You probably would want to test for collision before the move.
The subsequent tests for collision are done every 5 milliseconds until both images are at their final destination.
All that said, if you have animation engine then there are probably more elegant solutions then this one and I would try to get animation engine to work. (I dont have AE). And Malte (the author of animation engine) is very supportive.
regards
Bernd