This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-04-10 17:06:11

zeyrios
New Scratcher
Registered: 2013-04-10
Posts: 1

How do I restrict other animations when an animation is in progress

I need some help with a school assignment.

Here's part of the assignment.

As discussed in class, if a letter in your name is selected with the mouse pointer, left-mouse click, it should animate and then return to its original location, as long as no other animation is in progress. After all animations complete the 30-second timer should restart.

I know how to do everything except restrict other animations when an animation is in progress. In essence, how do I disable input from a mouse while their is an animation playing.

Offline

 

#2 2013-04-10 22:34:50

OverPowered
Scratcher
Registered: 2012-07-27
Posts: 100+

Re: How do I restrict other animations when an animation is in progress

First, create a variable, such as "Animating?" and add this script to one sprite.

when green flag clicked
set [Animating? v] to (0)
Next, add
set [Animating? v] to (1)
at the top of all of your animation scripts and
set[Animating? v] to (0)
at the bottom.

Finally, put the entire animation script, including the parts we just added, inside
if <(Animating?) = (0)>
All your scripts go here
end
Shoul work.  smile


Newest project: Tunnel TEST ~http://blocks.scratchr.org/API.php?user=OverPowered&amp;action=onlineStatus~ On my mind: Unicameralism

Offline

 

#3 2013-04-10 23:47:28

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How do I restrict other animations when an animation is in progress

OverPowered wrote:

First, create a variable, such as "Animating?" and add this script to one sprite.

when green flag clicked
set [Animating? v] to (0)
Next, add
set [Animating? v] to (1)
at the top of all of your animation scripts and
set[Animating? v] to (0)
at the bottom.

Finally, put the entire animation script, including the parts we just added, inside
if <(Animating?) = (0)>
All your scripts go here
end
Shoul work.  smile

Exactly, accept to make it easier you can just initiate "animating?" To no, and then when it is switch it to yes.  smile

Also, to be more specific, you need to put the if statement to enclose the mouse input script, not all of your scripts(as far as I am understanding).

And remember, if the input script is long, it may actually happen so that when the loop starts, "animating?" Is at no, but during the running of the script it turns yes. That would cause issues. Therefore, you may need to insert that if statement inside the script somewhere, and maybe on the scripts that animates the other buttons(at least that's what it sounds like...)

Hope that helps,

CAA14

Last edited by CAA14 (2013-04-10 23:52:22)

Offline

 

Board footer