c# - Drawing a GUI in XNA -
i'm working on making xna 2d platformer, , i'm wondering if it's possible draw kind of static gui on game?
what mean here while game updates , players position changes etc, gui drawn on kind of static layer (overlay?), size of window game being run in. way game wouldn't have update gui's position , little bit nicer handle.
any ideas?
thanks time
yeah, can draw them using spritebatch :)
//hudtexture transparent texture size of window/screen, hud drawn onto it. spritebatch.draw(hudtexture, vector2.zero, color.white); //let's works draw score @ [100,100]. spritebatch.drawstring(hudfont, points.tostring(), new vector2(100,100), color.white);
if plan on making more gui (buttons etc) might want check out answer wrote other post: xna drawstring() draws partial string
also; drawing scores etc, have experienced quite bit of boxing/unboxing because of tostring. reason, have had array of strings represent score:
string[] scoretext = new string[100000]; //as big max score //in initializing method: (int = 0; < scoretext.length; i++) scoretext[i] = i.tostring(); //in draw: spritebatch.drawstring(hudfont, scoretext[points], new vector2(100,100), color.white);
Comments
Post a Comment