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

2021/2/23

Get variable from actor that is not in world

Gbasire Gbasire

2021/2/23

#
Hello, so I'm currently working on a game, and I have several classes that store some variables (attack and defense). I've made an actor named Data whose job is to get the content of these variables (he is always present in the world). When, for example, one of Data's variable is set to "aaa", he will basically go in the class AAA and take the content of its variables, so for example here Data will have its attack variable set to 10 and its defense variable set to 20. The problem is that I need to add all actors like AAA in the world for it to work. Can I do something else so that I can take these even if AAA and everything aren't in the world (Data will always be in the world) ? thanks :)
danpost danpost

2021/2/24

#
If not in the world, then a reference to those actors must be maintained -- preferably, in a list (or a set of lists).
You need to login to post a reply.