Intersect issue
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Intersect issue
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
if intersect (graphic "trigger", image "sliderKnob") then
add 1 to fld "score"
end if
Re: Intersect issue
Not Available
Last edited by dburdan on Thu Jan 08, 2015 9:54 am, edited 1 time in total.
Re: Intersect issue
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
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
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Intersect issue
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.
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
Hi Wayne,
To control animated GIFs, check these terms in the LiveCode dictionary:
currentframe
framecount
palindromeframes
repeatcount
Best
Klaus
there is not IF... END IF in Dacris example, so please post more of your code if you want our help!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.
To control animated GIFs, check these terms in the LiveCode dictionary:
currentframe
framecount
palindromeframes
repeatcount
Best
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Intersect issue
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
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
Hey Wayne,
Try using a switch and position.
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.
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
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
Last edited by dburdan on Fri Nov 07, 2014 8:33 pm, edited 1 time in total.
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Intersect issue
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.
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
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.
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Intersect issue
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.
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
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.
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.
Last edited by dburdan on Fri Nov 07, 2014 8:33 pm, edited 1 time in total.
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Intersect issue
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.
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.
- Attachments
-
- EXAMPLE.zip
- (254.87 KiB) Downloaded 298 times
Re: Intersect issue
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:
This will only increment the score by one unless the user moves the slider.
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
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Intersect issue
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.
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
No problem I'd love to help. If you need to email me directly my email is in my signature.