本文整理汇总了C#中Sprite.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.Draw方法的具体用法?C# Sprite.Draw怎么用?C# Sprite.Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw(Sprite sprite)
{
if (_isHover)
sprite.Draw(_texShd.Texture, new Rectangle(3, 0, 45, 52), new Vector3(0f, 0f, 0f), new Vector3((Single)_rect.X, (Single)_rect.Y, 0f), Color.White);
sprite.Draw(_tex.Texture, new Rectangle(3, 0, 45, 52), new Vector3(0f, 0f, 0f), new Vector3((Single)_rect.X, (Single)_rect.Y, 0f), Color.White);
}
示例2: Render
public override void Render(Sprite sprite)
{
Rectangle rect = new Rectangle(0, 0, 1280, 720);
if (currentFrame >= frames.Length)
{
if (delay > 1.25f)
{
sprite.Draw(frames[frames.Length - 1], rect, ColorValue.White);
ColorValue color = ColorValue.White;
color.A = (byte)(byte.MaxValue * (1 - MathEx.Saturate((delay - 1.25f) / 1.25f)));
sprite.Draw(blackBg, rect, color);
}
else
{
ColorValue color = ColorValue.White;
color.A = (byte)(byte.MaxValue * MathEx.Saturate(delay / 1.25f));
sprite.Draw(blackBg, rect, color);
}
delay -= 0.04f;
}
else
{
sprite.Draw(frames[currentFrame], rect, ColorValue.White);
}
}
示例3: Render
public override void Render(Sprite sprite)
{
ColorValue color = ColorValue.White;
color.A = (byte)(byte.MaxValue * MathEx.Saturate(alpha));
sprite.Draw(overlay34, 0, 0, color);
if (alpha>=1)
{
sprite.Draw(lds_bg, 0, 0, ColorValue.White);
}
}
示例4: Render
public override void Render(Sprite sprite)
{
//Sprite.Transform = Matrix.Translation(X, Y, 0);
base.Render(sprite);
if (image != null)
{
sprite.Draw(image, X, Y, modColor);
}
}
示例5: Draw
public void Draw(Sprite sprite_resource, int diffuse)
{
sprite_resource.Transform =
Matrix.Scaling(Scaling) *
Matrix.RotationX(Rotation.X) *
Matrix.RotationY(Rotation.Y) *
Matrix.RotationZ(Rotation.Z) *
Matrix.Translation(Position);
sprite_resource.Draw(Texture, Center, Vector3.Empty, diffuse);
}
示例6: Render
public override void Render(Sprite sprite)
{
base.Render(sprite);
sprite.Draw(background, new Vector2(0, 613), ColorValue.White);
string msg = "TRANSFORM 23 CITIES";
fedge6.DrawString(sprite, msg, 130, 660, ColorValue.White);
fedge6.DrawString(sprite, "\n " + player.Area.CityCount.ToString() + " / 23 )", 130, 660, ColorValue.Yellow);
}
示例7: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
spritePosition = new Vector3(200f, 200f, 0f);
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0);
device.BeginScene();
using (Sprite sprite = new Sprite(device))
{
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw(tileSet.Texture, tilePosition, spriteCenter, spritePosition,
Color.FromArgb(255,255,255,255));
sprite.End();
}
device.EndScene();
device.Present();
this.Invalidate();
}
示例8: Render
public override void Render(Sprite sprite)
{
base.Render(sprite);
if (exitButton.IsMouseOver)
{
sprite.Draw(exitButton.Image, new Rectangle(-13, 0, exitButton.Image.Width, exitButton.Image.Height),
ColorValue.Yellow);
}
else
{
sprite.Draw(exitButton.Image, new Rectangle(-13, 0, exitButton.Image.Width, exitButton.Image.Height),
ColorValue.White);
}
}
示例9: TextureViewer_Load
void TextureViewer_Load(object sender, EventArgs e)
{
this.Show();
Application.DoEvents();
pp = new PresentParameters();
pp.BackBufferCount = 2;
pp.SwapEffect = SwapEffect.Discard;
pp.Windowed = true;
Direct3D d3d = new Direct3D();
d3d_device = new Device(d3d, 0, DeviceType.Hardware, d3dPanel.Handle, CreateFlags.HardwareVertexProcessing, pp);
texture = Texture.FromFile(d3d_device, texturePath);
int texWidth = texture.GetLevelDescription(0).Width;
int texHeight = texture.GetLevelDescription(0).Height;
d3dPanel.Top = menuStrip1.Height;
d3dPanel.Left = 0;
d3dPanel.ClientSize = new Size(texWidth, texHeight);
this.ClientSize = new System.Drawing.Size(
d3dPanel.Width,
d3dPanel.Height + menuStrip1.Height
);
pp.BackBufferWidth = texWidth;
pp.BackBufferHeight = texHeight;
d3d_device.Reset(pp);
sprite = new Sprite(d3d_device);
while (this.Visible)
{
d3d_device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, new Color4(Color.Black), 1.0f, 0);
d3d_device.BeginScene();
sprite.Begin(SpriteFlags.AlphaBlend);
Rectangle rect = new Rectangle()
{
X = 0,
Y = 0,
Width = texture.GetLevelDescription(0).Width,
Height = texture.GetLevelDescription(0).Height
};
sprite.Draw(texture, rect, new Color4(Color.White));
sprite.End();
d3d_device.EndScene();
d3d_device.Present();
Application.DoEvents();
}
}
示例10: Render
public override void Render(Sprite sprite)
{
if (state != NIGDialogState.Hiding)
{
ColorValue overlayColor = ColorValue.Transparent;
overlayColor.A = (byte)(165 * showPrg);
sprite.Draw(overlay, 0, 0, overlayColor);
int x = 451;
int y = 157;
float scale = -MathEx.Sqr(MathEx.Saturate(showPrg) * 1.5f - 1) + 1;
scale = (1.0f / 0.75f) * scale;
Matrix trans = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) *
Matrix.Scaling(scale, scale, 1) *
Matrix.Translation(x + background.Width / 2, y + background.Height / 2, 0);
sprite.SetTransform(trans);
sprite.Draw(background, 0, 0, ColorValue.White);
sprite.SetTransform(Matrix.Identity);
sprite.Draw(resumeButton.Image, resumeButton.X, resumeButton.Y, ColorValue.White);
if (resumeButton.IsMouseOver)
{
sprite.Draw(resumeButton.Image, resumeButton.X, resumeButton.Y - 4, ColorValue.White);
}
sprite.Draw(restartButton.Image, restartButton.X, restartButton.Y, ColorValue.White);
if (restartButton.IsMouseOver)
{
sprite.Draw(restartButton.Image, restartButton.X, restartButton.Y - 4, ColorValue.White);
}
sprite.Draw(exitButton.Image, exitButton.X, exitButton.Y, ColorValue.White);
if (exitButton.IsMouseOver)
{
sprite.Draw(exitButton.Image, exitButton.X, exitButton.Y - 4, ColorValue.White);
}
}
}
示例11: Render
public override void Render(Sprite sprite)
{
//spr.Transform = Matrix.Translation((int)(bounds.X + (bounds.Width - lblWidth) * 0.5f), (int)(bounds.Y + (bounds.Height - lblHeight) * 0.5f), 0);
if (IsValid)
{
if (Enabled)
{
if (IsPressed)
{
if (ImageMouseDown != null)
{
if (ResizeImage)
{
sprite.Draw(ImageMouseDown, new Rectangle(X, Y, radius * 2, radius * 2), modColor);
}
else
{
sprite.Draw(ImageMouseDown, X, Y, modColor);
}
}
}
else if (IsMouseOver)
{
if (ImageMouseOver != null)
{
if (ResizeImage)
{
sprite.Draw(ImageMouseOver, new Rectangle(X, Y, radius * 2, radius * 2), modColor);
}
else
{
sprite.Draw(ImageMouseOver, X, Y, modColor);
}
}
}
else
{
if (Image != null)
{
if (ResizeImage)
{
sprite.Draw(Image, new Rectangle(X, Y, radius * 2, radius * 2), modColor);
}
else
{
sprite.Draw(Image, X, Y, modColor);
}
}
}
}
else
{
if (ImageDisabled != null)
{
if (ResizeImage)
{
sprite.Draw(ImageDisabled, new Rectangle(X, Y, radius * 2, radius * 2), modColor);
}
else
{
sprite.Draw(ImageDisabled, X, Y, modColor);
}
}
}
}
else
{
if (ImageInvalid != null)
{
if (ResizeImage)
{
sprite.Draw(ImageInvalid, new Rectangle(X, Y, radius * 2, radius * 2), modColor);
}
else
{
sprite.Draw(ImageInvalid, X, Y, modColor);
}
}
}
//if (IsPressed)
//{
// Sprite.Transform = Matrix.Translation(X + 1, Y + 1, 0);
//}
base.Render(sprite);
}
示例12: RenderBallIcon
private void RenderBallIcon(Sprite sprite)
{
if (selectCity != null && selectCity.Owner == player)
{
//Array.Sort(resBallsCount, BallRecordCompare);
int left = 0;
for (int i = 0; i < resBallsCount.Length; i++)
{
RBallType ballType = resBallsCount[i].Type;
bool overrideDraw = selectCity.CanProduceProduction() ? (ballType == selectCity.GetProductionType()) : false;
//resBallsCount[i].Type == selectCity.GetProductionType()
switch (ballType)
{
case RBallType.Green:
{
if (resBallsCount[i].count != 0 || overrideDraw)
{
if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Green)
{
if (selectCity.IsFull())
{
sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White);
}
else
{
int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height);
sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height),
new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White);
}
}
int x = 687 + 69 * left - greenBallTex.Width / 2;
int y = 692 - greenBallTex.Height / 2;
sprite.Draw(greenBallTex, x, y, ColorValue.White);
Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) *
Matrix.Translation(new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0));
sprite.SetTransform(trans);
f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White);
sprite.SetTransform(Matrix.Identity);
left++;
}
}
break;
case RBallType.Education:
{
if (resBallsCount[i].count != 0 || overrideDraw)
{
if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Education)
{
if (selectCity.IsFull())
{
sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White);
}
else
{
int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height);
sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height),
new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White);
}
}
int x = 687 + 69 * left - educationBallTex.Width / 2;
int y = 692 - educationBallTex.Height /2 ;
sprite.Draw(educationBallTex, x, y, ColorValue.White);
Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) *
Matrix.Translation( new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0));
sprite.SetTransform(trans);
f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White);
sprite.SetTransform(Matrix.Identity);
left++;
}
}
break;
case RBallType.Health:
{
if (resBallsCount[i].count != 0 || overrideDraw)
{
if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Health)
{
if (selectCity.IsFull())
{
sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White);
}
else
{
int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height);
//.........这里部分代码省略.........
示例13: RenderSendBall
private void RenderSendBall(Sprite sprite)
{
if (targetCity != null)
{
float radLng = MathEx.Degree2Radian(targetCity.Longitude);
float radLat = MathEx.Degree2Radian(targetCity.Latitude);
float lngSign = Math.Sign(radLng);
Vector3 tangy = PlanetEarth.GetTangentY(radLng, radLat);
Vector3 tangx = PlanetEarth.GetTangentX(radLng, radLat);
Vector3 cityNormal = PlanetEarth.GetNormal(radLng, radLat);
cityNormal.Normalize();
Vector3 hpPos = targetCity.Position + cityNormal * 100 + tangx * (lngSign * City.CityRadius * 0.55f);
Viewport vp = renderSys.Viewport;
Vector3 screenPos = vp.Project(hpPos, scene.Camera.ProjectionMatrix,
scene.Camera.ViewMatrix, Matrix.Identity);
Vector3 lp = vp.Project(hpPos + tangx, scene.Camera.ProjectionMatrix,
scene.Camera.ViewMatrix, Matrix.Identity);
Vector3 rp = vp.Project(hpPos - tangx, scene.Camera.ProjectionMatrix,
scene.Camera.ViewMatrix, Matrix.Identity);
float scale0 = MathEx.Saturate(1.5f * Vector3.Distance(lp, rp));
float scale = (animProgress * animProgress) * scale0;
Matrix trans = Matrix.Translation(0, -background.Height / 2, 0) *
Matrix.Scaling(scale, scale, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0);
sprite.SetTransform(trans);
if (selectedIndex == -1)
{
sprite.Draw(background, 0, 0, ColorValue.White);
}
else
{
sprite.Draw(backgroundSelected[selectedIndex], 0, 0, ColorValue.White);
}
UpdateHotarea(ref trans);
if (state == State.Opened)
{
Matrix trans2 = Matrix.Translation(-background.Width / 2, -background.Height / 2, 0) *
Matrix.Scaling(scale0, scale0, 1) * Matrix.Translation(screenPos.X, screenPos.Y, 0);
sprite.SetTransform(trans2);
RenderBallIcon(sprite);
}
sprite.SetTransform(Matrix.Identity);
}
}
示例14: FastRender
/// <summary>
/// Draw the icon
/// </summary>
public void FastRender(DrawArgs drawArgs, Sprite sprite, Vector3 projectedPoint)
{
// Check icons for within "visual" range
float distanceToIcon = Vector3.Length(this.Position - drawArgs.WorldCamera.Position);
if(distanceToIcon > this.MaximumDisplayDistance)
return;
if(distanceToIcon < this.MinimumDisplayDistance)
return;
if (!this.isInitialized)
this.Initialize(drawArgs);
if ((!this.m_isUpdated) || (drawArgs.WorldCamera.Altitude < 300000))
{
this.UpdatePosition(drawArgs);
}
JHU_IconTexture iconTexture = this.GetTexture();
if(iconTexture==null)
{
// Render label
if(this.Name != null)
{
// Center over target as we have no bitmap
Rectangle rect = new Rectangle(
(int)projectedPoint.X - (labelWidth>>1),
(int)(projectedPoint.Y - (drawArgs.defaultDrawingFont.Description.Height >> 1)),
labelWidth,
drawArgs.screenHeight );
drawArgs.defaultDrawingFont.DrawText(sprite, this.Name, rect, DrawTextFormat.Center, normalColor);
}
}
else
{
// Render icon
sprite.Transform = Matrix.Scaling(this.XScale,this.YScale,0);
if (m_isRotated)
sprite.Transform *= Matrix.RotationZ((float)m_rotation.Radians - (float) drawArgs.WorldCamera.Heading.Radians);
sprite.Transform *= Matrix.Translation(projectedPoint.X, projectedPoint.Y, 0);
sprite.Draw( iconTexture.Texture,
new Vector3(iconTexture.Width>>1, iconTexture.Height>>1,0),
Vector3.Empty,
normalColor );
if (m_iconTexture2Show)
{
sprite.Draw ( m_iconTexture2.Texture,
new Vector3(m_iconTexture2.Width>>1, m_iconTexture2.Height>>1, 0),
Vector3.Empty,
normalColor );
}
if (m_iconTexture3Show)
{
sprite.Draw ( m_iconTexture3.Texture,
new Vector3(m_iconTexture3.Width>>1, m_iconTexture3.Height>>1, 0),
Vector3.Empty,
normalColor );
}
// Reset transform to prepare for text rendering later
sprite.Transform = Matrix.Identity;
}
if (m_drawGroundStick)
{
Vector2[] groundStick = new Vector2[2];
Angle testAngle = new Angle();
testAngle.Degrees = 45.0;
Vector3 projectedGroundPoint = drawArgs.WorldCamera.Project(m_groundPoint);
m_groundStick.Begin();
groundStick[0].X = projectedPoint.X;
groundStick[0].Y = projectedPoint.Y;
groundStick[1].X = projectedGroundPoint.X;
groundStick[1].Y = projectedGroundPoint.Y;
m_groundStick.Draw(groundStick, m_groundStickColor);
m_groundStick.End();
}
}
示例15: Draw
/// <summary>
/// 绘制动画当前帧
/// </summary>
/// <returns>是否正常绘制</returns>
public bool Draw(Sprite sprite , Vector3 pos)
{
AnimationFrame aniFrame = currentFrame;
sprite.Draw(texture, aniFrame.ClipRect, aniFrame.FrameOffset, pos, Color.White.ToArgb());
return true;
}