本文整理汇总了C#中SpriteBatch.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.Draw方法的具体用法?C# SpriteBatch.Draw怎么用?C# SpriteBatch.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawAndUpdate
public void DrawAndUpdate(SpriteBatch spriteBatch, TimeSpan elapsedTime, Texture2D spriteSheet, float timescale, Texture2D grid)
{
if (timescale != 0)
{
currentFrameTimer -= TimeSpan.FromMilliseconds(elapsedTime.TotalMilliseconds * timescale);
if (currentFrameTimer <= TimeSpan.Zero)
{
AdvanceFrameAndReset();
}
}
//threading issue
if (currentFrameIndex >= frames.Count)
{
currentFrameIndex = 0;
}
if (frames.Count != 0)
{
spriteBatch.Draw(spriteSheet, frames[currentFrameIndex].DrawRectangle, frames[currentFrameIndex].SourceRectangle, Color.White);
spriteBatch.Draw(grid, frames[currentFrameIndex].DrawRectangle, Color.Red);
spriteBatch.Draw(grid, frames[currentFrameIndex].SourceRectangle, Color.Blue);
}
}
示例2: Draw
public void Draw(SpriteBatch sb, int xx, ref int yy, int ww) {
if (!Visible()) return;
if (Main.mouseLeft && Main.mouseLeftRelease && ModWorld.GuiAchievements.MouseIn(sb.GraphicsDevice.ScissorRectangle,new Rectangle(xx,yy,ww,42))) {
toggled = !toggled;
if (toggled) GuiAchievements.setScroll = yy+GuiAchievements.scroll-120;
}
Color white = new Color(255,255,255,191);
Color limish = new Color(136,255,0,191);
bool achieved = Achieved();
sb.Draw(ModWorld.Notifier.frame1,new Rectangle(xx+1,yy,ww-2,42),achieved ? limish : white);
sb.Draw(ModWorld.Notifier.frame2,new Rectangle(xx,yy,1,42),achieved ? limish : white);
sb.Draw(ModWorld.Notifier.frame2,new Rectangle(xx+ww-1,yy,1,42),achieved ? limish : white);
ModWorld.DrawStringShadowed(sb,Main.fontMouseText,title,new Vector2(xx+8,yy+10),Color.White,Color.Black);
string value = ""+Value(true)+"/"+Value(false);
ModWorld.DrawStringShadowed(sb,Main.fontMouseText,value,new Vector2(xx+ww-12-Main.fontMouseText.MeasureString(value).X,yy+10),Color.White,Color.Black);
yy += 42;
if (toggled) {
for (int i = 0; i < categories.Count; i++) categories[i].Draw(sb,xx+24,ref yy,ww-48);
for (int i = 0; i < achievements.Count; i++) achievements[i].Draw(sb,xx+24,ref yy,ww-48);
}
}
示例3: Draw
public void Draw(SpriteBatch SP)
{
Texture2D TEX = Main.goreTexture[Config.goreID["Observing eye"]];
Vector2 NC = N.position+new Vector2(N.width,N.height)/2f - Main.screenPosition;
Vector2 TC = new Vector2(TEX.Width,TEX.Height)/2f;
SP.Draw(TEX,NC-TC*s1+Pos,new Rectangle(0,0,TEX.Width,TEX.Height),c1,0f,default(Vector2),s1,SpriteEffects.None,0f);
SP.Draw(TEX,NC-TC*s2+Pos-Pos2,new Rectangle(0,0,TEX.Width,TEX.Height),c2,0f,default(Vector2),s2,SpriteEffects.None,0f);
}
示例4: OnDrawOne
protected virtual void OnDrawOne(SpriteBatch sb, Vector2 pos, float size, float alpha) {
Color c = Color.GreenYellow;
float sizeAmp = !IsActive() ? 1.5f : 1f;
sb.Draw(ptFuzzy,pos-Main.screenPosition,GetRectFuzzy(),new Color(c.R,c.G,c.B,(byte)(c.A/2f)),0f,GetCenterFuzzy(),GetScaleFuzzy(size*sizeAmp),SpriteEffects.None,0f);
sb.Draw(ptFuzzy,pos-Main.screenPosition,GetRectFuzzy(),c,0f,GetCenterFuzzy(),GetScaleFuzzy(size*sizeAmp/2f),SpriteEffects.None,0f);
float lightAmp = !IsActive() ? 2f : 1f;
if (addLight) Lighting.addLight((int)Math.Round(pos.X/16f),(int)Math.Round(pos.Y/16f),c.R/255f*size/32f*c.A/255f*lightAmp,c.G/255f*size/32f*c.A/255f*lightAmp,c.B/255f*size/32f*c.A/255f*lightAmp);
}
示例5: OnDrawContent
protected override void OnDrawContent(SpriteBatch batch, Rectangle contentArea, GameTime gameTime, float alpha)
{
if (Scene == null || Scene.MiniMapTexture == null)
return;
batch.Draw(Skin.Pix, new Rectangle(contentArea.X - 2, contentArea.Y - 2, contentArea.Width + 4, contentArea.Height + 4), Color.Black);
batch.Draw(Scene.MiniMapTexture, new Rectangle(contentArea.X, contentArea.Y, contentArea.Width, contentArea.Height), Color.White);
Index2 center = new Index2((contentArea.Width / 2) + contentArea.X, (contentArea.Height / 2) + contentArea.Y);
batch.Draw(Skin.Pix, new Rectangle(center.X - 1, center.Y - 1, 2, 2), Color.White);
}
示例6: OnDrawContent
protected override void OnDrawContent(SpriteBatch batch, Rectangle contentArea, GameTime gameTime, float alpha)
{
if (!assets.Ready)
return;
batch.Draw(Texture, contentArea, Color * Transparency);
}
示例7: Draw
public void Draw(SpriteBatch spriteBatch, Color color)
{
Vector2 tangent = B - A;
float rotation = (float)Math.Atan2(tangent.Y, tangent.X);
const float ImageThickness = 8;
float thicknessScale = Thickness / ImageThickness;
Vector2 capOrigin = new Vector2(Art.HalfCircle.Width, Art.HalfCircle.Height / 2f);
Vector2 middleOrigin = new Vector2(0, Art.LightningSegment.Height / 2f);
Vector2 middleScale = new Vector2(tangent.Length(), thicknessScale);
spriteBatch.Draw(Art.LightningSegment, A, null, color, rotation, middleOrigin, middleScale, SpriteEffects.None, 0f);
spriteBatch.Draw(Art.HalfCircle, A, null, color, rotation, capOrigin, thicknessScale, SpriteEffects.None, 0f);
spriteBatch.Draw(Art.HalfCircle, B, null, color, rotation + MathHelper.Pi, capOrigin, thicknessScale, SpriteEffects.None, 0f);
}
示例8: DrawOnScreen
public void DrawOnScreen(SpriteBatch sb, double layer) {
Player player = Main.player[Main.myPlayer];
if (resetChat) Main.chatMode = false;
resetChat = false;
if (!Settings.GetBool("toggle") && Main.playerInventory && !Main.craftingHide && (!Codable.RunGlobalMethod("ModWorld","PreDrawAvailableRecipes",sb) || (bool)Codable.customMethodReturn)) {
if (Main.reforge || player.chest != -1 || Main.npcShop != 0 || player.talkNPC != -1 || Main.craftGuide || Main.ForceGuideMenu) return;
if (Config.tileInterface == null && Config.npcInterface == null) {
if (shouldInit) {
GuiCraft.Init();
shouldInit = false;
}
GuiCraft.Create();
}
}
if (Config.tileInterface != null && Config.tileInterface.code is GuiCraft) {
Config.tileInterface.SetLocation(new Vector2(player.position.X/16f,player.position.Y/16f));
((GuiCraft)Config.tileInterface.code).PreDrawInterface(sb);
}
if (Main.playerInventory && Settings.GetBool("toggle") && (Config.tileInterface == null || Config.tileInterface.code is GuiCraft)) {
Color c = Config.tileInterface != null && Config.tileInterface.code is ModWorld.GuiCraft ? Color.White : Color.Gray;
sb.Draw(ModWorld.texShow,new Vector2(414,210),GetTexRectangle(texShow),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
}
}
示例9: Draw
public void Draw(int idx, SpriteBatch batch, float x, float y,
float rotation, float sx, float sy, LColor color) {
RectBox rect = this._rectList[idx];
batch.SetColor(color);
batch.Draw(_texture, x, y, anchor.x, anchor.y, rect.width, rect.height,
sx, sy, MathUtils.ToDegrees(rotation), rect.x, rect.y,
rect.width, rect.height, false, false);
batch.ResetColor();
}
示例10: OnDrawingForeground
protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch)
{
spriteBatch.Draw(blankTexture, new RectangleF(64, 64, Width - 128, Height - 128), Color.Black * 0.75f * TransitionPosition);
var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle);
textRenderer.Draw(spriteBatch, "Welcome to the game!", Vector2.Zero, Color.White * TransitionPosition, settings);
base.OnDrawingForeground(time, spriteBatch);
}
示例11: DrawOnScreen
public void DrawOnScreen(SpriteBatch sb, double layer) {
Player player = Main.player[Main.myPlayer];
if (resetChat) Main.chatMode = false;
resetChat = false;
if (Config.tileInterface != null && Config.tileInterface.code is GuiCheat) {
Config.tileInterface.SetLocation(new Vector2(player.position.X/16f,player.position.Y/16f));
((GuiCheat)Config.tileInterface.code).PreDrawInterface(sb);
}
if (Main.playerInventory && GetClientAdminLevel() == 2) {
Color c;
Vector2 v;
int xx = 0;
c = Config.tileInterface != null && Config.tileInterface.code is GuiItem ? Color.White : Color.Gray;
v = new Vector2(8+xx,Main.screenHeight-8-texItem.Height);
sb.Draw(texItem,v,GetTexRectangle(texItem),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
xx += texItem.Width+2;
c = Config.tileInterface != null && Config.tileInterface.code is GuiPrefix ? Color.White : Color.Gray;
v = new Vector2(8+xx,Main.screenHeight-8-texPrefix.Height);
sb.Draw(texPrefix,v,GetTexRectangle(texPrefix),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
xx += texPrefix.Width+2;
c = Config.tileInterface != null && Config.tileInterface.code is GuiNPC ? Color.White : Color.Gray;
v = new Vector2(8+xx,Main.screenHeight-8-texNPC.Height);
sb.Draw(texNPC,v,GetTexRectangle(texNPC),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
xx += texNPC.Width+2;
c = Config.tileInterface != null && Config.tileInterface.code is GuiBuff ? Color.White : Color.Gray;
v = new Vector2(8+xx,Main.screenHeight-8-texBuff.Height);
sb.Draw(texBuff,v,GetTexRectangle(texBuff),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
xx += texBuff.Width+2;
c = Config.tileInterface != null && Config.tileInterface.code is GuiMisc ? Color.White : Color.Gray;
v = new Vector2(8+xx,Main.screenHeight-8-texMisc.Height);
sb.Draw(texMisc,v,GetTexRectangle(texMisc),c,0f,default(Vector2),1f,SpriteEffects.None,0f);
xx += texMisc.Width+2;
}
}
示例12: Draw
public override void Draw(SpriteBatch batch) {
if (base._visible && (base._texture != null)) {
pos = base.ConvertToWorldPos();
rotation = base.ConvertToWorldRot();
scale = base.ConvertToWorldScale();
batch.SetColor(base._color.r, base._color.g, base._color.b,
base._alpha);
if (this._type == BarType.PROGRESS_BAR_LEFT) {
batch.Draw(_texture, pos[0], pos[1], _anchor.x, _anchor.y,
base._size_width, base._size_height, scale[0],
scale[1], MathUtils.ToDegrees(rotation), base._left,
base._top, base._orig_width * this._percent,
base._orig_height, _flipX, _flipY);
} else if (this._type == BarType.PROGRESS_BAR_RIGHT) {
int offsetX = ((int) (base._orig_width * (1f - this._percent)));
batch.Draw(_texture, pos[0] + offsetX, pos[1], _anchor.x,
_anchor.y, base._size_width, base._size_height,
scale[0], scale[1], MathUtils.ToDegrees(rotation),
((int) base._left) + offsetX, (int) base._top,
(int) (base._orig_width * this._percent),
(int) base._orig_height, _flipX, _flipY);
} else if (this._type == BarType.PROGRESS_BAR_TOP) {
batch.Draw(_texture, pos[0], pos[1], _anchor.x, _anchor.y,
base._size_width, base._size_height, scale[0],
scale[1], MathUtils.ToDegrees(rotation), base._left,
base._top, base._orig_width,
(base._orig_height * this._percent), _flipX, _flipY);
} else if (this._type == BarType.PROGRESS_BAR_BOTTOM) {
int offsetY = ((int) (base._orig_height * (1f - this._percent)));
batch.Draw(_texture, pos[0], pos[1] + offsetY, _anchor.x,
_anchor.y, base._size_width, base._size_height,
scale[0], scale[1], MathUtils.ToDegrees(rotation),
(int) base._left, ((int) base._top)
+ ((int) (base._orig_height * this._percent)),
(int) base._orig_width,
(int) (base._orig_height * this._percent), _flipX,
_flipY);
}
batch.ResetColor();
}
}
示例13: Draw
public override void Draw(SpriteBatch sb, Projectile p, ModWorld.Firework f) {
trail.Insert(0,new Vector2(pos.X,pos.Y));
for (int i = 0; i < Math.Min(trail.Count,5); i++) {
Vector2 v = trail[i];
float alpha = (5-i)/5f;
sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha*.5f)),0f,GetCenterFuzzy(),GetScaleFuzzy(12f),SpriteEffects.None,0f);
sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha)),0f,GetCenterFuzzy(),GetScaleFuzzy(4f),SpriteEffects.None,0f);
}
if (trail.Count > 5) trail.RemoveAt(5);
pos += vel;
vel.Y += .05f;
if (timeLeft > 0) {
timeLeft--;
} else {
color.A = (byte)Math.Max(color.A-26,0);
if (color.A == 0) dead = true;
}
}
示例14: Draw
public void Draw(SpriteBatch sb, int index) {
if (dead) return;
int w = (int)(Math.Max(Main.fontMouseText.MeasureString(ac.title).X,Main.fontMouseText.MeasureString(ac.description).X*.75f)+(ac.tex == null ? 0 : 52)+8);
int xx = (int)((Main.screenWidth-w)/2f), yy = Main.screenHeight-y;
sb.Draw(frame1,new Rectangle(xx,yy,w,56),Color.White);
sb.Draw(frame2,new Rectangle(xx,yy,1,56),Color.White);
sb.Draw(frame2,new Rectangle(xx+w,yy,1,56),Color.White);
xx += 4;
if (ac.tex != null) {
float scale = 1f;
if (ac.tex.Width > 48) scale = 48f/ac.tex.Width;
if (ac.tex.Height*scale > 48f) scale = 48f/ac.tex.Height;
sb.Draw(ac.tex,new Rectangle((int)(xx+(48-ac.tex.Width*scale)/2f),(int)(yy+4+(48-ac.tex.Height*scale)/2f),(int)(ac.tex.Width*scale),(int)(ac.tex.Height*scale)),Color.White);
xx += 52;
}
ModWorld.DrawStringShadowed(sb,Main.fontMouseText,ac.title,new Vector2(xx,yy+8),Color.White,Color.Black);
ModWorld.DrawStringShadowed(sb,Main.fontMouseText,ac.description,new Vector2(xx,yy+28),Color.White,Color.Black,default(Vector2),.75f);
}
示例15: Draw
public override void Draw(SpriteBatch sb, Projectile p, Firework f) {
trail.Insert(0,new Vector2(pos.X,pos.Y));
for (int i = 0; i < Math.Min(trail.Count,10); i++) {
Vector2 v = trail[i];
float alpha = (10-i)/10f;
sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha*.5f)),0f,GetCenterFuzzy(),GetScaleFuzzy(36f),SpriteEffects.None,0f);
sb.Draw(ptFuzzy,v-Main.screenPosition,GetRectFuzzy(),new Color(color.R,color.G,color.B,(byte)(color.A*alpha)),0f,GetCenterFuzzy(),GetScaleFuzzy(12f),SpriteEffects.None,0f);
}
if (trail.Count > 10) trail.RemoveAt(10);
Lighting.addLight((int)Math.Round(pos.X/16f),(int)Math.Round(pos.Y/16f),color.R/255f*(color.A/255f),color.G/255f*(color.A/255f),color.B/255f*(color.A/255f));
pos += vel;
vel.Y += .075f;
if (timeLeft > 0) {
timeLeft--;
} else {
color.A = (byte)Math.Max(color.A-10,0);
if (color.A == 0) dead = true;
}
}