<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Attached find screenshots for both an Alice 2 and an Alice 3 implementation (you did not mention which version you were working with.)<div><br></div><div>In Alice 2, you would create the isClickedOn variable by selecting the “world” object, the “properties” tab in the “details” panel and click on the “create variable” button. The “A2_<sccreenshots>” show the rest of the implementation, including the event.</div><div><br></div><div>In Alice 3, if would create a “isClickedOn" property in the Cow class (see Screen shot “A3_CowProperty”. This will automatically create the procedural method “setIsClickedOn” method and the ‘getIsClickedOn” functional method for you in Alice, which you will then see used in the EventListener (“A3_Event”) and the “appear” method of the Cow class (“A3_CowAppear”). The score would be a property of the Scene class, to be used by some score object (not implemented) (“A3_firstMethod”)</div><div><br></div><div>You could also create the isClickedOn variable for the Cow object in Alice 2.</div><div><br></div><div>I hope that this helps.</div><div><br></div><div>Later,</div><div>Don Slater</div><div><br></div><div><img height="715" width="996" apple-width="yes" apple-height="yes" apple-inline="yes" id="8005D645-6813-4118-8F9D-0F6966979BF3" src="cid:EE3F926C-8BC9-4DC2-B07F-1CBF4A1E9D75@wv.cc.cmu.edu"><img height="694" width="996" apple-width="yes" apple-height="yes" apple-inline="yes" id="F1580316-B1F8-44B2-A122-63D406B66720" src="cid:4725A5F4-B07D-4671-A4E4-430E0579610E@wv.cc.cmu.edu"> </div><div><br></div><div><img height="374" width="823" apple-width="yes" apple-height="yes" apple-inline="yes" id="D9122C81-904C-4831-AE4B-2D69E9872E5E" src="cid:CD513CC7-D65C-43B8-8F04-F0C53BAEF0AC@wv.cc.cmu.edu"><img height="454" width="985" apple-width="yes" apple-height="yes" apple-inline="yes" id="37D14ED3-B78B-4A01-B7C3-0E6ED07612BC" src="cid:A23AFA59-1924-43CB-8EA4-C2CEED52F240@wv.cc.cmu.edu"><img height="503" width="932" apple-width="yes" apple-height="yes" apple-inline="yes" id="EA8AD90C-984C-492D-868B-127554C78B64" src="cid:BBF6221E-CC4D-4DAE-9980-A19584B1D5EE@wv.cc.cmu.edu"><img height="207" width="630" apple-width="yes" apple-height="yes" apple-inline="yes" id="5BFBE8A0-0F9D-4395-B29C-5E6B5E41AB00" src="cid:169411EC-F4CB-43A3-BC18-B0E9FAD4CB46@wv.cc.cmu.edu"></div><div><br></div><div><br></div><div><br><div><div>On Oct 6, 2014, at 8:34 AM, Emily Higgins <<a href="mailto:erphiggins@gmail.com">erphiggins@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Don -<div>Could you send a screenshot of how you would program what you did the algorithm for Whack-A-Mole? I can't figure out where to put the isClickedOn variable.</div><div><br></div><div>Refresher - the question was how to control when an event listener is activated, and the response was this:</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px">So my code might look something like</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">        </span>Scene variable / property -> boolean isClickedOn = false;</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">        </span>Event definition - mouseClickListener</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                </span>if (mouse clicks on target) and (not isClickedOn)</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                        </span>add 1 to score</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                        </span>isClickedOn = true</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">        </span>target move method</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                </span>hide target</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                </span>if (isClickedOn)</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                        </span>isClickedOn = false</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                </span>move target</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                </span>showTarget</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><br></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">        </span>myFirstMethod</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                </span>while (score < targetScore) or (time runs out)</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                        </span>target move</div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="white-space:pre-wrap">                </span>game over</div><div> </div><div><br></div><div>Thank you</div><div>Emily Higgins</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 1, 2014 at 12:51 PM, Don Slater <span dir="ltr"><<a href="mailto:dslater@andrew.cmu.edu" target="_blank">dslater@andrew.cmu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">See below...<br><div>
<div style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;"><div style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;"><span style="border-collapse: separate; font-family: Verdana; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px;"><div style="word-wrap:break-word"><span style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px;"><div style="word-wrap:break-word"><span style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px;"><div style="word-wrap:break-word"><span style="border-collapse: separate; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px;"><div style="word-wrap:break-word"><br></div></span></div></span></div></span></div></span></div></div></div><div><div>On Oct 1, 2014, at 9:39 AM, Emily Higgins <<a href="mailto:erphiggins@gmail.com" target="_blank">erphiggins@gmail.com</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr">Dear All-<div> I have two questions. </div><div>1) What does the Handle Active command do in Alice 3.1?</div></div></blockquote><div><br></div><div>I assume you mean the HandleActiveChanged method of the Scene class. This is a method that will facilitate the creation of multiple scenes in Alice 3 when it is implemented. If you look at what it does right now (see attached screen shot), you will see that it essentially builds the current (and only possible) Scene, readying it for execution. It is not a method you or your students need to use at this time.</div><div><br></div><blockquote type="cite"><div dir="ltr">2) How can you set up a program so that an object is only affected by an event listener for part of the program? For example, a student wants to have the program user move a box but only at a certain point of the program. I can't figure out how to limit when an event listener is active. </div></blockquote><div><br></div><div>The student should create a boolean variable for the Scene class that is initially set to false as the program runs, and at the time when the student wants the event to become active, he sets the value of the variable to true. He would reset it to false when he no longer wants to listen for the event.</div><div><br></div><div>Then the event would be guarded by an if statement, that performs the event action when the variable is true.</div><div><br></div><div>For example, i have a type of “Whack-A-Mole” game in which the player is supposed to click on the target object when it appears, but you only one to add one point at most for each appearance of the target.</div><div><br></div><div>So my code might look something like</div><div><br></div><div><span style="white-space:pre-wrap">        </span>Scene variable / property -> boolean isClickedOn = false;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>Event definition - mouseClickListener</div><div><br></div><div><span style="white-space:pre-wrap">                </span>if (mouse clicks on target) and (not isClickedOn)</div><div><span style="white-space:pre-wrap">                        </span>add 1 to score</div><div><span style="white-space:pre-wrap">                        </span>isClickedOn = true</div><div><br></div><div><span style="white-space:pre-wrap">        </span>target move method</div><div><span style="white-space:pre-wrap">                </span>hide target</div><div><span style="white-space:pre-wrap">                </span>if (isClickedOn)</div><div><span style="white-space:pre-wrap">                        </span>isClickedOn = false</div><div><span style="white-space:pre-wrap">                </span>move target</div><div><span style="white-space:pre-wrap">                </span>showTarget</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">        </span>myFirstMethod</div><div><span style="white-space:pre-wrap">                </span>while (score < targetScore) or (time runs out)</div><div><span style="white-space:pre-wrap">                        </span>target move</div><div><span style="white-space:pre-wrap">                </span>game over</div><div><br></div><div>Let me know if you have any other questions.</div><div><br></div><div>All the best,</div><div><br></div><div><br></div><div><span><handleActive.png></span></div><div><br></div><div><div>Don Slater</div><div>Alice Team</div><div>Carnegie Mellon University</div><div>5000 Forbes Avenue</div><div>Pittsburgh, PA 15213</div><div><br></div><div>Email: <a href="mailto:don@alice.org" target="_blank">don@alice.org</a></div><div><br></div><div>I have learned this at least by my experiment: that if one advances confidently in the direction of his dreams, and endeavors to live the life he has imagined, he will meet with a success unexpected in common hours.<br>--- Henry David Thoreau</div></div><div><br></div><div>The true object of all human life is play. -- G.K. Chesterton</div><blockquote type="cite"><div dir="ltr"><div><br></div><div>Thank you,</div><div>Emily Higgins</div><div>Boothbay Region High School</div><div>Boothbay Harbor, Maine</div></div>
_______________________________________________<br>alice-teachers mailing list<br><a href="mailto:alice-teachers@lists.andrew.cmu.edu" target="_blank">alice-teachers@lists.andrew.cmu.edu</a><br><a href="https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers" target="_blank">https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers</a><br></blockquote></div><br></div><br>_______________________________________________<br>
alice-teachers mailing list<br>
<a href="mailto:alice-teachers@lists.andrew.cmu.edu">alice-teachers@lists.andrew.cmu.edu</a><br>
<a href="https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers" target="_blank">https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>alice-teachers mailing list<br><a href="mailto:alice-teachers@lists.andrew.cmu.edu">alice-teachers@lists.andrew.cmu.edu</a><br>https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers<br></blockquote></div><br></div></body></html>