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

2015/8/14

How Do You Have A Variable Accessible Within 2 Actor Subclasses

TSTemple TSTemple

2015/8/14

#
I Cannot Seem To Figure It Out
danpost danpost

2015/8/14

#
Show the code of the class with the variable. Specify which variable. Then show the codes in the other classes where you need to access it from (methods).
benja24 benja24

2015/8/23

#
You could create two methodes that return or change the value of the variable within one of the two classes and then evoke these from the other class.
fejfo fejfo

2015/8/23

#
I think you are missing some core java knowledge in actor 1 you have :
public int* i**;
*can be any class **can be any name in the world :
public Actor1 a;

// some code
a = new Actor1();
addObject(a,x,y);
then you can do :
int*** i = ((World1*) getWorld()).a.i**;
*name of the world; **name of the varible in actor1 ***class use in actor 1
You need to login to post a reply.