本文整理汇总了C#中Sprite.Draw2D方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.Draw2D方法的具体用法?C# Sprite.Draw2D怎么用?C# Sprite.Draw2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.Draw2D方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Draw
/// <summary>
/// Draw this gauge as a sprite (using current animation frame).
/// Called every video frame
/// </summary>
/// <param name="sprite"></param>
public override void Draw(Sprite sprite)
{
if (enabled)
{
// Draw the background texture
sprite.Draw2D(texture, srcRect, destSize, destPosn, Color.White);
// Draw our children on top
foreach (Widget w in widgetList)
{
w.Draw(sprite);
}
}
}
示例3: Draw
public void Draw( Sprite sprite, int grid_size )
{
if (m_file_texture != null)
{
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw2D(m_file_texture, m_source, new Rectangle(0, 0, grid_size, grid_size), new Point((int)((float)m_location.X * ((float)grid_size / ((float)grid_size / (float)m_source.Width))),
(int)(float)(m_location.Y * ((float)grid_size / ((float)grid_size / (float)m_source.Height)))), Color.White);
sprite.End();
}
}
示例4: drawRadar
/// <summary>
/// Draws the radar.
/// </summary>
public void drawRadar()
{
using (Sprite s = new Sprite(device))
{
s.Begin(SpriteFlags.AlphaBlend);
Point playerP = new Point((int)player.Location.X + radarPoint.X,
(int)player.Location.Z + radarPoint.Y);
s.Draw2D(ContentLoader.Radar, Rectangle.Empty, new Size((int)(playerP.X * 2), (int)((this.height-playerP.Y) * 2)),
new Point(0, (int)(this.height - (this.height - playerP.Y) * 2)), Color.White);
s.Draw2D(this.radarEnemyTexture, Rectangle.Empty,
this.enemySize, playerP, Color.LightSkyBlue);
s.Draw2D(ContentLoader.GUIBack, Rectangle.Empty, new Size((int)(this.width * 0.15f), 120),
new Point(0, 0), Color.White);
foreach (Enemy e in enemies)
{
Point point = new Point(
(int)(radarPoint.X + e.Location.X * Math.Cos(player.Head.Rotation.X) - e.Location.Z * Math.Sin(player.Head.Rotation.X)),
(int)(radarPoint.Y - e.Location.X * Math.Sin(player.Head.Rotation.X) - e.Location.Z * Math.Cos(player.Head.Rotation.X)));
s.Draw2D(this.radarEnemyTexture, Rectangle.Empty,
this.enemySize, point, Color.Red);
}
s.End();
}
}
示例5: drawHealth
/// <summary>
/// Draws the given texture to the given point on the screen.
/// </summary>
/// <param name="texture">The texture to draw.</param>
/// <param name="point">Where to display the texture on the screen.</param>
/// <param name="scale">The amount to scale the x value of the Sprite.</param>
public void drawHealth(Texture texture, Point point, float scale)
{
Size healthSize = new Size((int)((this.width * 0.288f) * scale),
(int)(this.height * 0.060));
this.healthBarSize = new Size((int)(this.width * 0.530f),
(int)(this.height * 0.24));
using (Sprite s = new Sprite(device))
{
Point newPoint = new Point((int)(this.width * 0.0344) + point.X,
(int)(this.height * 0.0736) + point.Y);
Size healthBack = new Size((int)(this.width-(this.width-newPoint.X+30)),
(int)(this.height * 0.120));
s.Begin(SpriteFlags.AlphaBlend);
s.Draw2D(ContentLoader.GUIBack, Rectangle.Empty,
healthBack, new Point(newPoint.X-30, 0), Color.White);
s.Draw2D(healthTexture, new Rectangle(point, healthSize),
healthSize, newPoint, Color.Red);
s.Draw2D(texture, Rectangle.Empty, healthBarSize, point, Color.Black);
s.End();
}
}