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

2020/12/5

Can I pass a variable form a world to an actor?

Jess271 Jess271

2020/12/5

#
I was wondering if there is anyway I can declare a variable and assign it a value within the world's code and then use that same variable within the actor's code.
danpost danpost

2020/12/6

#
Jess271 wrote...
I was wondering if there is anyway I can declare a variable and assign it a value within the world's code and then use that same variable within the actor's code.
In Actor subclass, use:
int value = ((MyWorld)getWorld()).varName;
for
int varName;
in world.
You need to login to post a reply.