Alice Community  

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

Reply
 
Thread Tools Display Modes
Working with variables
Old
Shibble
Junior Member
 
Status: Offline
Posts: 5
Join Date: Sep 2011
Default Working with variables - 10-17-2011, 11:13 AM

Hey Guys,

I was hoping someone could help me out with a little project for school..

Here's the thing :

For my tic tac toe game i want the game to generate a random number 0 or 1 for who can play first. That part i have. But now i want to import that variable into another method and work with that if it makes sense.

To clarify :

In "world" i have a method that generates a random number. say : PlayerTurnFirst (variable)

in "cube1" i have a method with an if/else statement saying if "PlayerTurnFirst" is 1, then setText to X .. else if "PlayerTurnfirst" is 0, setText to O.

But i just can't seem to get that "PlayerTurnFirst" variable that i created in the world into the cube method.

So does anyone know how to make that variable accesable in every method ?

Thanks in advance !

(Sorry if my English is a bit off)
   
Reply With Quote
Old
ZoiieeMadden
Junior Member
 
Status: Offline
Posts: 2
Join Date: Oct 2011
Default 10-27-2011, 11:35 AM

Quote:
Originally Posted by Shibble View Post
Hey Guys,

I was hoping someone could help me out with a little project for school..

Here's the thing :

For my tic tac toe game i want the game to generate a random number 0 or 1 for who can play first. That part i have. But now i want to import that variable into another method and work with that if it makes sense.

To clarify :

In "world" i have a method that generates a random number. say : PlayerTurnFirst (variable)

in "cube1" i have a method with an if/else statement saying if "PlayerTurnFirst" is 1, then setText to X .. else if "PlayerTurnfirst" is 0, setText to O.

But i just can't seem to get that "PlayerTurnFirst" variable that i created in the world into the cube method.

So does anyone know how to make that variable accesable in every method ?

Thanks in advance !

(Sorry if my English is a bit off)


If I was in your shoes, I would click the create the variable button, on the class property window you have to set the variable so that it can be referenced by any method for unlimited number of times.

Hope this helps.

_________________
Madden Girl
   
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 ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.