alice-teacher Alice 3 Event Listener Question

Donald Slater djslater107 at mac.com
Sun Nov 12 16:21:35 EST 2017


Emily,
See this attached world, and the explanation I sent in my previous message…

If you set the boolean variable to false in the main method, it will become false when the run button is pushed, regardless of when you try to trigger the event listener… You have to change the state (or value) of isActive as part of some other event, or procedure call

One example of using isActive

	mouse click on some thing
		if isActive
			call procedure
			set isActive to false  // here the event will happen only once, unless isActive is reset to true in some other event or procedure

	another event mouse-click or keypress or some other procedure is called
			set isActive to true

Another example

	mouse click on some thing
		if isActive
			call procedure  // here the event will happen until isActive is set to false in some other event or procedure call
			

	another event mouse-click or keypress or some other procedure is called
			set isActive to false 


Let me know if you have any other questions…

All the best,
Don Slater


	

> On Nov 12, 2017, at 3:59 PM, Emily Higgins <erphiggins at gmail.com <mailto:erphiggins at gmail.com>> wrote:
> 
> I put a global Boolean to turn to false in the main method and then set up the event listener to have an if key pressed AND Boolean true, and that did not work.  
> Emily
> 
> On Sun, Nov 12, 2017 at 3:29 PM Joel Caulum <JCaulum at edgewood.edu <mailto:JCaulum at edgewood.edu>> wrote:
> Don,
> 
> Could you send a code sample, preferably in Alice 2, showing an example of what you described here?
> 
> 
> Thanks,
> 
> Joel Caulum
> 
> Computer Science
> 
> Portage High School
> 
> Portage, WI
> 
> From: alice-teachers <alice-teachers-bounces+jcaulum=edgewood.edu at lists.andrew.cmu.edu <mailto:edgewood.edu at lists.andrew.cmu.edu>> on behalf of Donald Slater <djslater107 at mac.com <mailto:djslater107 at mac.com>>
> Sent: Thursday, November 9, 2017 3:36:54 PM
> To: Alice educators
> Subject: Re: alice-teacher Alice 3 Event Listener Question
>  
> Emily,
> One solution would be to create a Boolean variable for the Scene / World, maybe called isActive, with an initial value of true.
> 
> In the event, create an if... statement
>         if (isActive)
> 
> And then the work of the event would be inside the if statement code block...
> 
> You would set the isActive variable to false at the point in the program where the user should NOT be able to move the wolf.
> 
> Let me know if you have any questions...
> 
> All the best,
> Don Slater
> 
> Alice Project
> 
> Sent from my iPad
> 
> > On Nov 9, 2017, at 2:29 PM, Emily Higgins <erphiggins at gmail.com <mailto:erphiggins at gmail.com>> wrote:
> > 
> > Hi All,
> > I have a problem.  How can I make an event listener stop working?  We have an event listener moving a wolf, and at certain point in the program, the user needs to NOT be able to move the wolf.  I can't figure it out.
> > 
> > Thank you very much,
> > Emily Higgins
> > STEM/Gifted and Talented
> > Boothbay Region High School
> > _______________________________________________
> > alice-teachers mailing list
> > alice-teachers at lists.andrew.cmu.edu <mailto:alice-teachers at lists.andrew.cmu.edu>
> > To change settings or unsubscribe visit:
> > https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers <https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers>
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu <mailto:alice-teachers at lists.andrew.cmu.edu>
> To change settings or unsubscribe visit:
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers <https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers>
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu <mailto:alice-teachers at lists.andrew.cmu.edu>
> To change settings or unsubscribe visit:
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers <https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers>_______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu <mailto:alice-teachers at lists.andrew.cmu.edu>
> To change settings or unsubscribe visit:
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers <https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20171112/26d89a18/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: activeHare.a2w
Type: application/octet-stream
Size: 743860 bytes
Desc: not available
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20171112/26d89a18/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20171112/26d89a18/attachment-0003.html>


More information about the alice-teachers mailing list