alice-teacher Global Variables
Emily Higgins
erphiggins at gmail.com
Wed Dec 11 14:11:15 EST 2013
I can see how to pass a variable between the methods, but how can I pass it
between an event listener and a method? I want to, for example, keep track
of number of mouse clicks during a game. How can I do that? I can't
create a parameter in an event listener.... I think I am missing a step or
a piece of understanding in figuring out how to manage this.
Thank you
Emily Higgins
Boothbay Region High School
Boothbay, Maine
On Wed, Dec 11, 2013 at 1:17 PM, Don Slater <dslater at andrew.cmu.edu> wrote:
> Alice 3 does not really support global variables in the same way as Alice
> 2. Alice 3 is Java-based, with a strong sense of scope for variables.
>
> It is possible to create a variable that belongs to the Scene class, that
> can be used by any other methods (functions and procedures) written on the
> Scene class. But If I am writing a method for the Penguin class, that
> method does not have access to the variable created in the Scene. That
> Scene variable must be passed as a parameter to the Penguin method that
> would like to use it, and a function of the Penguin class must return a
> value to for updating the Scene variable.
>
> Please let me know if you have any other questions.
>
> Later,
> Don Slater
>
> On Dec 10, 2013, at 3:04 PM, Robert Durtschi <robert.durtschi at gcsu.edu>
> wrote:
>
> > I'm guessing it's the same for Alice 3; In Alice 2.x variables created
> as properties of the World object (top object in the object-tree) could be
> seen/manipulated by all other objects.
> >
> >
> > Hello All -
> > I am trying to iterate a counter in an event listener, so that if the
> user
> > clicks on four objects, an action occurs. How can I do this? I also
> > can't figure out how to make a global variable that can be accessed
> > throughout the program.
> >
> > Emily Higgins
> > Boothbay Region High School
> > Boothbay Harbor, Maine
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL:
> http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20131209/98e3a033/attachment-0001.html
> >
> > ------------------------------
> >
> > _______________________________________________
> > alice-teachers mailing list
> > alice-teachers at lists.andrew.cmu.edu
> > https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
>
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> 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/20131211/084ec66f/attachment-0001.html
More information about the alice-teachers
mailing list