Page 1 of 1
Intersect issue
Posted: Tue Apr 26, 2011 9:21 pm
by unclewayne
When the 2 items overlap the score just keeps going up. how do i make it add 1 and stop every time they intersects.
if intersect (graphic "trigger", image "sliderKnob") then
add 1 to fld "score"
end if
Re: Intersect issue
Posted: Tue Apr 26, 2011 10:00 pm
by dburdan
Not Available
Re: Intersect issue
Posted: Wed Apr 27, 2011 11:06 am
by Klaus
Hi Wayne,
yep, Dacri is right, since intersect() is a function that will probably not call itself,
we need to look at the condition that will trigger it!
In other words: show us more code!
Best
Klaus
Re: Intersect issue
Posted: Wed Apr 27, 2011 4:03 pm
by unclewayne
Hey Dacri,
I was using some of that code. When the slider gets to the end i want it to add 1 to the score field. Right now when I get to the end the score keep going up.
On top of that I was wondering if there is anyway to play and stop an animated gif or some other type of animation. Basically, when the slider gets to the end I want it to add one to the score field and play an animation and pause it. then when you hit the end again it will unpause the animation and then pause it again and add 1 to the score field. All of these actions should happen while your finger is on the slider the whole time. Think of it as a broom and the dirt piles up after each swipe.
Re: Intersect issue
Posted: Wed Apr 27, 2011 4:51 pm
by Klaus
Hi Wayne,
unclewayne wrote:Hey Dacri,
I was using some of that code. When the slider gets to the end i want it to add 1 to the score field. Right now when I get to the end the score keep going up.
there is not IF... END IF in Dacris example, so please post more of your code if you want our help!
To control animated GIFs, check these terms in the LiveCode dictionary:
currentframe
framecount
palindromeframes
repeatcount
Best
Klaus
Re: Intersect issue
Posted: Wed Apr 27, 2011 6:30 pm
by unclewayne
Sorry about that, i added that bit in. it works perfectly except for the climbing numbers.
on constrainRectangularCallback
-- Get the distance of the start line & center theslider thumb
get distance(the location of graphic "startLine", the location of image "sliderKnob") //Get the distance that the slider has traveled so far.
put it into SliderDistance //Put that distance into a variable
divide sliderDistance by 2 //Divide it by 2 to get it to around 100
put round(SliderDistance) into sliderDistance //Round it to the nearest number to avoid errors.
set the blendLevel of field "unlockText" to round(sliderDistance * 2) + 10 //Change the opacity of the "Slide To Unlock" text just like on the iphone. Add 15 to it to make it fade sooner
if intersect (graphic "trigger", image "sliderKnob") then
add 1 to field "score"
end if
end constrainRectangularCallback
Re: Intersect issue
Posted: Wed Apr 27, 2011 8:01 pm
by dburdan
Hey Wayne,
Try using a switch and position.
Code: Select all
switch the location of image "sliderKnob"
case 50, 200 //Just an example
add 1 to score //Add 1 to the score variable
put "Score:" && score into field "score" //Put "Score:" and your score into a text field
move image "sliderKnob" to 50, 100 in 300 milliseconds. //Move the slider back to it's original location. This will evaluate the switch to false.
end switch
Since the move command is last, it will stop the switch, evaluating it to false.
As far as the animation part, did you mean something similar to how I faded the text? As the bar moves further along the rect, the texts starts to fade. Then when you pull back or let go, the texts returns to full opacity.
Code: Select all
set the blendLevel of field "unlockText" to round(sliderDistance * 2) + 10 //Change the opacity of the "Slide To Unlock" text just like on the iphone. Add 15 to it to make it fade sooner
Re: Intersect issue
Posted: Wed Apr 27, 2011 9:09 pm
by unclewayne
Almost.
Your finger would be on "sliderKnob" the whole time so there is no need for the last line, so i took that out.
The only issue, is that it doesn't add one every time you hit "case 50, 200".
So some one would be swiping left to right repeatedly and every time you hit "case 50, 200" it would add 1 to your score.
I will ask about the animation after i nail this down. Thanks for all of your help.
Re: Intersect issue
Posted: Wed Apr 27, 2011 10:23 pm
by dburdan
The number 50,200 was just an example. you have to change it to the to coordinates of the sliderThumb when it is where you want it to be to add a point.
Re: Intersect issue
Posted: Wed Apr 27, 2011 10:36 pm
by unclewayne
Sorry. I did, I didn't want to confuse you with my coordinates.
It registers and puts "Score: 1" into the field the first time it hits and then nothing goes into the field on the second hit and third hit and so on.
Re: Intersect issue
Posted: Thu Apr 28, 2011 12:02 am
by dburdan
Wayne,
Would you be able to upload a stack of what you currently have? That would give me a better idea of what I can do to help.
Re: Intersect issue
Posted: Thu Apr 28, 2011 1:08 am
by unclewayne
Hey Darci,
Sorry i am being unclear, Visuals would be quicker.
Attached is the sample. You will see the grey bar slides back and forth, if you let it go it will return back to the left. We want it to add 1 to the score every time you hit the right without letting go. Let me know if you need any other info.
Thanks again.
Re: Intersect issue
Posted: Thu Apr 28, 2011 6:49 am
by dburdan
Hey Wayne,
My solution may be more of a hack but it gets the job done! Place the
left of the trigger right on top of the
right of the sliderRect. Then use the following:
Code: Select all
on constrainRectangularCallback
-- Get the distance of the start line & center theslider thumb
get distance(the location of graphic "startLine", the location of image "sliderKnob") //Get the distance that the slider has traveled so far.
put it into SliderDistance //Put that distance into a variable
divide sliderDistance by 2 //Divide it by 2 to get it to around 100
put round(SliderDistance) into sliderDistance //Round it to the nearest number to avoid errors.
if intersect (graphic "trigger", image "sliderKnob") then
add 1 to field "score"
move graphic "trigger" to 405, 199 in 1 millisecond
end if
if the left of image "sliderKnob" <= 160 then
move graphic "trigger" to 404, 199 in 1 millisecond
end if
end constrainRectangularCallback
This will only increment the score by one unless the user moves the slider.
Re: Intersect issue
Posted: Thu Apr 28, 2011 8:23 pm
by unclewayne
Great.
You know, i tried that and it didn't work in the Livecode arena. Lesson learned, alway test it in simulator.
Thank you for all the help.
I am finishing up some other aspects of the job, i may post asking about starting and stopping animations in a couple of days.
Re: Intersect issue
Posted: Thu Apr 28, 2011 8:56 pm
by dburdan
No problem I'd love to help. If you need to email me directly my email is in my signature.