Note that there are some explanatory texts on larger screens.

plurals
  1. POXNA DrawString() draws only a partial string
    primarykey
    data
    text
    <p>I have a problem with <code>DrawString()</code> in <code>XNA</code>. I use multiple <code>SpriteBatches</code> for several logical layers. For example: background, objects, menus and so on. </p> <p>In my menu batch, I draw a menu (the big grey box in the background), the buttons (the smaller grey boxes on the menu) and the strings for the buttons. </p> <p>The Problem: <a href="http://ompldr.org/vaGw4YQ/Unbenannt.png" rel="nofollow">http://ompldr.org/vaGw4YQ/Unbenannt.png</a></p> <p>But for some reason, the strings aren't drawn completely. Does anyone know why?</p> <p><strong>EDIT:</strong></p> <pre><code>_menuLayer.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); if (_menu != null) { _menuLayer.Draw(_menuBoard, new Vector2(graphics.PreferredBackBufferWidth / 2 - 160, graphics.PreferredBackBufferHeight / 2 - 240), Color.White); } _menuLayer.End(); _buttonLayer.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); if (_menu != null) { foreach (Button button in _menu.Buttons) { if (button.Pressed) { _buttonLayer.Draw(_menuButtonPressed, button.Location, Color.White); _buttonLayer.DrawString(_text, button.Text, button.GiveStringLocation(_text), Color.Black); } else { _buttonLayer.Draw(_menuButton, button.Location, Color.White); _buttonLayer.DrawString(_text, button.Text, button.GiveStringLocation(_text), Color.Black); } } } _buttonLayer.End(); &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!-- This file contains an xml description of a font, and will be read by the XNA Framework Content Pipeline. Follow the comments to customize the appearance of the font in your game, and to change the characters which are available to draw with. --&gt; &lt;XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics"&gt; &lt;Asset Type="Graphics:FontDescription"&gt; &lt;!-- Modify this string to change the font that will be imported. --&gt; &lt;FontName&gt;Arial&lt;/FontName&gt; &lt;!-- Size is a float value, measured in points. Modify this value to change the size of the font. --&gt; &lt;Size&gt;20&lt;/Size&gt; &lt;!-- Spacing is a float value, measured in pixels. Modify this value to change the amount of spacing in between characters. --&gt; &lt;Spacing&gt;0&lt;/Spacing&gt; &lt;!-- UseKerning controls the layout of the font. If this value is true, kerning information will be used when placing characters. --&gt; &lt;UseKerning&gt;true&lt;/UseKerning&gt; &lt;!-- Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic", and "Bold, Italic", and are case sensitive. --&gt; &lt;Style&gt;Bold&lt;/Style&gt; &lt;!-- If you uncomment this line, the default character will be substituted if you draw or measure text that contains characters which were not included in the font. --&gt; &lt;!-- &lt;DefaultCharacter&gt;*&lt;/DefaultCharacter&gt; --&gt; &lt;!-- CharacterRegions control what letters are available in the font. Every character from Start to End will be built and made available for drawing. The default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin character set. The characters are ordered according to the Unicode standard. See the documentation for more information. --&gt; &lt;CharacterRegions&gt; &lt;CharacterRegion&gt; &lt;Start&gt;&amp;#32;&lt;/Start&gt; &lt;End&gt;&amp;#126;&lt;/End&gt; &lt;/CharacterRegion&gt; &lt;/CharacterRegions&gt; &lt;/Asset&gt; &lt;/XnaContent&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload