Trying to update a HUD
by Arden · in Torque X 2D · 09/23/2010 (3:25 pm) · 3 replies
I created an object within Game.cs, named _playGui, inheriting from the class GuiPlay : GUISceneview, IGUIScreen like this:
Now, what I want to do is to create a use this as an instance I can use through the code so I can update the HUD with scores and such.
So I have added:
But when I compile, I am getting the error:
Inconsistent accessibility: property type 'StarterGame2D.GuiPlay' is less accessible than property 'StarterGame2D.Game.Instance'
Is there a way to fix this, or do you guys thing I'm going at it the wrong way (my intent being having HID scene objects associated with individual GUI components that then can be easily moved around in the editor).
Thanks!
GuiPlay _playGui = new GuiPlay(); GUICanvas.Instance.SetContentControl(_playGui);
Now, what I want to do is to create a use this as an instance I can use through the code so I can update the HUD with scores and such.
So I have added:
public GuiPlay Instance
{
get { return _instance;}
}and:#region Private, protected, internal fields
private static GuiPlay _instance;But when I compile, I am getting the error:
Inconsistent accessibility: property type 'StarterGame2D.GuiPlay' is less accessible than property 'StarterGame2D.Game.Instance'
Is there a way to fix this, or do you guys thing I'm going at it the wrong way (my intent being having HID scene objects associated with individual GUI components that then can be easily moved around in the editor).
Thanks!
#2
If I understand what you want to do, GuiPlay becomes a Singleton, right?
In that case, Instance must be static as well if you want to call it this way:
GuiPlay.Instance.doSomething();
Is this the issue?
09/23/2010 (5:57 pm)
I am not sure the error originates from the code you have shown us...If I understand what you want to do, GuiPlay becomes a Singleton, right?
In that case, Instance must be static as well if you want to call it this way:
GuiPlay.Instance.doSomething();
Is this the issue?
#3
Works well so far.
Thanks for the answer though!
09/23/2010 (8:00 pm)
Must have. However I decided to go about it another way, by restricting the Guiplay instance to Games.cs and working directly from the GuiPlay class which creates HUD objects from other GUIControl custom classes the first time it is called.Works well so far.
Thanks for the answer though!
Torque 3D Owner Will O-Reagan
Modern Intrigues