alice-teacher switching which object is controlled by arrows
Don Slater
dslater at andrew.cmu.edu
Thu Nov 24 09:18:29 EST 2011
I like this solution a lot… Younger students may not immediately recognize why your solution works, and so the explicit checking of the "flag" in a conditional as I have done may help them see what is going on. Moving then to your solution they will then see as "cool".
I tend to move from an explicit representation to an implicit, but your mileage may vary ;-)
Later,
Don Slater
On Nov 23, 2011, at 4:38 PM, David Fenton wrote:
> Interesting solution Don,
>
> I refined your J key event to use a simple call directly to the world.activeObject and it works perfectly.
> When the key is pressed, we *know* which is the active object so we don't need to check if it is the 'hare' or the 'tortoise' - the event becomes more generic. Hope this is useful.
>
> See attached screenshot. I used the 'space' key.
>
> Cheers
> David Fenton Ô¿Ô
> Brisbane Australia
>
>
> -----Original Message-----
> From: alice-teachers-bounces+fenton=fdn.uq.edu.au at lists.andrew.cmu.edu [mailto:alice-teachers-bounces+fenton=fdn.uq.edu.au at lists.andrew.cmu.edu] On Behalf Of Don Slater
> Sent: Thursday, 24 November 2011 4:14 AM
> To: Alice educators
> Subject: Re: alice-teacher switching which object is controlled by arrows
>
> Now for the second part of my thoughts on this.
>
> How can we create events that work for multiple objects, and distinguish between the different objects.
>
> A simple version of the problem.
>
> See the attached world: "mouseclickChoice.a2w"
>
> I have created a world level object variable and named it "activeObject".
>
> I have also created a world level method named "setActiveObject" which has an object parameter "objectClickedOn". I created a "when the mouse is clicked anything do" event. This event calls "setActiveObject". When prompted for the parameter, in the drop-down menu, I selected the "expressions" option, which gave me access to the "object under mousecursor".
>
> The "setActiveObject" method has an if statement
>
> if "objectClickedOn" == "hare"
> set the activeObject method to "hare"
> else if "objectClickedOn" == "tortoise"
> set the activeObject method to "tortoise"
> else
> // do nothing
>
> Then I created a "when 'F' key is pressed" event, with an if statement
>
> if "activeObject" == "hare"
> // hare does its thing
> else
> // tortoise does its thing
>
> When you "Play" this world, when you click on the hare, and press F the hare moves up and down, when you click on the tortoise, and press F the tortoise moves up and down. If you click on any other object in the world, such as the ground, the last object selected will respond to the F key.
>
> ---- Note ---
> How to compare objects.
>
> In the if statement, when you want to compare object variables to objects in the world ("objectClickOn" == "hare") for example.
>
> 1) drag the if control into the editor.
> 2) drag the object variable or parameter so as to replace "true" in the if statement
> 3) you will be given several options from the drop down menu. Select the appropriate operation and complete the expression
>
> Please let me know if you have any questions.
>
> All the best,
> Don Slater
>
> <mouseclickChoice.png>_______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
More information about the alice-teachers
mailing list