C# XNA: Custom drawing class isn't printing text though it has the location right -


So I'm trying to attract some text with C # and XNA. I have been properly loaded SprintFont , there is no bug in the code and there are no compile time warnings or errors. I will not get any error during execution.

When I pull text from my main game class, it works fine. However, I have found a different category that I am trying to attract. I have created an example of this, which is named Constructor and the Draw () function, yet it still does not work.

Here is the main game class (the relevant bits anyway):

  Protected Override Zero Draw (GameTime Game Time) {GraphicsDevice.Clear (Color.Turquoise); If (! StartScreen.hasRun) {// Works fine spriteBatch.Begin (); Spritebatch.DrawString (spaceAge, "Score 0", new vector 2 (50, 50), color. Black); SpriteBatch.End (); // start.screen.Draw (spritebatch) failed to attract; } And {} base.Draw (gametime); }  

Here is the startScreen example of the draw () function that references (differently created by StartScreen Class in another file):

  Public Boolean Draw (SpriteBatch Spreadbatch) {If (this.hasRun == incorrect) {spriteBatch.Beggin (); Spritebatch.Draw (This background, new rectangle (0, 0, it's screenview, it screen. Highlight), color. White); Spritebatch.DrawString (this.font, "DevBuild: 001", New Vector 2 (This. TextStart, 50), Color. Black); SpriteBatch.End (); / * Console.lightline ("HARRAN:" + HARNAN); Console.light line ("screenwidth:" + convert.tostring (screenwidth)); Console.light line ("screen-light:" + convert to toastring (screen-hight); Console.light line ("dimension. X:" + convert.tostring (stringDimensions.X)); Console.light line ("dimension .Y:" + convert.tostring (stringDimensions.Y)); Console.lightline ("textstart:" + convert.tostring (textstart); * / // All logs above give correct output. HasRun = true; Console.print line ("hayn:" + hiran); Back true; } And false return; }  

Why, when in this function ( (textStart, 50) where textStart is the right on- Screen coordinates calculates 312 on an 800-wide screen), and call to DrawString is the same format, does not the text appear?

Feel free to ask more code if it is necessary.

( spritebatch.Draw to make NB call does not work here, the image is not drawn - maybe this is the same issue?)

Edit Do: I have tried the suggestions given below: start () and expire () from StartScreen class and start.screen has been called within the call Draw () Draw > within the Draw () function of the game between start () and end () / Code>. Still nothing emerges. Instead of creating your own draw method, a public bubble makes it publicly void, a variable bool,

So this should work and your code should look like this:

  bool drawn = false; // is defined at the top of its class so that the draw method is not required to be a bulging public zero draw (Spritebatch Spratbatch) (if (this.hasRun == incorrect) {spriteBatch.Beggin (); Spritebatch.Draw ( This background, new rectangle (0, 0, it's screenview, this screen.height), color white); Spritebatch.DrawString (this.font, "DevBuild: 001", new vector 2 (this textstart, 50) , Color. Black); spriteBatch.End (); / * console.lightline ("HARRAN:" + HARN); console.light line ("screen Width: "+ Convert.tostring (screenwidth); console.light line (" Screenshite: "+ Convert.tostring (screenhit); console.light line (" dimension.x: "+ convert.Trowstring (stringDimensions.X) Console.light line ("Dimensions: Y:" + Convert.tostring (stringDimensions.Y); Console.lightline ("TextStart:" + Convert.tostring (textstart)) * / // All logs above are true output HasRun = true; console.light line ("HARN:" + HARNAN); b Other = Drew = false;}}  

Also, why your dracula should not be at all with the code given by you, it does not seem that you have it anywhere Used


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -