#EDIT#
found solution:
add
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
after any time you call
SpriteBatch.Begin();
SpriteBatch.DrawString(SpriteFont, outputStr, position, Color.Black);
SpriteBatch.End();
http://blogs.msdn.com/b/shawnhar/arch...
#EDIT#
for some unknown reason, when ever I call these three lines of code I get major graphical errors
SpriteBatch.Begin();
SpriteBatch.DrawString(SpriteFont, DisplayMessage, position, Color.Black);
SpriteBatch.End();
heres the graphics issue, for some reason it just makes the game go crazy.
if anyone needs it, here is the full code for this part:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DoTs
{
class WordComponent : DrawableGameComponent
{
private wordDictionary wordDic;
private WLvalue wordVals;
private string[] words;
protected SpriteFont SpriteFont { get; set; }
protected SpriteBatch SpriteBatch { get; set; }
public WordComponent(Game game)
: base(game)
{
}
protected override void LoadContent()
{
wordDic = new wordDictionary();
words = new string[3];
wordVals = new WLvalue();
newWords();
SpriteBatch = new SpriteBatch(GraphicsDevice);
SpriteFont = Game.Content.Load("SpriteFont1");
}
public void newWords()
{
words[0] = wordDic.getLow();
words[1] = wordDic.getMed();
words[2] = wordDic.getHigh();
}
///
/// accepts from 0-2, 0 = lowVal word, 1 = medVal word, 2 = highVal word
///
/// a string to be used as a goal for the player or a "" string if the wordNum is
/// out of bounds
public string getWord(int wordNum)
{
string retVal = "";
if (wordNum < 3 && wordNum >= 0)
{
retVal = words[wordNum];
}
return (retVal);
}
public int getWordVal(int wordNum)
{
int retVal = -1;
if (wordNum < 3 && wordNum >= 0)
{
retVal = wordVals.getWordVal(words[wordNum]);
}
return (retVal);
}
public override void Draw(GameTime gameTime)
{
float left = GraphicsDevice.Viewport.TitleSafeArea.Left;
float top = GraphicsDevice.Viewport.TitleSafeArea.Top;
Vector2 position = new Vector2(left + 90, top);
string DisplayMessage = "";
int i;
for (i = 0; i < 3; i++)
{
DisplayMessage += getWord(i);
DisplayMessage += " - ";
DisplayMessage += getWordVal(i);
DisplayMessage += "\n";
}
SpriteBatch.Begin();
SpriteBatch.DrawString(SpriteFont, DisplayMessage, position, Color.Black);
SpriteBatch.End();
base.Draw(gameTime);
}
}
}
it is implimented into the game like this:
protected override void Initialize()
{
...
Components.Add(new WordComponent(this));
base.Initialize();
}
:( please somone help me, The assignment is due tomorow, it would suck if I would have to decide between GUI and graphics
edit:
I think that the error is some how related to the z buffer getting stuffed with... there was an object under the word which when I placed my cammera at a sertain angle the far away object was drawing over the top of the car