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


C# Point.ToString方法代码示例

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


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

示例1: Draw

        public override void Draw(SpriteBatch sb)
        {
            GraphicsDevice.Clear(Color.Gray);
            base.Draw(sb);

            Viewport vp = GraphicsDevice.Viewport;

            Point tl = new Point(vp.X, vp.Y);
            Point tr = new Point(vp.X+vp.Width, vp.Y);
            Point bl = new Point(vp.X, vp.Y+vp.Height);
            Point br = new Point(vp.X+vp.Width, vp.Y+vp.Height);

            bool coords = displayMode != 0;
            string tlString = coords ? tl.ToString() : "Top Left";
            Vector2 tlOrigin = Vector2.Zero;
            string trString = coords ? tr.ToString() : "Top Right";
            Vector2 trOrigin = new Vector2(UIFont.MeasureString(trString).X.Floor(), 0);
            string blString = coords ? bl.ToString() : "Bottom Left";
            Vector2 blOrigin = new Vector2(0, UIFont.MeasureString(blString).Y.Floor());
            string brString = coords ? br.ToString() : "Bottom Right";
            Vector2 brOrigin = UIFont.MeasureString(brString).Floor();

            sb.Begin();

            Color cornerColor = displayMode == 2 ? Color.White : Color.White * 0.5f;
            sb.Draw(corner, tl.AsVector2(), null, cornerColor, 0, Vector2.Zero, 1f, SpriteEffects.None, 0);
            sb.Draw(corner, tr.AsVector2(), null, cornerColor, 0, new Vector2(corner.Width, 0), 1f, SpriteEffects.FlipHorizontally, 0);
            sb.Draw(corner, bl.AsVector2(), null, cornerColor, 0, new Vector2(0, corner.Height), 1f, SpriteEffects.FlipVertically, 0);
            sb.Draw(corner, br.AsVector2(), null, cornerColor, 0, corner.Size(), 1f, SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically, 0);

            if(displayMode != 2)
            {
                Color textColor = Color.Yellow;
                sb.DrawString(UIFont, tlString, tl.AsVector2(), textColor, 0, tlOrigin, 1, SpriteEffects.None, 0);
                sb.DrawString(UIFont, trString, tr.AsVector2(), textColor, 0, trOrigin, 1, SpriteEffects.None, 0);
                sb.DrawString(UIFont, blString, bl.AsVector2(), textColor, 0, blOrigin, 1, SpriteEffects.None, 0);
                sb.DrawString(UIFont, brString, br.AsVector2(), textColor, 0, brOrigin, 1, SpriteEffects.None, 0);

                sb.DrawString(UIFont, GraphicsDevice.PresentationParameters.DisplayOrientation.ToString(),
                        vp.Bounds.Center.AsVector2(), Color.Yellow);
            }
            sb.End();
        }
开发者ID:cryophobia,项目名称:exen,代码行数:43,代码来源:ScreenSize.cs

示例2: Draw

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            foreach (Block b in worldElements)
            {
                b.Draw(spriteBatch);
            }

            foreach (Entity e in liveEntities)
            {
                e.Draw(spriteBatch);
            }

            foreach (IUserInterfaceElement uiElement in uiElementList)
            {
                uiElement.Draw(spriteBatch);
            }

            // Draw Mouse Position
            Point mousePos = new Point(lastMouseState.X, lastMouseState.Y);

            #if WINDOWS || XBOX
            spriteBatch.DrawString(sliderFont, "Mouse Pos:" + mousePos.ToString(), Vector2.Zero, Color.White);
            spriteBatch.DrawString(sliderFont, "Player Energy: " + Player.Energy.ToString(), new Vector2(0, 16), Color.White);
            spriteBatch.DrawString(sliderFont, "Entity Count: " + liveEntities.Count.ToString(), new Vector2(0, 32), Color.White);
            #endif // WINDOWS || XBOX

            if (IsPaused)
            {
            #if WINDOWS || XBOX
                if (Player.isAlive)
                {
                    spriteBatch.DrawString(sliderFont, "Paused", new Vector2(380, 280), Color.Blue);
                }
                else
                {
                    spriteBatch.DrawString(sliderFont, "GAME OVER", new Vector2(380, 280), Color.Red);
                }
            #endif // WINDOWS || XBOX
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
开发者ID:endy,项目名称:IvyXNA,代码行数:52,代码来源:Quicksilver.cs


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