protected V2DGame() { if (instance != null) { throw new Exception("There can be only one game class."); } Components.Add(new GamerServicesComponent(this)); SignedInGamer.SignedIn += new EventHandler<SignedInEventArgs>(OnGamerSignIn); instance = this; graphics = new GraphicsDeviceManager(this); contentManager = Content; Content.RootDirectory = "Content"; stage = new V2DStage(); GetCursor(); }
//protected Screen GetContainerScreen(DisplayObject obj) //{ // Screen result = null; // while (obj.parent != null && !(obj.parent is Screen) && obj.parent is DisplayObjectContainer) // { // obj = (DisplayObjectContainer)obj.parent; // } // if (obj.parent is Screen) // { // result = (Screen)obj.parent; // } // return result; //} public virtual void SetStageAndScreen() { if (!isOnStage) { stage = GetStage(); screen = GetScreen(); } }
/// <summary> /// When this object, or a parent object is removed from stage. /// </summary> public virtual void RemovedFromStage(EventArgs e) { if (stage != null) { stage.ObjectRemovedFromStage(this); } isOnStage = false; stage = null; }