当前位置: 首页>>代码示例>>C#>>正文


C# SpriteBatch.DrawString方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawString方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawString方法的具体用法?C# SpriteBatch.DrawString怎么用?C# SpriteBatch.DrawString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.DrawString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateAndDraw

        internal void UpdateAndDraw(double a_elapsedTimeTotalSeconds, SpriteBatch m_spriteBatch, Camera m_camera, float displaceMentY)
        {
            for (int i = 0; i < MAX_PARTICLES; i++)//Går igenom alla partiklar
            {
                   //Update particle speed and position
                    m_particles[i].Update(a_elapsedTimeTotalSeconds);

                    //Get view coordinates of particle

                    Vector2 particleModelPositions = m_particles[i].getPosition();

                    Vector2 viewCoordinates = m_camera.translateCoordinates(m_particles[i].getPosition(), 960, 640, displaceMentY);

                    //Create destination rectangle
                    Rectangle dest = new Rectangle((int)viewCoordinates.X, (int)viewCoordinates.Y, 10, 10);

                    Rectangle dest2 = new Rectangle(320,450, 32, 32);

                    //Print particle
                    m_spriteBatch.Draw(m_particle, dest, Color.White);
                    m_spriteBatch.DrawString(font, "Particle 1 Y: " + viewCoordinates.Y.ToString(), new Vector2(240, 500), Color.White);
                    m_spriteBatch.DrawString(font, "Particle 1 X: " + viewCoordinates.X.ToString(), new Vector2(240, 540), Color.White);

            }
        }
开发者ID:BaltaX,项目名称:MegaJump,代码行数:25,代码来源:ParticleSystem.cs

示例2: Draw

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            //spriteBatch.Draw(background, Vector2.Zero, Color.White);
            spriteBatch.Draw(background,
            new Vector2(0, -5),
            null,
            Color.White,
            0.0f,
            Vector2.Zero,
            1.0f,
            SpriteEffects.None,
            0.0f);
            /*
            spriteBatch.Draw(player,
            playerPosition,
            null,
            Color.White,
            0.0f,
            Vector2.Zero,
            1.0f,
            SpriteEffects.None,
            0.0f);*/
            hero.Draw(gameTime, spriteBatch);
            spriteBatch.DrawString(damageStringFont, damageNumber+" ", fPos, Color.White);
            spriteBatch.DrawString(damageStringFont, "  /"+health, fPos, Color.White);

            playButton.Draw(gameTime, spriteBatch);
        }
开发者ID:WINPROG20152016,项目名称:Maramag_TapTitanXNA,代码行数:28,代码来源:Level.cs

