本文整理汇总了C#中ISpriteBatch类的典型用法代码示例。如果您正苦于以下问题:C# ISpriteBatch类的具体用法?C# ISpriteBatch怎么用?C# ISpriteBatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISpriteBatch类属于命名空间,在下文中一共展示了ISpriteBatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Draw
public static void Draw(ISpriteBatch sb, Vector2 source, Vector2 dest, Color color)
{
var dist = Vector2.Distance(source, dest);
var angle = GetAngle(source, dest);
// Get the length of the segments
var segLen = dist / 6;
if (segLen < 5.0f)
segLen = 5.0f;
if (segLen > 25.0f)
segLen = 25.0f;
// Primary line
var tailLen = dist - (segLen / 2);
var pDest = source + (new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * tailLen);
RenderLine.Draw(sb, source, pDest, color);
// Arrow segment 1
var ang1 = angle - MathHelper.PiOver4;
var seg1 = dest - (new Vector2((float)Math.Cos(ang1), (float)Math.Sin(ang1)) * segLen);
RenderLine.Draw(sb, dest, seg1, color);
// Arrow segment 2
var ang2 = angle + MathHelper.PiOver4;
var seg2 = dest - (new Vector2((float)Math.Cos(ang2), (float)Math.Sin(ang2)) * segLen);
RenderLine.Draw(sb, dest, seg2, color);
// Arrow segment 3
RenderLine.Draw(sb, seg1, seg2, color);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:30,代码来源:RenderArrow.cs
示例2: DoRender
/// <summary>Render this AParentSceneNode by rendering all its children.</summary>
protected override void DoRender(
Moment now,
GraphicsDevice graphicsDevice,
ISpriteBatch spriteBatch,
TextureContent content,
HolofunkView view,
Transform parentTransform,
int depth)
{
Transform combinedTransform = parentTransform.CombineWith(LocalTransform);
if (view == HolofunkView.Secondary && SecondaryViewOption == SecondaryViewOption.PositionMirrored) {
combinedTransform = new Transform(
new Vector2(
spriteBatch.Viewport.X - combinedTransform.Translation.X,
combinedTransform.Translation.Y),
combinedTransform.Scale);
}
Spam.Graphics.WriteLine(new string(' ', depth * 4) + Label + ": parentTransform " + parentTransform + ", localTransform " + LocalTransform + ", combinedTransform " + combinedTransform);
// m_children must only be enumerated / mutated under lock (this)
lock (this) {
m_childSnapshot.AddRange(m_children);
}
for (int i = 0; i < m_childSnapshot.Count; i++) {
m_childSnapshot[i].Render(now, graphicsDevice, spriteBatch, content, view, combinedTransform, depth + 1);
}
// note that clearing preserves the capacity in the list, so no reallocation on next render
m_childSnapshot.Clear();
}
开发者ID:RobJellinghaus,项目名称:Holofunk,代码行数:34,代码来源:AParentSceneNode.cs
示例3: InfoBar
internal InfoBar(ISpriteBatch spriteBatch, ISpriteFont spriteFont)
{
_spriteBatch = spriteBatch;
_spriteFont = spriteFont;
FontColor = Color.LightBlue;
}
开发者ID:DaveEmmerson,项目名称:SpaceWar2,代码行数:7,代码来源:InfoBar.cs
示例4: Draw
/// <summary>
/// Draws the <see cref="SkeletonBodyItem"/>.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="position">Position to draw at.</param>
/// <param name="scale">Amount to scale the Grh in percent (1.0f for no scaling).</param>
/// <param name="color">The color.</param>
/// <param name="effect">SpriteEffects to use when drawing.</param>
internal void Draw(ISpriteBatch sb, Vector2 position, float scale, Color color, SpriteEffects effect)
{
// Validate
if (Source == null)
return;
// Find the effect
Vector2 m;
switch (effect)
{
case SpriteEffects.FlipHorizontally:
m = new Vector2(-1, 1);
break;
case SpriteEffects.FlipVertically:
m = new Vector2(1, -1);
break;
default:
m = new Vector2(1, 1);
break;
}
// Calculate the angle
float angle;
if (Dest == null)
angle = 0.0f;
else
angle = SkeletonNode.GetAngle(Source.Position * m, Dest.Position * m) - MathHelper.PiOver2;
// Draw
var v = Source.Position + ItemInfo.Offset;
Grh.Draw(sb, (v * m) + position, color, effect, angle, ItemInfo.Origin, scale);
}
开发者ID:mateuscezar,项目名称:netgore,代码行数:42,代码来源:SkeletonBodyItem.cs
示例5: Draw
public void Draw(ISpriteBatch spriteBatch)
{
for (int i = 0; i < _particleSystems.Count; i++)
{
_particleSystems[i].Draw(spriteBatch);
}
}
开发者ID:bobsum,项目名称:PLan2015,代码行数:7,代码来源:CompositeParticleSystem.cs
示例6: DrawControl
/// <summary>
/// Draw the Button.
/// </summary>
/// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param>
protected override void DrawControl(ISpriteBatch spriteBatch)
{
base.DrawControl(spriteBatch);
// Draw the text
DrawText(spriteBatch, _textPos);
}
开发者ID:Furt,项目名称:netgore,代码行数:11,代码来源:Button.cs
示例7: RecursiveDraw
/// <summary>
/// Recursively draws the joints and bones of a skeleton.
/// </summary>
/// <param name="camera">Camera to use.</param>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="selectedNode">SpriteBatch to draw to.</param>
/// <param name="node">Current node being drawn.</param>
/// <param name="colorIndex">Index of the color to use from the ColorList.</param>
static void RecursiveDraw(ICamera2D camera, ISpriteBatch sb, SkeletonNode selectedNode, SkeletonNode node, int colorIndex)
{
// Find the color of the joint
var color = _colorList[colorIndex];
if (node == selectedNode)
color = _nodeColorSelected;
else if (node.Parent == null)
color = _nodeColorRoot;
// Draw the joint
var scale = 1f / camera.Scale;
var origin = SkeletonNode.HalfJointVector;
_joint.Draw(sb, node.Position, color, SpriteEffects.None, 0f, origin, scale);
// Iterate through the children
foreach (var child in node.Nodes)
{
colorIndex++;
if (colorIndex == _colorList.Length)
colorIndex = 0;
// Draw the bone to the child
RenderLine.Draw(sb, node.Position, child.Position, _colorList[colorIndex], (1f / camera.Scale) * 2f);
// Draw the child
RecursiveDraw(camera, sb, selectedNode, child, colorIndex);
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:36,代码来源:SkeletonDrawer.cs
示例8: DrawName
private void DrawName(ISpriteBatch spriteBatch)
{
Vector2 measure = Font.MeasureString(Score.Name);
Vector2 origin = new Vector2(0, measure.Y * 0.5f);
spriteBatch.DrawString(Font, Score.Name, NamePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
}
开发者ID:bobsum,项目名称:PLan2015,代码行数:7,代码来源:House.cs
示例9: Begin
public void Begin(ISpriteBatch batch)
{
device.SetRenderTarget(target);
device.Clear(screenConstants.BackgroundColor);
batch.Begin();
}
开发者ID:Nexus87,项目名称:PokeClone,代码行数:7,代码来源:Screen.cs
示例10: Camera
public Camera(ISpriteBatch spriteBatch)
{
if (spriteBatch == null)
throw new ArgumentNullException("spriteBatch");
_spriteBatch = spriteBatch;
_boundingRectangle = new Rectangle(0, 0, 1024, 640);
}
开发者ID:polly5315,项目名称:MonoGameTopDownShooter,代码行数:7,代码来源:Camera.cs
示例11: DrawSpawn
public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font)
{
var spawnArea = spawn.SpawnArea;
// Only draw if it does not cover the whole map
if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue)
return;
// Draw spawn area
Vector2 cameraOffset = map.Camera.Min;
Rectangle rect = spawnArea.ToRectangle(map);
rect.X -= (int)cameraOffset.X;
rect.Y -= (int)cameraOffset.Y;
RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2);
// Draw name
CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID];
if (charTemp != null)
{
string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID);
Vector2 textPos = new Vector2(rect.X, rect.Y);
textPos -= new Vector2(0, font.MeasureString(text).Y);
textPos = textPos.Round();
spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black);
}
}
开发者ID:Furt,项目名称:netgore,代码行数:28,代码来源:EditorEntityDrawer.cs
示例12: Draw
/// <summary>
/// Draws a <see cref="Skeleton"/>.
/// </summary>
/// <param name="skeleton">The <see cref="Skeleton"/> to draw.</param>
/// <param name="camera">Camera to use.</param>
/// <param name="sb">The <see cref="ISpriteBatch"/> to draw with.</param>
/// <param name="selectedNode">The <see cref="SkeletonNode"/> to draw as selected.</param>
public static void Draw(Skeleton skeleton, ICamera2D camera, ISpriteBatch sb, SkeletonNode selectedNode = null)
{
if (skeleton == null)
{
Debug.Fail("skeleton is null.");
return;
}
if (skeleton.RootNode == null)
{
Debug.Fail("skeleton contains no root node.");
return;
}
if (sb == null)
{
Debug.Fail("sb is null.");
return;
}
if (sb.IsDisposed)
{
Debug.Fail("sb is disposed.");
return;
}
if (camera == null)
{
Debug.Fail("camera is null.");
return;
}
RecursiveDraw(camera, sb, selectedNode, skeleton.RootNode, 0);
}
开发者ID:wtfcolt,项目名称:game,代码行数:37,代码来源:SkeletonDrawer.cs
示例13: LevelView
public LevelView(ILevel level, ISpriteBatch spriteBatch, ITexture texture, ICamera camera)
{
_level = level;
_spriteBatch = spriteBatch;
_texture = texture;
_camera = camera;
}
开发者ID:zakvdm,项目名称:Frenetic,代码行数:7,代码来源:LevelView.cs
示例14: Draw
/// <summary>
/// Draws the <see cref="StyledText"/>s in this <see cref="StyledTextsDrawer"/>.
/// </summary>
/// <param name="sb">The <see cref="ISpriteBatch"/>.</param>
/// <param name="defaultColor">The default color.</param>
/// <param name="offset">The offset to start drawing the text at.</param>
public void Draw(ISpriteBatch sb, Color defaultColor, Vector2 offset)
{
foreach (var item in _textsWithPos)
{
item.StyledText.Draw(sb, Font, offset + item.Position, defaultColor);
}
}
开发者ID:Vizzini,项目名称:netgore,代码行数:13,代码来源:StyledTextsDrawer.cs
示例15: Draw
/// <summary>
/// Makes the object draw itself.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> the object can use to draw itself with.</param>
public void Draw(ISpriteBatch sb)
{
if (!IsAlive)
return;
_particleEffect.Draw(sb);
}
开发者ID:wtfcolt,项目名称:game,代码行数:11,代码来源:TemporaryMapParticleEffect.cs
示例16: SetUp
public void SetUp()
{
stubSpriteBatch = MockRepository.GenerateStub<ISpriteBatch>();
stubFont = MockRepository.GenerateStub<IFont>();
stubConsole = MockRepository.GenerateStub<IConsole<string>>();
stubConsole.Log = log;
}
开发者ID:zakvdm,项目名称:Frenetic,代码行数:7,代码来源:OverlayViewImplementationTests.cs
示例17: ConsoleOverlaySetView
public ConsoleOverlaySetView(IOverlayView inputView, IOverlayView commandConsoleView, IOverlayView messageConsoleView, IOverlayView possibleCommandsView, ISpriteBatch spriteBatch, ITexture texture, IFont font)
: base(spriteBatch, texture, font)
{
_overlays.Add(inputView);
_overlays.Add(commandConsoleView);
_overlays.Add(messageConsoleView);
_overlays.Add(possibleCommandsView);
}
开发者ID:zakvdm,项目名称:Frenetic,代码行数:8,代码来源:ConsoleOverlaySetView.cs
示例18: Render
public void Render(Moment now, GraphicsDevice graphicsDevice, ISpriteBatch spriteBatch, TextureContent content, HolofunkView view)
{
if (RootNode != null) {
RootNode.Render(now, graphicsDevice, spriteBatch, content, view, Transform.Identity, 0);
}
Spam.Graphics.WriteLine("End Render");
}
开发者ID:RobJellinghaus,项目名称:Holofunk,代码行数:8,代码来源:SceneGraph.cs
示例19: Draw
public virtual void Draw(ISpriteBatch spriteBatch)
{
string scoreString = DisplayScore.ToString();
Vector2 measure = Font.MeasureString(scoreString);
Vector2 origin = new Vector2(measure.X, measure.Y * 0.5f);
spriteBatch.DrawString(Font, scoreString, ScorePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
}
开发者ID:bobsum,项目名称:PLan2015,代码行数:9,代码来源:School.cs
示例20: Draw
/// <summary>
/// Draws a rectangle.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="dest">Destination rectangle.</param>
/// <param name="color">Color of the rectangle.</param>
public static void Draw(ISpriteBatch sb, Rectangle dest, Color color)
{
var fDest = new FloatRect(dest.Left, dest.Top, dest.Width, dest.Height);
using (var s = Shape.Rectangle(fDest, color))
{
sb.Draw(s);
}
}
开发者ID:wtfcolt,项目名称:game,代码行数:15,代码来源:RenderRectangle.cs
注:本文中的ISpriteBatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论