non-static variable cannot be referenced from static context...
I know what it means and how to fix it, but I don't know how to properly do it I think...
You see, there's a bunch of stuff I don't have direct access to in jMonkeyEngine and because of that I can't use them the way I want. It's something I have to live with.
But, it's annoying me. There has to be a better way to access those variables than making gazillion methods and twisted ways to reference a "dummy" variable that I'll be able to use as static (because I'm controlling it).
As an example.
My main class is Game. It extends SimpleApplication. That class, SimpleApplication, has all the stuff I need to load textures, files, models, etc. That thing is called the assetManager. It's declared that way in the source file:
Code:
protected AssetManager assetManager;
Since I can't access that as a static, I have devised a way to "get it" by doing something like the following in my Game class:
Code:
AssetManager gameAssetManager;
Then later, to be sure it has been properly initialized, I call:
Code:
gameAssetManager = assetManager;
It works, but that worries me a lot. I'm not sure things are done right since I've been having weird problems lately and I think it might be because of that. I'm unsure as of now if it is the problem, but I'd rather have better code now than wait longer and have even more spaghetti-looking code. (My Game class is now at close to 500 lines and I'm very far from being at the middle of things). With like 30 or so classes, I'm worried that I'm doing a really bad job.
So to clean things up a bit I need to fix things up.
I tried referencing my Game class in other classes, but I get the same message (static method/var). Or use the following:
Code:
protected Game game = new Game();
but I'm getting nulls all over the place understandingly. At first I thought it would work nicely since all my variables are static, but since those vars in SimpleApplication are not, those get null'ed...
I guess I could pass the Game class when initializing those other classes, but ... ugh.
So... what are my options? :(
And again, thanks a lot for your help.