本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawTextWithShadow方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawTextWithShadow方法的具体用法?C# SpriteBatch.DrawTextWithShadow怎么用?C# SpriteBatch.DrawTextWithShadow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.DrawTextWithShadow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawButton
private void DrawButton(SpriteBatch spriteBatch, Vector2 position, Rectangle sprite, string label, float alpha, bool labelWithShadow)
{
spriteBatch.Draw(_buttonsTexture, position, sprite, Color.White * alpha);
if (label != "")
{
var h = SceneManager.Instance.GameFontSmall.MeasureString(label).Y;
var labelPosition = position + new Vector2(18, (15 - h) / 2);
if (labelWithShadow)
spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFontSmall, label, labelPosition, Color.White * alpha);
else
spriteBatch.DrawString(SceneManager.Instance.GameFontSmall, label, labelPosition, Color.White * alpha);
}
}
示例2: Draw
public override void Draw(SpriteBatch spriteBatch, ViewportAdapter viewportAdapter)
{
base.Draw(spriteBatch, viewportAdapter);
var screenSize = SceneManager.Instance.VirtualSize;
var gameFont = SceneManager.Instance.GameFont;
spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: viewportAdapter.GetScaleMatrix());
// Background
spriteBatch.Draw(_backgroundTexture, _backgroundTexture.Bounds, Color.White);
// Title
var titleString = _titleStrings[SceneManager.Instance.TypeOfSceneSaves];
var titleX = (SceneManager.Instance.VirtualSize.X - SceneManager.Instance.GameFontBig.MeasureString(titleString).X) / 2;
spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFontBig, titleString, new Vector2(titleX, 10), Color.White);
// Slots
for (var i = 0; i < 3; i++)
{
var slotPosition = _slotsPosition[i].Location.ToVector2();
// Check if the slot isn't empty
if (_gameSaves[i].StagesCompleted > 0)
{
// Pete Head
if (_slotIndex == i)
{
_peteAnimatedSprite.Position = slotPosition + _peteHeadPosition;
_peteAnimatedSprite.Draw(spriteBatch);
}
else
{
spriteBatch.Draw(_peteSpritesheet, slotPosition + _peteHeadPosition, _peteDefaultFrame, Color.White);
}
// Save Name
spriteBatch.DrawString(gameFont, "SAVE NAME", slotPosition + _namePosition, _fontColor);
// Stages
var divisorPosition = Vector2.Zero;
for (var j = 0; j < _gameSaves[i].StagesCompleted; j++)
{
var markPosition = slotPosition + _stagesPosition + ((_stagePeteMarkFrame.Width + 4) * j * Vector2.UnitX);
spriteBatch.Draw(_stageSpritesheet, markPosition, _stagePeteMarkFrame, Color.White);
if (j < SceneManager.MaxLevels - 1)
{
divisorPosition = markPosition + (_stagePeteMarkFrame.Width + 1) * Vector2.UnitX + (9 * Vector2.UnitY);
spriteBatch.Draw(_stageSpritesheet, divisorPosition, _stageDivisorFrame, Color.White);
}
}
if (_gameSaves[i].StagesCompleted < SceneManager.MaxLevels)
{
var nextMarkPos = (divisorPosition == Vector2.Zero) ? (slotPosition + _stagesPosition) : (divisorPosition - (9 * Vector2.UnitY) + (3 * Vector2.UnitX));
if (_slotIndex == i)
{
_nextStageMarkAnimatedSprite.Position = nextMarkPos;
_nextStageMarkAnimatedSprite.Draw(spriteBatch);
}
else
{
spriteBatch.Draw(_stageSpritesheet, nextMarkPos, _stageNextMarkFrame, Color.White);
}
}
// Lives
var lives = _gameSaves[i].Lives;
var livesWidth = (lives * _lifeFrame.Width) + (lives - 1);
var livesPosition = slotPosition + (_slotsPosition[i].Width - livesWidth - _livesPosition.X) * Vector2.UnitX + _livesPosition.Y * Vector2.UnitY;
for (var j = 0; j < lives; j++)
{
var lifePosition = livesPosition + ((_lifeFrame.Width + 1) * j * Vector2.UnitX);
spriteBatch.Draw(_iconsSpritesheet, lifePosition, _lifeFrame, Color.White);
}
// Hearts
var hearts = _gameSaves[i].Hearts;
var heartsWidth = (hearts * _heartFrame.Width) + (hearts - 1) * 5;
var heartsPosition = slotPosition + (_slotsPosition[i].Width - heartsWidth - _heartsPosition.X) * Vector2.UnitX + _heartsPosition.Y * Vector2.UnitY;
for (var j = 0; j < hearts; j++)
{
var heartPosition = heartsPosition + ((_heartFrame.Width + 5) * j * Vector2.UnitX);
spriteBatch.Draw(_iconsSpritesheet, heartPosition, _heartFrame, Color.White);
}
// Ammo
spriteBatch.Draw(_iconsSpritesheet, slotPosition + _ammoPosition, _ammoFrame, Color.White);
spriteBatch.DrawString(gameFont, _gameSaves[i].Ammo.ToString(), slotPosition + _ammoTextPosition, _fontColor);
// Coins
spriteBatch.Draw(_iconsSpritesheet, slotPosition + _coinsPosition, _coinFrame, Color.White);
spriteBatch.DrawString(gameFont, _gameSaves[i].Coins.ToString(), slotPosition + _coinsTextPosition, _fontColor);
}
else
{
// Empty slot text
var emptySlotTextSize = gameFont.MeasureString(EmptySlotText);
var emptyPosition = new Vector2(slotPosition.X + (_slotsPosition[i].Width - emptySlotTextSize.X) / 2,
slotPosition.Y + (_slotsPosition[i].Height - emptySlotTextSize.Y) / 2);
//.........这里部分代码省略.........
示例3: Draw
public void Draw(SpriteBatch spriteBatch)
{
if (!_paused) return;
spriteBatch.Draw(_backgroundTexture, _backgroundDrawArea, Color.White * 0.5f);
spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFontBig, Title, _pausePosition, Color.White);
for (var i = 0; i < _menu.Length; i++)
{
var position = new Vector2(_menuItemsX[i], _menuY + (i * SceneManager.Instance.GameFont.LineHeight));
spriteBatch.DrawTextWithShadow(SceneManager.Instance.GameFont, _menu[i], position, Color.White);
}
spriteBatch.Draw(_cursor, new Vector2(_menuItemsX[_index] - 16, _menuY + (_index * SceneManager.Instance.GameFont.LineHeight) - 1), Color.White);
}
示例4: Draw
public void Draw(SpriteBatch spriteBatch)
{
var screenSize = SceneManager.Instance.VirtualSize;
var fontBig = SceneManager.Instance.GameFontBig;
var font = SceneManager.Instance.GameFont;
var format = "{0}/{1}";
spriteBatch.Draw(_background, new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y), Color.White * 0.5f);
var coinsLPos = new Vector2(_rowsInnerPositionsLeft[0, Current], 60);
var coinsRPos = new Vector2(_rowsInnerPositionsRight[0], 60);
var heartsLPos = new Vector2(_rowsInnerPositionsLeft[1, Current], 85);
var heartsRPos = new Vector2(_rowsInnerPositionsRight[1], 85);
var enemiesLPos = new Vector2(_rowsInnerPositionsLeft[2, Current], 110);
var enemiesRPos = new Vector2(_rowsInnerPositionsRight[2], 110);
var timeLPos = new Vector2(_rowsInnerPositionsLeft[3, Current], 135);
var timeRPos = new Vector2(_rowsInnerPositionsRight[3], 135);
spriteBatch.DrawTextWithShadow(fontBig, _completed ? TitleCompleted : TitleFailed, _titlePosition, Color.White);
var coinsStr = String.Format(format, _values[0, 0], _data.MaxCoins);
var coinsColor = CalculateColor(_values[0, 0], _data.MaxCoins);
spriteBatch.DrawTextWithShadow(font, CoinsEarned, coinsLPos, Color.White);
spriteBatch.DrawRightText(font, coinsStr, coinsRPos, coinsColor, Color.Black);
var heartsColor = CalculateColor(_values[1, 0], 0);
spriteBatch.DrawTextWithShadow(font, HeartsLost, heartsLPos, Color.White);
spriteBatch.DrawRightText(font, _values[1, 0].ToString(), heartsRPos, heartsColor, Color.Black);
var enemiesStr = String.Format(format, _values[2, 0], _data.MaxEnemies);
var enemiesColor = CalculateColor(_values[2, 0], _data.MaxEnemies);
spriteBatch.DrawTextWithShadow(font, EnemiesDefeated, enemiesLPos, Color.White);
spriteBatch.DrawRightText(font, enemiesStr, enemiesRPos, enemiesColor, Color.Black);
var timeColor = CalculateColor(_timeValues[0], _data.MaxTime);
spriteBatch.DrawTextWithShadow(font, Time, timeLPos, Color.White);
spriteBatch.DrawRightText(font, FormatTime(_timeValues[0]), timeRPos, timeColor, Color.Black);
if (_phase >= 1)
{
spriteBatch.DrawTextWithShadow(font, _rankSentences[_rank], _rankSentencePosition, Color.White * _rankSentenceAlpha);
if (_rank == "S")
((AnimatedSprite)_rankSprite).Draw(spriteBatch);
else
_rankSprite.Draw(spriteBatch);
}
IconsManager.Instance.DrawActionButton(spriteBatch, new Vector2(5, screenSize.Y - 40), false, "Continue", _buttonsAlpha, true);
IconsManager.Instance.DrawCancelButton(spriteBatch, new Vector2(5, screenSize.Y - 20), false, "Again", _buttonsAlpha, true);
}