Making Buttons Solid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Making Buttons Solid
hello,
i have been researching " Intersect " and the use of layers in this but i am still drawing blanks.
i have a number of buttons on the screen which move about but they can move over each other, what i would to try and do is make them solid so you cant move them over each other.
does that make sense.
i would rather be told what to go and read and work it with out trial and error than someone post the answer.
i have been researching " Intersect " and the use of layers in this but i am still drawing blanks.
i have a number of buttons on the screen which move about but they can move over each other, what i would to try and do is make them solid so you cant move them over each other.
does that make sense.
i would rather be told what to go and read and work it with out trial and error than someone post the answer.
Last edited by d.m.holdawayGA2553 on Wed Mar 21, 2012 11:48 pm, edited 1 time in total.
Re: Making Buttons Solid
Your buttons already move over each other, right? Did you mean "so you CAN'T move them over each other"?
If so, please write back. There are easy ways to do this. How do your button move now?
Craig Newman
If so, please write back. There are easy ways to do this. How do your button move now?
Craig Newman
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Re: Making Buttons Solid
yes Craig thats what i ment, i am really sorry for getting that mixed up i have corrected the post.
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Re: Making Buttons Solid
I move them with
on touchMove pId, pX, pY
if the cType of the target is "shape" and sMoving is true then
set the loc of the target to pX, pY
end if
end touchMove
on touchMove pId, pX, pY
if the cType of the target is "shape" and sMoving is true then
set the loc of the target to pX, pY
end if
end touchMove
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Re: Making Buttons Solid
i have just found a good example
http://revonline2.runrev.com/stack/281/ ... ic-Control
i will have a look at this.
http://revonline2.runrev.com/stack/281/ ... ic-Control
i will have a look at this.
Re: Making Buttons Solid
Thought so. Anyway, you don't make the movng objects "solid". Rather you control them; herd them like sheep. Make them do your bidding.
Try this: on a card place three buttons. Name one "starter". Name another "mover". Name the third "theTarget". Place the btn "mover" far to the left of btn "theTarget", but on the same horizontal line. Put this in the script of btn "starter":
Please try to understand what each line does. This is homework. Experiment and play around. Can you change the speed in more than one way? The starting position? Does it matter where you place the button "starter"? Can it be between the other two?
The example above is just a bit verbose, for readability. Can you shorten it?.
Write back with the completed homework.
Craig Newman
Try this: on a card place three buttons. Name one "starter". Name another "mover". Name the third "theTarget". Place the btn "mover" far to the left of btn "theTarget", but on the same horizontal line. Put this in the script of btn "starter":
Code: Select all
on mouseUp
put the loc of btn "mover" into startLoc
repeat until intersect(btn "mover",btn "tTarget") = "true"
get the loc of btn "mover"
set the loc of btn "mover" to item 1 of it + 1 & "," & item 2 of it
wait 2
end repeat
set the loc of btn "mover" to startLoc
end mouseUp
The example above is just a bit verbose, for readability. Can you shorten it?.
Write back with the completed homework.
Craig Newman
Re: Making Buttons Solid
Yes Sir, Mr Newman... Where should I put your apple ?... 

