Upon clicking on a button 1, button 2 jumps up and lands backs to its original spot in 10 ticks.
For example
on mouseUP
....move button 2 relative 0,-20 in 5 ticks
....wait 5 ticks
....move button 2 relative 0,20 in 5 ticks
end mouseUP
My question is how do I control the clicking of button 1 in a way where it doesn't run until button 2 is back to its original spot. I don't want the button 2 to be jumping up more than it should be when button 1 is clicked faster than 10 ticks. I hope it is clear what I am trying to say! Thanks
Animation Control
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Animation Control
Hi ferhan24badshah,
How about disable?
Button 1
Simon
How about disable?
Button 1
Code: Select all
on mouseUP
disable me
move button 2 relative 0,-20 in 5 ticks
wait 5 ticks
move button 2 relative 0,20 in 5 ticks
enable me
end mouseUP
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Animation Control
That works well (and I should probably just leave it at that, but just for good measure as this may translate into some extra learning...)
The move command on its own is blocking, and so the enable statement is executed only after the move has finished, which is why you can do that in that button script. If you change button 1's script to
You will see that the move commands do not wait until they are finished before executing the next statement, so the button becomes enabled too soon. (Also there is a creep downscreen where the moving button starts to move according to the second command before the first has completed.) A problem in this case, but you will have other situations where you don't want to wait for moves to finish before dealing with other lines of code.
Change button 1's script again to leave out the enable statementHow then are we going to reenable the button?
Well, there is a "moveStopped" message sent to the object that was moved, when it finishes the move. So in button 2 you can scriptThe moveStopped message is handled in button 2 because button 2 is the object that was moved.
Now there's another consideration that in this scenario you have two moves one after the other. The moveStopped message will be sent when each of the moves finishes, so the enabling of button 1 will happen too soon. There's a number of ways round that but I have to go now so we can pretend that you will be interested enough to work this out yourself
I hope that helps, not confuses.
The move command on its own is blocking, and so the enable statement is executed only after the move has finished, which is why you can do that in that button script. If you change button 1's script to
Code: Select all
on mouseUp
disable me
move button 2 relative 0,-20 in 5 ticks without waiting
wait 5 ticks with messages
move button 2 relative 0,20 in 5 ticks without waiting
enable me
end mouseUp
Change button 1's script again to leave out the enable statement
Code: Select all
on mouseUp
disable me
move button 2 relative 0,-20 in 5 ticks without waiting
--make the pause a little longer to ensure the first move is finished before going back down
wait 6 ticks with messages
move button 2 relative 0,20 in 5 ticks without waiting
end mouseUp
Well, there is a "moveStopped" message sent to the object that was moved, when it finishes the move. So in button 2 you can script
Code: Select all
on moveStopped
enable button 1
end moveStopped
Now there's another consideration that in this scenario you have two moves one after the other. The moveStopped message will be sent when each of the moves finishes, so the enabling of button 1 will happen too soon. There's a number of ways round that but I have to go now so we can pretend that you will be interested enough to work this out yourself

I hope that helps, not confuses.
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Re: Animation Control
SparkOut wrote:That works well (and I should probably just leave it at that, but just for good measure as this may translate into some extra learning...)
The move command on its own is blocking, and so the enable statement is executed only after the move has finished, which is why you can do that in that button script. If you change button 1's script toYou will see that the move commands do not wait until they are finished before executing the next statement, so the button becomes enabled too soon. (Also there is a creep downscreen where the moving button starts to move according to the second command before the first has completed.) A problem in this case, but you will have other situations where you don't want to wait for moves to finish before dealing with other lines of code.Code: Select all
on mouseUp disable me move button 2 relative 0,-20 in 5 ticks without waiting wait 5 ticks with messages move button 2 relative 0,20 in 5 ticks without waiting enable me end mouseUp
Change button 1's script again to leave out the enable statementHow then are we going to reenable the button?Code: Select all
on mouseUp disable me move button 2 relative 0,-20 in 5 ticks without waiting --make the pause a little longer to ensure the first move is finished before going back down wait 6 ticks with messages move button 2 relative 0,20 in 5 ticks without waiting end mouseUp
Well, there is a "moveStopped" message sent to the object that was moved, when it finishes the move. So in button 2 you can scriptThe moveStopped message is handled in button 2 because button 2 is the object that was moved.Code: Select all
on moveStopped enable button 1 end moveStopped
Now there's another consideration that in this scenario you have two moves one after the other. The moveStopped message will be sent when each of the moves finishes, so the enabling of button 1 will happen too soon. There's a number of ways round that but I have to go now so we can pretend that you will be interested enough to work this out yourself
I hope that helps, not confuses.
I will try that. But I want to make an adjustment. My object "button2" actually jumps when I touch the card instead of button 1. So how would that change the coding?