本文整理汇总了C#中Sprite.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.Dispose方法的具体用法?C# Sprite.Dispose怎么用?C# Sprite.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPaint
protected override void OnPaint(PaintEventArgs pe)
{
if ((this.m_FormRenderFrame.Device != null) && (this.m_FormRenderFrame.Texture != null) && (this.Visible) && (this.WindowState != FormWindowState.Minimized)) {
try {
this.m_FormRenderFrame.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1F, 0);
SurfaceDescription surfaceDescription = this.m_FormRenderFrame.Texture.GetLevelDescription(0);
Size size = new Size(surfaceDescription.Width, surfaceDescription.Height);
Size targetSize = new Size(Math.Max(1, (Int32)((Single)size.Width * this.m_ZoomFactor)), Math.Max(1, (Int32)((Single)size.Height * this.m_ZoomFactor)));
if (this.Size != targetSize) {
this.Size = targetSize;
}
this.m_FormRenderFrame.Device.BeginScene();
Sprite sprite = new Sprite(this.m_FormRenderFrame.Device);
sprite.Begin(SpriteFlags.None);
sprite.Draw2D(this.m_FormRenderFrame.Texture, new Rectangle(new Point(0, 0), size), new SizeF(((Single)size.Width * this.m_ZoomFactor), ((Single)size.Height * this.m_ZoomFactor)), new PointF(0F, 0F), Color.FromArgb(255, 255, 255, 255));
sprite.End();
sprite.Dispose();
this.m_FormRenderFrame.Device.EndScene();
this.m_FormRenderFrame.Device.Present();
} catch {
}
}
}
示例2: DrawInfo
/// <summary>
/// Draw the player information.
/// </summary>
/// <param name="device">The direct3D device.</param>
private void DrawInfo(Device device)
{
try
{
int deviceWidth = device.Viewport.Width;
int deviceHeight = device.Viewport.Height;
long frameCounter = _memory.GetFrameCount();
if (frameCounter > 10)
{
if (string.IsNullOrEmpty(_playerOneName))
{
_playerOneName = _memory.GetCharacter(1);
}
if (string.IsNullOrEmpty(_playerTwoName))
{
_playerTwoName = _memory.GetCharacter(2);
}
_sprite = new Sprite(_device);
_sprite.Begin(SpriteFlags.AlphaBlend);
_sprite.Transform
= Matrix.Scaling(new Vector3(_fontSize / (12 / 2), _fontSize / (7 / 2), 0));
_spritePosition = new Vector2(
_fontSize,
(deviceHeight / _fontSize) * 7);
_sprite.Draw(_background, new Vector3(1, 1, 0), new Vector3(_spritePosition, -1), Color.White);
_spritePosition = new Vector2(
deviceWidth - (_fontSize * 13),
(deviceHeight / _fontSize) * 7);
_sprite.Draw(_background, new Vector3(1, 1, 0), new Vector3(_spritePosition, -1), Color.White);
_sprite.End();
_sprite.Dispose();
_sprite = new Sprite(_device);
_sprite.Begin(SpriteFlags.AlphaBlend);
// P1
string playerOneHeader = string.Format("-{0}'s STATS-", _playerOneName);
string playerOnePos = string.Format(
"[{0},{1}]",
_memory.GetPosX(1).ToString("F3"),
_memory.GetPosY(1).ToString("F3"));
string playerOneHealth = string.Format("HP : {0}", _memory.GetHealth(1));
string playerOneStun = string.Format("STUN : {0}", _memory.GetStun(1));
string playerOneEx = string.Format("EX : {0}", _memory.GetEXmeter(1));
string playerOneUltra = string.Format("ULTRA : {0}", _memory.GetUltraMeter(1));
string playerOneScript = string.Format(
"ANIM : {0} ({1})",
_memory.PlayerAnim(1),
_memory.GetAnimFrame(1));
int playerOneInterruptFrame = _memory.GetInterruptFrame(1);
string playerOneInterrupt = string.Format("INTRPT: {0}", playerOneInterruptFrame);
// P2
string playerTwoHeader = string.Format("-{0}'s STATS-", _playerTwoName);
string playerTwoPos = string.Format(
"[{0},{1}]",
_memory.GetPosX(2).ToString("F3"),
_memory.GetPosY(2).ToString("F3"));
string playerTwoHealth = string.Format("HP : {0}", _memory.GetHealth(2));
string playerTwoStun = string.Format("STUN : {0}", _memory.GetStun(2));
string playerTwoEx = string.Format("EX : {0}", _memory.GetEXmeter(2));
string playerTwoUltra = string.Format("ULTRA : {0}", _memory.GetUltraMeter(2));
string playerTwoScript = string.Format(
"ANIM : {0} ({1})",
_memory.PlayerAnim(2),
_memory.GetAnimFrame(2));
int playerTwoInterruptFrame = _memory.GetInterruptFrame(2);
string playerTwoInterrupt = string.Format("INTRPT: {0}", playerTwoInterruptFrame);
string playerOneAdv = string.Format("ADV : {0}", playerOneInterruptFrame - playerTwoInterruptFrame);
string playerTwoAdv = string.Format("ADV : {0}", playerTwoInterruptFrame - playerOneInterruptFrame);
string playerOneStats = string.Join(
"\n",
playerOneHeader,
playerOnePos,
playerOneHealth,
playerOneStun,
playerOneEx,
playerOneUltra,
playerOneScript,
playerOneInterrupt,
playerOneAdv);
string playerTwoStats = string.Join(
"\n",
playerTwoHeader,
//.........这里部分代码省略.........