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

2013/3/11

Need help with accesing a variable from another actor

relthix relthix

2013/3/11

#
Hey guys, I made a little project where there is a room with 5 compartments. There are 5 squares with different weights. When two squares hit eachother, the heaviest square should move to the right compartment and the leightest one to the left one. But how can I make them compare their weight? This is the setup: Actor Square Square_1 Square_2 etc. This is part of the code, I made a pubic static int variable at every square. int x = getX(); if (collision(Square.class)) { int m = Square.massa; if (massa < m) { up(Square.class); if (x > 224) { setLocation(x - 224, 32); } }
davmac davmac

2013/3/11

#
If you want the squares to all have different mass, then your variable should not be static. Try reading through tutorial #6 (see Documentation link above).
laziaf laziaf

2013/3/12

#
@davmac, hi man, can you help me? i have a trouble, I made a game using a countdown timer using Edit> import class> counter, a maximum of 40 to 0, and if up to 0 game over. the problem is, time is running very fast, and I do not know how to slow down time as a matter of seconds. I need your help. thanks
davmac davmac

2013/3/12

#
You need to post your code. Either post the relevant parts here, or upload your scenario with source code and post the link to it here.
You need to login to post a reply.