Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How do I disable An event For a short period?
Old
scarlet
Guest
 
Status:
Posts: n/a
Default How do I disable An event For a short period? - 11-21-2007, 05:26 PM

I made a program where a character throws a boomerang, when the space bar is pressed using "create an event".

But while performing the method "throw boomerang" I want to disable the space bar event until the boomerang has returned.Then enable it again.

The reason for this is that if I press "space" 10 ten times really fast at the beginning of the game. The character keeps throwing for the rest of the game without me pressing anything.

Last edited by scarlet; 11-21-2007 at 05:31 PM.
   
Reply With Quote
This message is for Gabe
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default This message is for Gabe - 11-27-2007, 08:09 AM

Gabe,

I received the following email message, but when I followed the link, the original posting by Scarlett was visible but the reply by marriott was not visible.

==========
Dear DickBaldwin,

marriott has just replied to a thread you have subscribed to entitled - How do I disable An event For a short period? - in the How do I...? forum of Alice Community.

This thread is located at:
http://www.alice.org/community/showthread.php?t=1058&goto=newpost

Here is the message that has just been posted:
***************

---Quote (Originally by scarlet)---
I made a program where a character throws a boomerang, when the space bar is pressed using "create an event".

But while performing the method "throw boomerang" I want to disable the space bar event until the boomerang has returned.Then enable it again.

The reason for this is that if I press "space" 10 ten times really fast at the beginning of the game. The character keeps throwing for the rest of the game without me pressing anything.
---End Quote---
Create variable, you could call it "boomerangInMotion". At the beginning of "throw boomerang", check if the boomerang is in motion -- if not, go ahead and throw it. If so, do nothing. The basic flow:


Code:
---------
throw boomerang:
if (boomerangInMotion)
-- do nothing --
else
set boomerangInMotion to true
-- do boomerang throw animation --
set boomerangInMotion to false
---------

***************

==========


Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
gabe
Administrator
 
gabe's Avatar
 
Status: Offline
Posts: 461
Join Date: Jul 2005
Location: Pittsburgh, PA
Default 11-27-2007, 12:05 PM

marriott deleted his/her post.
   
Reply With Quote
Old
scarlet
Guest
 
Status:
Posts: n/a
Default 11-27-2007, 12:39 PM

Code:
---------
throw boomerang:
if (boomerangInMotion)
-- do nothing --
else
set boomerangInMotion to true
-- do boomerang throw animation --
set boomerangInMotion to false


This code doesn't work.

This is not how events works. If I press space twice really fast. ALice will call "throw bomerang" and wait for it to finish then it will call "throw boomerang" again. The way Alice sees to "boomerangInMotion" will always be false.
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 11-27-2007, 01:36 PM

Quote:
Originally Posted by scarlet View Post
Code:
---------
throw boomerang:
if (boomerangInMotion)
-- do nothing --
else
set boomerangInMotion to true
-- do boomerang throw animation --
set boomerangInMotion to false


This code doesn't work.

This is not how events works. If I press space twice really fast. ALice will call "throw bomerang" and wait for it to finish then it will call "throw boomerang" again. The way Alice sees to "boomerangInMotion" will always be false.
I guess that explains why Mariott deleted his/her post.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.