This site requires JavaScript, please enable it in your browser!
Greenfoot back
GeneralBrae
GeneralBrae wrote ...

2011/10/25

Public Variables

GeneralBrae GeneralBrae

2011/10/25

#
Hi. Can anyone please explain how to make a variable 'visible' by all classes? If for instance I declare "xcoords" in a world class how would I then use the value in that variable in an actor class? Thanks!
davmac davmac

2011/10/25

#
Read through this tutorial. It explains exactly what you are asking!
GeneralBrae GeneralBrae

2011/10/26

#
Brilliant thanks a lot!
ez4u2c ez4u2c

2011/10/26

#
You might be interested in going a step further in making your external references less cumbersome to access. You can read my questions and davmac's answers on the subject here: http://www.greenfoot.org/topics/311
GeneralBrae GeneralBrae

2011/10/27

#
That helps thanks. This is probably a dumb question but how do you create a 2 dimensional array? I need it to hold x and y coordinates.
danpost danpost

2011/10/27

#
Use two sets of square brackets instead of one private int coords = { { x1, y1 } { x2, y2 } { x3, y3 } ... }
You need to login to post a reply.