How do I access an Object from anywhere?
I want to be able to just type a class name and then the object to access it.
Basically kinda like this:
Code :
GL10 gl = ObjectHandeler.gl;
[Please note that ObjectHandeler is a class]
Is there any way to go about this, and how would I do it? I need a GL10 object that I can access absolutely anywhere.
Thanks in advance. (In the past I just passed around the object using methods, but it isnt very efficient and flexible...)
Re: How do I access an Object from anywhere?
Is ObjectHandeler the name of a class (by convention it is because of its spelling)?
If it is the name of a class and gl is a public static member of that class then your code should work.
An example would be the out variable in the System class. You can access it anywhere.
Making a variable static means there is only one of them and it has the last value assigned to it.
Re: How do I access an Object from anywhere?
If i make it static, can i still modify it? (Like setting it to null, etc...)
Re: How do I access an Object from anywhere?
Quote:
Originally Posted by
nivangerow
If i make it static, can i still modify it? (Like setting it to null, etc...)
Did you try doing this? Don't ask such questions, how to do this, what will happen, will it work. Why don't you try it and have an experience.