本文整理汇总了C#中SpriteBatch.DrawTexture方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawTexture方法的具体用法?C# SpriteBatch.DrawTexture怎么用?C# SpriteBatch.DrawTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.DrawTexture方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(SpriteBatch spriteBatch, GameTime time)
{
if (!Visible) return;
var tex = (IsChecked) ? Textures[0] : Textures[1];
tex = (Enabled) ? tex : (IsChecked) ? Textures[2] : Textures[3];
spriteBatch.DrawTexture(tex, new Rectangle(Position.X, Position.Y, Size.Width, Size.Height), Color.White);
spriteBatch.DrawString(Text, Font, new Vector2(Position.X + 35, Position.Y + 5), Color);
}
示例2: HandleDraw
private void HandleDraw(SpriteBatch spriteBatch, Vector2 position, Color4 color, float rotation, float scale, Vector2 origin)
{
Animation2DFrame currentFrame = animation[frameIndex];
Vector2 totalScale = new Vector2(currentFrame.Scale * scale);
float totalRotation = rotation + currentFrame.Rotation;
spriteBatch.DrawTexture(currentFrame.Texture, position - TextureOffset, color, totalRotation, totalScale, origin);
}
示例3: Draw
public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
{
if (!Visible) return;
var size = Font.MeasureString(Text);
spriteBatch.DrawTexture(IsHovered ? _hoveredTexture : _texture,
new Rectangle(Position.X, Position.Y, Size.Width, Size.Height));
spriteBatch.DrawString(Text, Font,
new Vector2(Position.X + ((Size.Width - size.X) / 2), Position.Y + ((Size.Height - size.Y) / 2)),
Color.White);
base.Draw(spriteBatch, gameTime);
}
示例4: Draw
public override void Draw(SpriteBatch batch, GameTime time)
{
batch.Begin();
// Draw wood background
for (var x = 0; x < 11; x++)
{
for (var y = 0; y < 8; y++)
{
var tileX = x * ChainReactGame.WabeSize;
var tileY = y * ChainReactGame.WabeSize;
batch.DrawTexture(_background, new Rectangle(tileX, tileY, ChainReactGame.WabeSize, ChainReactGame.WabeSize));
}
}
// Draw gray game field
for (var x = 1; x < 7; x++)
{
for (var y = 1; y < 7; y++)
{
var tileX = x * ChainReactGame.WabeSize;
var tileY = y * ChainReactGame.WabeSize;
batch.DrawTexture(_gameAreaTexture, new Rectangle(tileX, tileY, ChainReactGame.WabeSize, ChainReactGame.WabeSize));
}
}
// Draw wabes
const float cut = (ChainReactGame.WabeSize / 3);
var fullWabeSizeX = ChainReactGame.WabeSize * _game.GameMap.Wabes.GetLength(0);
var fullWabeSizeY = ChainReactGame.WabeSize * _game.GameMap.Wabes.GetLength(1);
foreach (var wabe in _game.GameMap.Wabes)
{
var wabeX = (wabe.X + 1) * ChainReactGame.WabeSize;
var wabeY = (wabe.Y + 1) * ChainReactGame.WabeSize;
for (var x = 0; x <= 2; x++)
{
for (var y = 0; y <= 2; y++)
{
var field = wabe.ConvertVector2ToWabeField(new Vector2(x, y));
var texture = SelectTextureFromField(field);
var mutltiplicatorX = cut * x;
var mutltiplicatorY = cut * y;
if (field.Type == WabeFieldType.Center)
{
var color = wabe.Owner?.Color ?? Color.White;
color.A = (wabe.Owner != null) ? (byte)205 : (byte)255;
batch.DrawTexture(texture, new Rectangle((wabeX) + mutltiplicatorX, (wabeY) + mutltiplicatorY, cut, cut), color);
}
else if (field.Type == WabeFieldType.Unused)
{
var color = wabe.Owner?.Color ?? Color.LightGray;
color.A = 128;
batch.DrawTexture(texture, new Rectangle((wabeX) + mutltiplicatorX, (wabeY) + mutltiplicatorY, cut, cut), color);
}
else
{
batch.DrawTexture(texture,
new Rectangle((wabeX) + mutltiplicatorX, (wabeY) + mutltiplicatorY, cut, cut));
}
var posX = mutltiplicatorX + wabeX;
var posY = mutltiplicatorY + wabeY;
// Draw field border
if (GameSettings.Instance.FieldLines)
batch.DrawTexture(_fieldBorder, new Rectangle(posX, posY, cut, cut));
}
}
// Draw wabe border
if (GameSettings.Instance.WabeLines)
batch.DrawTexture(_wabeBorder, new Rectangle(wabeX, wabeY, ChainReactGame.WabeSize, ChainReactGame.WabeSize));
}
// Draw game border
if (GameSettings.Instance.BorderLines)
batch.DrawTexture(_gameBorder, new Rectangle(ChainReactGame.WabeSize, ChainReactGame.WabeSize, fullWabeSizeX, fullWabeSizeY));
// Draw messages
if (!string.IsNullOrEmpty(_lastMessage))
{
batch.DrawString(!string.IsNullOrEmpty(_game.Message) ? _game.Message : _lastMessage, _font,
new Vector2(96, 680), Color.Black);
}
else
{
if (!string.IsNullOrEmpty(_game.Message))
{
batch.DrawString(_game.Message, _font, new Vector2(96, 680), Color.Black);
}
}
if (!string.IsNullOrEmpty(ResourceManager.LastSoundError))
{
batch.DrawString("Failed to play a sound: " + ResourceManager.LastSoundError, _font, new Vector2(96, 720), Color.Red);
}
if (_game?.CurrentPlayer != null)
{
batch.DrawString(_game.CurrentPlayer.Name + $"'s turn ({_game.CurrentPlayer.GetColorString()}) ({_game.CurrentPlayer.Wins} Wins)", _font, new Vector2(96, 60), Color.Black);
}
foreach (var wabe in _game.GameMap.Wabes.Cast<Wabe>().ToList().Where(x => x.AnimationManager.IsRunning).Select(x => x.AnimationManager))
//.........这里部分代码省略.........
示例5: Draw
public override void Draw(double elapsed, SpriteBatch spriteBatch, Vector2 position, OpenTK.Graphics.Color4 color, float rotation, float scale, Vector2 origin)
{
Vector2 scaleVec = new Vector2(scale);
spriteBatch.DrawTexture(Texture, position - TextureOffset, color, rotation, scaleVec, origin);
}