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


C# Rectangle.ToString方法代码示例

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


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

示例1: MakeWindow

        /// <summary>
        /// Makes a game window of a specified size.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="r"></param>
        public static void MakeWindow(GraphicsDeviceManager g, Rectangle r)
        {
            if ((r.Width > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width) ||
                (r.Height > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height)) return;
            g.PreferredBackBufferWidth = r.Width;
            g.PreferredBackBufferHeight = r.Height;
            g.IsFullScreen = false;
            g.ApplyChanges();

            Log.Write("Created window with params " + r.ToString(), Alert.Info);
        }
开发者ID:HaKDMoDz,项目名称:EntityEngineV4,代码行数:16,代码来源:EntityGame.cs

示例2: pixelPerfect

        private static bool pixelPerfect(Texture2D t1, Rectangle r1, Texture2D t2, Rectangle r2)
        {
            //Found here: http://gamedev.stackexchange.com/questions/15191/is-there-a-good-way-to-get-pixel-perfect-collision-detection-in-xna
            Color[] bits1 = new Color[t1.Width * t1.Height];
            Color[] bits2 = new Color[t2.Width * t2.Height];

            t1.GetData(bits1);
            t2.GetData(bits2);

            //Intersection Bounds
            int x1 = Math.Max(r1.X, r2.X);
            int x2 = Math.Min(r1.Right, r2.Right);
            int y1 = Math.Max(r1.Y, r2.Y);
            int y2 = Math.Min(r1.Bottom, r2.Bottom);

            for (int y = y1; y < y2; y++)
            {
                for (int x = x1; x < x2; x++)
                {
                    Color colorA = bits1[x - r1.X + (y - r1.Y) * t1.Width];
                    Color colorB = bits2[x - r2.X + (y - r2.Y) * t2.Width];

                    if (colorA.A == 255 && colorB.A == 255)
                    {
                        Debug.WriteLine("Collision Detected.");
                        Debug.WriteLine("Texture 1 Information:");
                        Debug.WriteLine("Bounds: " + t1.Bounds.ToString());
                        Debug.WriteLine("Rect:   " + r1.ToString());
                        Debug.WriteLine("Texture 2 Information:");
                        Debug.WriteLine("Bounds: " + t2.Bounds.ToString());
                        Debug.WriteLine("Rect:   " + r2.ToString());

                        Debug.WriteLine(colorA.ToString() + "    " + colorB.ToString());

                        return true;

                    }
                }
            }
            return false;
        }
开发者ID:jurramonga,项目名称:JScreenTest,代码行数:41,代码来源:CollisionDetector.cs

示例3: ReplaceRenderStates

        public void ReplaceRenderStates(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState,
            DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect, Matrix transformMatrix,
            Rectangle scissorRectangle)
        {
            bool isNewRender = currentParameters.HasValue == false;

            var newParameters = new BeginParameters();
            newParameters.ChangeRecord = new List<StateChangeInfo>();

            newParameters.SortMode = sortMode;
            newParameters.BlendState = blendState;
            newParameters.SamplerState = samplerState;
            newParameters.DepthStencilState = depthStencilState;
            newParameters.RasterizerState = rasterizerState;
            newParameters.Effect = effect;
            newParameters.TransformMatrix = transformMatrix;

            try
            {
                newParameters.ScissorRectangle = scissorRectangle;
            }
            catch(Exception e)
            {
                throw new Exception("Could not set scissor rectangle to:" + scissorRectangle.ToString(), e);
            }
            if (currentParameters != null)
            {
                beginParametersUsedThisFrame.Add(currentParameters.Value);
            }

            currentParameters = newParameters;

            if (beginEndState == SpriteBatchBeginEndState.Began)
            {
                SpriteBatch.End();
            }

            try
            {
                SpriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;
            }
            catch(Exception e)
            {
                throw new Exception("Error trying to set scissor rectangle:" + scissorRectangle.ToString());
            }
            beginEndState = SpriteBatchBeginEndState.Began;
            SpriteBatch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, transformMatrix);

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:49,代码来源:SpriteBatchStack.cs

示例4: DrawQuarterCircle

        // Draw one of the squares at a grid coordinate.
        void DrawQuarterCircle(ISpriteBatch spriteBatch, TextureContent content, Rectangle rect, Vector2 gridOrigin, int beat, Color color, float filledness, int depth)
        {
            // we prefer beats to start at upper left, but left to this logic, they start at lower left

            // position of this measure
            Vector2 position = gridOrigin + new Vector2(((beat / 4) % 4) * rect.Width, (beat / 16) * rect.Height);

            Vector2 offset;
            switch (beat % 4)
            {
                case 0: offset = new Vector2(1, 1); break;
                case 1: offset = new Vector2(0, 1); break;
                case 2: offset = new Vector2(0, 0); break;
                case 3: offset = new Vector2(1, 0); break;
                default: offset = Vector2.Zero; break; // NOTREACHED
            }
            position += offset * new Vector2(rect.Width, rect.Height);

            Rectangle destRect = new Rectangle(
                rect.Left + (int)position.X,
                rect.Top + (int)position.Y,
                rect.Width,
                rect.Height);

            Spam.Graphics.WriteLine(new string(' ', depth * 4 + 4) + Label + ": beat " + beat + ", filledness " + filledness + ", destRect " + destRect.ToString());

            // Use NonPremultiplied, as our sprite textures are not premultiplied
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

            Vector2 origin = new Vector2(0);

            // always draw a hollow quarter circle
            spriteBatch.Draw(
                content.QuarterHollowCircle,
                destRect,
                null,
                color,
                (float)((beat % 4 + 2) * Math.PI / 2),
                origin,
                SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically,
                0);

            // now maybe draw a filled circle
            Vector4 v = color.ToVector4();
            v *= filledness;
            color = new Color(v);

            spriteBatch.Draw(
                content.QuarterFilledCircle,
                destRect,
                null,
                color,
                (float)((beat % 4 + 2) * Math.PI / 2),
                origin,
                SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically,
                0);

            spriteBatch.End();
        }
开发者ID:RobJellinghaus,项目名称:Holofunk,代码行数:60,代码来源:BeatNode.cs


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