Re: Making Buttons Solid
Dixie.
In The Marx Brothers movie "Horse Feathers", Harpo gives the professor a watermelon.
Soon after, that professor was thrown out of his own classroom.
Craig
In The Marx Brothers movie "Horse Feathers", Harpo gives the professor a watermelon.
Soon after, that professor was thrown out of his own classroom.
Craig
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Re: Making Buttons Solid
ok.
well
takes the current location of the button "mover" and puts it into a variable
this code makes the button mover move until it hits the target, but i am unsure about this line
its doing the moving part but i dont understand
is the time it takes for mover to hit theTarget
then upon hitting it, its breaks the loop and sets the mover button back to the location
well
Code: Select all
put the loc of btn "mover" into startLoc
Code: Select all
repeat until intersect(btn "mover",btn "theTarget") = "true"
get the loc of btn "mover"
set the loc of btn "mover" to item 1 of it + 1 & "," & item 2 of it
wait 2
Code: Select all
set the loc of btn "mover" to item 1 of it + 1 & "," & item 2 of it
Code: Select all
to item 1 of it + 1 & "," & item 2 of it
Code: Select all
wait 2
then upon hitting it, its breaks the loop and sets the mover button back to the location
-
- Livecode Opensource Backer
- Posts: 328
- Joined: Mon Dec 05, 2011 5:34 pm
- Contact:
Re: Making Buttons Solid
Just for reference:
a 'loc' variable consists of two components - x and y position - eg. "100,200"
Using the 'get' command will get the value of a variable/function/whatever and put the result into a special variable named 'it' (see the dictionary for more info on this)
Using 'chunk' access notation ( 'item 1') the various parts of the loc (inside the 'it' variable) can be used - item 1 of it would return '100' from the loc example above - item 2 returns '200'!
To set the loc of something you need to provide both the x and y - comma separated text - "444,555".
So the line:
set the loc of btn "mover" to item 1 of it + 1 & "," & item 2 of it
basically creates a new 'loc' from the old loc by breaking it down into it's component parts, adding a value to the 'x' part (item 1) and reconstructing a new loc from those modified parts.
Wow, that is a long an laborious way of explaining this
But I hope it helps someone.
Dave
a 'loc' variable consists of two components - x and y position - eg. "100,200"
Using the 'get' command will get the value of a variable/function/whatever and put the result into a special variable named 'it' (see the dictionary for more info on this)
Using 'chunk' access notation ( 'item 1') the various parts of the loc (inside the 'it' variable) can be used - item 1 of it would return '100' from the loc example above - item 2 returns '200'!
To set the loc of something you need to provide both the x and y - comma separated text - "444,555".
So the line:
set the loc of btn "mover" to item 1 of it + 1 & "," & item 2 of it
basically creates a new 'loc' from the old loc by breaking it down into it's component parts, adding a value to the 'x' part (item 1) and reconstructing a new loc from those modified parts.
Wow, that is a long an laborious way of explaining this


Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.
Visit http://electronic-apps.info for released App information.
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Re: Making Buttons Solid
no thats really good!
so if i was to say
it would move diagonal
that would make the loc 1,1
so if i wanted to move it quicker i could just change item 1 and item 2
so if i was to say
Code: Select all
set the loc of btn "mover" to item 1 of it + 1 & "," & item 2 of it + 1
that would make the loc 1,1
so if i wanted to move it quicker i could just change item 1 and item 2
Code: Select all
set the loc of btn "mover" to item 1 of it + 10 & "," & item 2 of it + 10
Re: Making Buttons Solid
YES! You are on your way. Congrats.
And yes, again, two ways of changing the rate are to modify the "wait" duration or to increase the offset of the loc parameters. There are even others.
I might have been more helpful with that one line if I wrote:
set the loc of btn "mover" to (item 1 of it + 1) & "," & (item 2 of it) --better readability
How about making the "mover" button bounce around the card at random til it hits the target? If you can do this you should have most of the mental tools you need for your game. A word of warning: be careful that you limit the playing field to the rect of the card or your button will disappear off an edge. You may want to make a button that manually relocates it if it gets lost. Do you know how to terminate a running script? (command-period)
Good luck, play all day, write back.
Craig Newman
And yes, again, two ways of changing the rate are to modify the "wait" duration or to increase the offset of the loc parameters. There are even others.
I might have been more helpful with that one line if I wrote:
set the loc of btn "mover" to (item 1 of it + 1) & "," & (item 2 of it) --better readability
How about making the "mover" button bounce around the card at random til it hits the target? If you can do this you should have most of the mental tools you need for your game. A word of warning: be careful that you limit the playing field to the rect of the card or your button will disappear off an edge. You may want to make a button that manually relocates it if it gets lost. Do you know how to terminate a running script? (command-period)
Good luck, play all day, write back.
Craig Newman
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Re: Making Buttons Solid
cool i like this!
what if my buttons are in a group, how would i use intersect then?
thanks for the command-period heads up
that is most helpful!
thanks again for the advice and the tips
what if my buttons are in a group, how would i use intersect then?
thanks for the command-period heads up
that is most helpful!
thanks again for the advice and the tips
Re: Making Buttons Solid
Keep going.
Intersect will use the overall extent of the group, regardless of the locations of its component objects, and use that as the basis for returning a value. Try it. Make a group with two objects located diagonally. The group will be a rectangle.
Where is that random game? An exercise like this will advance your learning dramatically.
Craig Newman
Intersect will use the overall extent of the group, regardless of the locations of its component objects, and use that as the basis for returning a value. Try it. Make a group with two objects located diagonally. The group will be a rectangle.
Where is that random game? An exercise like this will advance your learning dramatically.
Craig Newman
-
- Posts: 81
- Joined: Mon Jan 09, 2012 4:48 pm
Re: Making Buttons Solid
i have started on the random bouncing homework.
but could you explain
but could you explain
i am not sure what you ment by that.Intersect will use the overall extent of the group