Intersect issue

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
unclewayne
Posts: 37
Joined: Tue Apr 05, 2011 9:58 pm

Intersect issue

Post by unclewayne » Tue Apr 26, 2011 9:21 pm

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

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Intersect issue

Post by dburdan » Tue Apr 26, 2011 10:00 pm

Not Available
Last edited by dburdan on Thu Jan 08, 2015 9:54 am, edited 1 time in total.

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Intersect issue

Post by Klaus » Wed Apr 27, 2011 11:06 am

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! :D


Best

Klaus

unclewayne
Posts: 37
Joined: Tue Apr 05, 2011 9:58 pm

Re: Intersect issue

Post by unclewayne » Wed Apr 27, 2011 4:03 pm

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.

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Intersect issue

Post by Klaus » Wed Apr 27, 2011 4:51 pm

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

unclewayne
Posts: 37
Joined: Tue Apr 05, 2011 9:58 pm

Re: Intersect issue

Post by unclewayne » Wed Apr 27, 2011 6:30 pm

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

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Intersect issue

Post by dburdan » Wed Apr 27, 2011 8:01 pm

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
Last edited by dburdan on Fri Nov 07, 2014 8:33 pm, edited 1 time in total.

unclewayne
Posts: 37
Joined: Tue Apr 05, 2011 9:58 pm

Re: Intersect issue

Post by unclewayne » Wed Apr 27, 2011 9:09 pm

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.

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Intersect issue

Post by dburdan » Wed Apr 27, 2011 10:23 pm

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.

unclewayne
Posts: 37
Joined: Tue Apr 05, 2011 9:58 pm

Re: Intersect issue

Post by unclewayne » Wed Apr 27, 2011 10:36 pm

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.

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Intersect issue

Post by dburdan » Thu Apr 28, 2011 12:02 am

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.
Last edited by dburdan on Fri Nov 07, 2014 8:33 pm, edited 1 time in total.

unclewayne
Posts: 37
Joined: Tue Apr 05, 2011 9:58 pm

Re: Intersect issue

Post by unclewayne » Thu Apr 28, 2011 1:08 am

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.
Attachments
EXAMPLE.zip
(254.87 KiB) Downloaded 298 times

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Intersect issue

Post by dburdan » Thu Apr 28, 2011 6:49 am

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.

unclewayne
Posts: 37
Joined: Tue Apr 05, 2011 9:58 pm

Re: Intersect issue

Post by unclewayne » Thu Apr 28, 2011 8:23 pm

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.

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Intersect issue

Post by dburdan » Thu Apr 28, 2011 8:56 pm

No problem I'd love to help. If you need to email me directly my email is in my signature.

Post Reply

Return to “iOS Deployment”