示例3: Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(TitleScreenTexture, Vector2.Zero, null, backgroundCurrentColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
            spriteBatch.Draw(TitleTextJapanese, Vector2.Zero, null, text1CurrentColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, .9f);
            spriteBatch.Draw(TitleTextEnglish, Vector2.Zero, null, text2CurrentColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, .8f);

            if(!HelpShown && !CreditsShown)
                spriteBatch.DrawString(titlescreenFont, "Press ENTER to begin", new Vector2((925f / 2f) - (titlescreenFont.MeasureString("Press ENTER to begin").X / 2f), 500), startTextColor);

            if (fadephase == 2 && !HelpShown && !CreditsShown)
            {
                spriteBatch.DrawString(titlescreenFont, "Press C for credits", new Vector2((925f) - (titlescreenFont.MeasureString("Press C for credits").X + 30), 605), Color.Gray);
                spriteBatch.DrawString(titlescreenFont, "Press H for help", new Vector2((925f) - (titlescreenFont.MeasureString("Press H for help").X + 30), 620), Color.Gray);
            }

            if (HelpShown)
            {
                spriteBatch.Draw(HelpTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            }
            else if (CreditsShown)
            {
                spriteBatch.Draw(CreditsTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            }

            spriteBatch.DrawString(titlescreenFont, cheatText, new Vector2((925f / 2f) - (titlescreenFont.MeasureString(cheatText).X / 2f), 600), cheatTextCurrentColor);
        }
开发者ID:cmark89,项目名称:AsteroidRebuttal,代码行数:26,代码来源:TitleScene.cs

示例4: Draw

 public void Draw(SpriteBatch spriteBatch)
 {
     bool hover = false;
     float x = (float)Mouse.GetState().X;
     MouseState state = Mouse.GetState();
     Vector2 MousePos = new Vector2(x, (float)state.Y);
     if (HelperFunctions.CheckIntersection(this.r, MousePos))
     {
         hover = true;
     }
     if (hover)
     {
         Primitives2D.FillRectangle(spriteBatch, this.r, new Color(128, 87, 43, 50));
     }
     foreach (DropDownMenu.RecTexPair r in this.container)
     {
         spriteBatch.Draw(ResourceManager.TextureDict[r.tex], r.r, Color.White);
     }
     if (hover)
     {
         spriteBatch.DrawString(Fonts.Arial12Bold, this.Options[this.ActiveIndex], new Vector2((float)(this.r.X + 8), (float)(this.r.Y + this.r.Height / 2 - Fonts.Arial12Bold.LineSpacing / 2)), Color.White);
         return;
     }
     spriteBatch.DrawString(Fonts.Arial12Bold, this.Options[this.ActiveIndex], new Vector2((float)(this.r.X + 8), (float)(this.r.Y + this.r.Height / 2 - Fonts.Arial12Bold.LineSpacing / 2)), new Color(255, 239, 208));
 }
开发者ID:castroev,项目名称:StardriveBlackBox-verRadicalElements-,代码行数:25,代码来源:DropDownMenu.cs

示例5: Draw

 public override void Draw(SpriteBatch spriteBatch)
 {
     if (HasFocus)
         spriteBatch.DrawString(SpriteFont, Text, Position, SelectedColor);
     else
         spriteBatch.DrawString(SpriteFont, Text, Position, Color);
 }
开发者ID:GabrielWilds,项目名称:XnaRpg,代码行数:7,代码来源:LinkLabel.cs

示例6: Draw

        public void Draw(SpriteBatch sb)
        {
            Rectangle vp = sb.GraphicsDevice.Viewport.Bounds;

            sb.Draw(hudTex, new Vector2(vp.Width - 240, 18), new Rectangle(319,0,230,236), Color.White);

            sb.Draw(hudTex, new Vector2(vp.Width - 238, 120 - (int)huntedLevel), new Rectangle(550, 2 + (100 - (int)huntedLevel), 16, (int)huntedLevel*2), Color.White, 0f, new Vector2(0,0), 1f, SpriteEffects.None, 1);

            sb.DrawString(hudFont, "Day " + day, new Vector2(vp.Width - 216, 221), Color.White);
            sb.DrawString(hudFont, timeOfDay.Hour.ToString("00") + ":" + timeOfDay.Minute.ToString("00"), new Vector2(vp.Width - 24 - hudFont.MeasureString(timeOfDay.Hour.ToString("00") + ":" + timeOfDay.Minute.ToString("00")).X, 221), Color.White);

            sb.Draw(hudTex, new Vector2(30, 28), new Rectangle(vehicle?50:0, 150, 50, 50), Color.White, 0f, new Vector2(25, 25), 1f, SpriteEffects.None, 1);
            sb.Draw(hudTex, new Vector2(30, 28 +26), new Rectangle(weapon * 50, 100, 50, 50), Color.White, 0f, new Vector2(25, 25), 1f, SpriteEffects.None, 1);

            sb.Draw(hudTex, new Vector2(68, 18), new Rectangle(0, 0, 310, 25), Color.White);
            sb.Draw(hudTex, new Vector2(70, 20), new Rectangle(2, 54, (int)((float)(300f/100f) * heroHealth), 16), vehicle?Color.Green:Color.Red);

            //if (showAmmo)
            //{
                sb.Draw(hudTex, new Vector2(68, 18 + 26), new Rectangle(0, 26, 310, 25), Color.White * (showAmmo?1f:0.3f));
                sb.Draw(hudTex, new Vector2(70, 20 + 26), new Rectangle(0, 71, ammo * 3, 16), Color.White * (showAmmo ? 1f : 0.3f));
            //}

            Ticker.Draw(sb, hudFont, new Vector2(20, 70));
        }
开发者ID:GarethIW,项目名称:Hunted,代码行数:25,代码来源:Hud.cs

示例7: Draw

 public void Draw(SpriteBatch theSpriteBatch)
 {
     theSpriteBatch.Draw(background, this.Position + new Vector2((period) * background.Width, 0), new Rectangle(0, 0, background.Width, background.Height), this.Color, this.Rotation, Vector2.Zero, 1.0f, SpriteEffects.None, 0);
     theSpriteBatch.Draw(background, this.Position + new Vector2((period + 1) * background.Width, 0), new Rectangle(0, 0, background.Width, background.Height), this.Color, this.Rotation, Vector2.Zero, 1.0f, SpriteEffects.None, 0);
     theSpriteBatch.DrawString(font, string.Format("Level: {0}", this.period), new Vector2(702, 4), Color.Black);
     theSpriteBatch.DrawString(font, string.Format("Level: {0}", this.period), new Vector2(700, 4), Color.LightGray);
 }
开发者ID:kulhajs,项目名称:wp_planes,代码行数:7,代码来源:Background.cs

示例8: Draw

        public override void Draw(SpriteBatch sb)
        {
            if(wakeTime < wakeThresh)
            {
                float totDim = font.MeasureString(moneyTot).X;
                float diffDim = font.MeasureString(moneyDif).X;

                game.GraphicsDevice.BlendState = BlendState.AlphaBlend;
                sb.Draw(hudMonB, hud.scaledRect(monPos, 425, 151), Color.White);
                sb.Draw(hudMonF, hud.scaledRect(monPos, 425, 151), Color.White);

                sb.DrawString(font, moneyTot, hud.scaledCoords(monTotPos), Color.White, 0,
                    new Vector2(font.MeasureString(moneyTot).X, font.MeasureString(moneyTot).Y / 2), hud.scale * (28.0f / 40), SpriteEffects.None, 0);

                if (game.ship.moneyManager.changing)
                {
                    sb.DrawString(font, moneyDif, hud.scaledCoords(monDifPos.X + 3, monDifPos.Y + 3), hud.outline, 0,
                            new Vector2(font.MeasureString(moneyDif).X, font.MeasureString(moneyDif).Y / 2), hud.scale * (28.0f / 40), SpriteEffects.None, 0);

                    if (game.ship.moneyManager.difference < 0)
                        sb.DrawString(font, moneyDif, hud.scaledCoords(monDifPos), hud.redBody, 0,
                            new Vector2(font.MeasureString(moneyDif).X, font.MeasureString(moneyDif).Y / 2), hud.scale * (28.0f / 40), SpriteEffects.None, 0);
                    else
                        sb.DrawString(font, moneyDif, hud.scaledCoords(monDifPos.X, monDifPos.Y), hud.contSecondary, 0,
                            new Vector2(font.MeasureString(moneyDif).X, font.MeasureString(moneyDif).Y / 2), hud.scale * (28.0f / 40), SpriteEffects.None, 0);
                }

                sb.Draw(TextureManager.icoMon, hud.scaledRect(monPos + new Vector2(335,70), 90, 90),
                        null, Color.White, 0, new Vector2(45, 45), SpriteEffects.None, 0);
            }
        }
开发者ID:Thinny-Hendrix,项目名称:MoonCow,代码行数:31,代码来源:HudMoney.cs

示例9: Draw

        public void Draw(SpriteBatch spriteBatch)
        {
            var position = new Vector2(XnaDartsGame.Viewport.Width*0.5f, XnaDartsGame.Viewport.Height*0.125f);
            var font = ScreenManager.Trebuchet24;

            float ppd;
            var thrown = _mode.CurrentPlayer.Rounds.Sum(r => r.Darts.Count);
            float totalScore = _mode.CurrentPlayer.Rounds.Sum(r => _mode.GetScore(r));

            if (thrown > 0)
            {
                ppd = totalScore/thrown;
            }
            else
            {
                ppd = 0;
            }

            var text = "Points Per Dart: " + ppd.ToString("0.00");
            var offset = font.MeasureString(text)*0.5f;
            spriteBatch.DrawString(font, text, position - offset + Vector2.One, Color.Black);
            spriteBatch.DrawString(font, text, position - offset, Color.White);

            //Draw points per round
            var ppr = totalScore/(_mode.CurrentRoundIndex + 1);

            position.Y += offset.Y*2.0f + 10.0f;
            text = "Points Per Round: " + ppr.ToString("0.00");
            offset = font.MeasureString(text)*0.5f;
            spriteBatch.DrawString(font, text, position - offset + Vector2.One, Color.Black);
            spriteBatch.DrawString(font, text, position - offset, Color.White);
        }
开发者ID:nymo1,项目名称:XDarts,代码行数:32,代码来源:PointsPerDartComponent.cs

示例10: Draw

 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.DrawString(font, "Score: " + Score, scorePosition, Color.Black);
     spriteBatch.DrawString(font, "HP: ", healthPosition, Color.Black);
     spriteBatch.Draw(healthOutline, healthOutlinePosition, Color.White);
     spriteBatch.Draw(healthBar, healthBarSize, Color.White);
 }
开发者ID:csce3513,项目名称:Team12,代码行数:7,代码来源:GameInfo.cs

示例11: Draw

        public override void Draw(SpriteBatch batch)
        {
            batch.Draw(image, new Rectangle(287, 110, 460, y_spacing * (3) + 10), Color.Gray);
            batch.Draw(image, new Rectangle(292, 115, 450, y_spacing * (3)), Color.Black);
            batch.DrawString(font, title, new Vector2(292, 115), teamColor);

            batch.Draw(image, new Rectangle(x_position - 5, y_position - 5, 410, y_spacing * (menuitems.Count) + 10), Color.Gray);
            batch.Draw(image, new Rectangle(x_position, y_position, 400, y_spacing * (menuitems.Count)), Color.Black);
            batch.DrawString(font, "Rules List:", new Vector2(x_position, y_position), Color.Gold);

            batch.DrawString(font, "(X)", new Vector2(372, 140), Color.Blue);

            foreach (MenuItem x in menuitems)
            {
                int i = menuitems.IndexOf(x);
                if (i == 0) x.Draw(batch, font, 412, 140);
                else if (x==current) x.Draw(batch, font, x_position + (i + 1) * x_spacing + 15, y_position + y_spacing * (i));
                else x.Draw(batch, font, x_position + (i + 1) * x_spacing, y_position + y_spacing * (i));
            }

            batch.Draw(image, new Rectangle(x_position - 5 + 500, y_position - 5, 410, y_spacing * (judgementItems.Count) + 10), Color.Gray);
            batch.Draw(image, new Rectangle(x_position + 500, y_position, 400, y_spacing * (judgementItems.Count)), Color.Black);
            batch.DrawString(font, "Judgement List:", new Vector2(x_position + 500, y_position), Color.Gold);

            foreach (MenuItem x in judgementItems)
            {
                int i = judgementItems.IndexOf(x);
                if (i == 0) x.Draw(batch, font, 412, 140);
                else if (x == current) x.Draw(batch, font, x_position + 500 + (i + 1) * x_spacing + 15, y_position + y_spacing * (i));
                else x.Draw(batch, font, x_position + 500 + (i + 1) * x_spacing, y_position + y_spacing * (i));
            }
        }
开发者ID:ncallaway,项目名称:Pixl-Sport,代码行数:32,代码来源:RuleMenu.cs

示例12: Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            map.Draw(spriteBatch, "Underlay");
            player.Draw(spriteBatch);
            map.Draw(spriteBatch, "Overlay");//overlay AFTER the player (on top)
            spriteBatch.DrawString(font, "" + popup, new Vector2(0, 0), Color.Black);
            spriteBatch.DrawString(font, "\n" + (int)player.Image.Position.X, new Vector2(0, 0), Color.Black);
            spriteBatch.DrawString(font, "\n\n" + (int)player.Image.Position.Y, new Vector2(0, 0), Color.Black);

            if (popup == new Vector2(128, 192))
                if (Enumerable.Range((int)player.Image.Position.X - 10, (int)player.Image.Position.X + 5).Contains((int)popup.X) && Enumerable.Range((int)player.Image.Position.Y - 10, (int)player.Image.Position.Y + 10).Contains((int)popup.Y))
                {
                    spriteBatch.Draw(texturebg, new Rectangle(0, 400, 640, 80), Color.White);
                    spriteBatch.DrawString(font, "And everything has died...", new Vector2(0, 400), Color.Black);
                    if (one == 0)
                    {
                        paper.Play();
                        one = 1;
                    }
                    popup = Vector2.Zero;
                }
                else
                    one = 0;
        }
开发者ID:rooper149,项目名称:Rpg,代码行数:25,代码来源:Level_One.cs

示例13: Draw

        public void Draw(SpriteBatch spriteBatch, Vector2 position, SpriteFont font)
        {
            Queue<TraversalInformation> queue = new Queue<TraversalInformation>();
            queue.Enqueue(new TraversalInformation(Root, 0));
            TraversalInformation current;

            int positionCorrection = 24;

            int i = -1;
            while (queue.Count > 0)
            {
                current = queue.Dequeue();
                spriteBatch.DrawString(font, current.DebugTreeNode.Context + ":", position + new Vector2(current.Level * positionCorrection, ++i * positionCorrection), Color.White);
                
                if ((current.DebugTreeNode.DebugEvent != null) && (current.DebugTreeNode.Collapsstate))
                {
                    spriteBatch.DrawString(font, current.DebugTreeNode.Value, position + new Vector2((current.Level + 1) * positionCorrection, ++i * positionCorrection), Color.White);
                }

                foreach (DebugTreeNode child in current.DebugTreeNode.Children)
                {
                    queue.Enqueue(new TraversalInformation(child, 1 + current.Level));
                }

            }
        }
开发者ID:Norskan,项目名称:Playground,代码行数:26,代码来源:DebugTree.cs

示例14: DebugDraw

        public virtual void DebugDraw(SpriteBatch spriteBatch)
        {
            // object debug info
            spriteBatch.DrawString(
                spriteFont: AssetRepository.Instance.Arial,
                text: owner.Health + "/" + owner.Health.MaxValue,
                position: PositionAboveHead(25),
                color: Color.White,
                rotation: 0f,
                origin: Vector2.Zero,
                scale: 1f,
                effects: SpriteEffects.None,
                depth: 1f
            );

            spriteBatch.DrawString(
                spriteFont: AssetRepository.Instance.Arial,
                text: owner.DisplayName,
                position: PositionAboveHead(50),
                color: Color.White,
                rotation: 0f,
                origin: Vector2.Zero,
                scale: 1f,
                effects: SpriteEffects.None,
                depth: 1f
            );
        }
开发者ID:rickbatka,项目名称:co-op-engine,代码行数:27,代码来源:CombatBase.cs

示例15: Draw

        public override void Draw(SpriteBatch s, Vector2 relativePosition)
        {
            Vector2 pos = relativePosition + Position;

            s.Draw(_texture, pos, Color.White);

            s.DrawString(_spriteFont, _name, pos + new Vector2(10,7+35), Color.White);

            if (_dropdownDown)
            {
                if (_option2 != "")
                {
                    s.Draw(_arrows, pos + new Vector2(-32 - 16, _texture.Height), Color.White);

                    s.Draw(_texture, pos + new Vector2(-32 - 16 - 1, _texture.Height + 32), Color.White);
                    s.DrawString(_spriteFont, _option1, pos + new Vector2(-32 - 16 - 1 + _texture.Width / 2 - _spriteFont.MeasureString(_option1).X / 2, _texture.Height + 32 + 20), Color.White);

                    s.Draw(_texture, pos + new Vector2(-32 - 16 + 96 + 1, _texture.Height + 32), Color.White);
                    s.DrawString(_spriteFont, _option2, pos + new Vector2(-32 - 16 + 96 + 1 + _texture.Width / 2 - _spriteFont.MeasureString(_option2).X / 2, _texture.Height + 32 + 20), Color.White);
                }
                else if (_option1 != "")
                {
                    s.Draw(_arrowDown, pos + new Vector2(-32 - 16, _texture.Height), Color.White);
                    s.Draw(_texture, pos + new Vector2(0, _texture.Height + 32), Color.White);
                    s.DrawString(_spriteFont, _option1, pos + new Vector2( _texture.Width / 2 - _spriteFont.MeasureString(_option1).X / 2, _texture.Height + 32 + 20), Color.White);
                }
            }

            base.Draw(s, relativePosition);
        }
开发者ID:steffan88,项目名称:Bevelle,代码行数:30,代码来源:SquareDropdown.cs


注:本文中的Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。