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


C# Rectangle.Offset方法代码示例

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


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

示例1: MoveVector2WASD

        public static void MoveVector2WASD(ref Vector2 pos, ref Rectangle boundingRect)
        {
            var keyboard = Keyboard.GetState();
            if (keyboard.IsKeyDown(Keys.A))
            {
                pos.X -= 2;
                boundingRect.Offset(-1,0);
            }
            else if (keyboard.IsKeyDown(Keys.D))
            {
                pos.X += 2;
                boundingRect.Offset(1, 0);

            }
            if (keyboard.IsKeyDown(Keys.W))
            {
                pos.Y -= 2;
                boundingRect.Offset(0, -1);

            }
            else if (keyboard.IsKeyDown(Keys.S))
            {
                boundingRect.Offset(0, 1);
                pos.Y += 2;
            }
        }
开发者ID:Thecontrarian,项目名称:XnaUtility,代码行数:26,代码来源:UtilityMethods.cs

示例2: Draw

        public void Draw(SpriteBatchProxy spriteBatch)
        {
            Rectangle dst = new Rectangle((int)m_location.X - MARGIN, (int)m_location.Y - MARGIN, 16, 16);
            m_srcRect.X = m_srcRect.Y = 0;

            for (int j = 0; j <= Math.Floor((double)((m_size.Y + MARGIN * 2) / m_srcRect.Height)); j++)
            {
                for (int i = 0; i <= Math.Floor((double)((m_size.X + MARGIN * 2) / m_srcRect.Width)); i++)
                {
                    spriteBatch.Draw(Application.MagicContentManager.GetTexture("textbox"), dst, m_srcRect, Color.White);

                    dst.Offset(16, 0);

                    if (i == 0)
                    {
                        // first so offset for srcRect
                        m_srcRect.Offset(16, 0);
                    }
                    else if (i == Math.Floor((double)((m_size.X + MARGIN * 2) / m_srcRect.Width)) - 1)
                    {
                        //last
                        m_srcRect.Offset(16, 0);
                    }
                }

                dst.Offset(-16 * (int)(Math.Floor((double)((m_size.X + MARGIN * 2) / m_srcRect.Width)) + 1), 16);
                m_srcRect.X = 0;

                if (j == 0)
                {
                    // first so offset for srcRect
                    m_srcRect.Offset(0, 16);
                }
                else if (j == Math.Floor((double)((m_size.Y + MARGIN * 2) / m_srcRect.Height)) - 1)
                {
                    //last
                    m_srcRect.Offset(0, 16);
                }
            }

            m_srcRect.X = m_anim * 16;
            m_srcRect.Y = 48;

            dst.Offset((int)(m_size.X + MARGIN * 2) - (16 + (int)m_skip_size.X + 8), -((int)m_skip_size.Y + 8));

            spriteBatch.Draw(Application.MagicContentManager.GetTexture("textbox"), dst, m_srcRect, Color.White);

            dst.Offset(16, 0);

            spriteBatch.DrawString(Application.MagicContentManager.Font, m_skip, dst.Location.ToVector2(), Color.Black);
            spriteBatch.DrawString(Application.MagicContentManager.Font, m_text, m_location, Color.Black);
        }
开发者ID:valryon,项目名称:Rabbit-Apocalypse,代码行数:52,代码来源:TextBox.cs

示例3: Draw

        public override void Draw(GameTime gameTime)
        {
            _reactionBar.Draw(gameTime);

             if (!_gameState.ReactionProgress.IsReactionInProgress)
             {

                 _spriteBatch.Begin();
                 var seq = _touchService.Touches;
                 for (int i = 0; i < seq.Count; i++)
                 {
                     var texture = seq[i].Button == ButtonType.Left ? _leftButtonTexture : _rightButtonTexture;

                     var scale = (_reactionBar.BackTexture.Height - 2*LetterVerticalMargin)/texture.Height/2;

                     var rect = new Rectangle(0, 0, (int) (texture.Width*scale), (int) (texture.Height*scale));

                     rect.Offset(_reactionBar.DestinationRectangle.X + (int) ((i + 0.5)*_oneTouchWidth - rect.Width/2f),
                                 _reactionBar.DestinationRectangle.Y +
                                 (int) (_reactionBar.DestinationRectangle.Height/2f - rect.Height/2f));

                     _spriteBatch.Draw(texture, rect, Color.White);
                 }

                 _spriteBatch.End();
             }

            base.Draw(gameTime);
        }
开发者ID:sergik,项目名称:Cardio,代码行数:29,代码来源:InputSequenceDisplay.cs

示例4: _drawMiniMap

		private void _drawMiniMap()
		{
			Texture2D miniMapText = EOGame.Instance.GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 45, true);
			Character c = World.Instance.MainPlayer.ActiveCharacter;

			_spriteBatch.Begin();
			for (int row = Math.Max(c.Y - 30, 0); row <= Math.Min(c.Y + 30, Map.Height); ++row)
			{
				for (int col = Math.Max(c.X - 30, 0); col <= Math.Min(c.X + 30, Map.Width); ++col)
				{
					Rectangle miniMapRectSrc = new Rectangle(0, 0, miniMapText.Width / 9, miniMapText.Height);
					bool isEdge = false;
					Vector2 loc = _getMiniMapDrawCoordinates(col, row, c);
					if (c.X == col && c.Y == row)
					{
						//draw orange thing
						miniMapRectSrc.Offset((int)MiniMapGfx.Orange * miniMapRectSrc.Width, 0);
					}
					else
					{
						isEdge = _drawObjectAndActorIcons(col, row, ref miniMapRectSrc);
					}

					_drawGridBox(isEdge, miniMapText, loc, miniMapRectSrc);
				}
			}
			_spriteBatch.End();
		}
开发者ID:Fallenoath,项目名称:EndlessClient,代码行数:28,代码来源:MiniMapRenderer.cs

示例5: Draw

        internal override void Draw(Xna.Framework.Graphics.SpriteBatch ssb)
        {
            Rectangle screen = new Rectangle(0, 0, TDVBasicGame.Width, TDVBasicGame.Height);

            Rectangle dirtSource = new Rectangle(0, 0, TDVBasicGame.Width, TDVBasicGame.Height);
            dirtSource.Offset(dirtOffset);
            ssb.Draw(dirt, screen, dirtSource, Color.White);
            ssb.Draw(current_vignette, screen, vignette2.Bounds, Color.White);
            ssb.Draw(frame, screen, frame.Bounds, Color.White);

            frameNum++;
            if (frameNum % FRAME_DIVISOR == 0)
            {
                shakeOffset = rnd.Next(6) - 6;
                dirtOffset.X = rnd.Next(dirt.Width - TDVBasicGame.Width);
                dirtOffset.Y = rnd.Next(dirt.Height - TDVBasicGame.Height);
                if (frameNum % BULB_DIVISOR == 0)
                {
                    if (rnd.Next(10) == 1)
                    {
                        current_vignette = vignette;
                    }
                    else
                    {
                        current_vignette = vignette2;
                    }
                }
            }
        }
开发者ID:Anniepoo,项目名称:DSalleShare,代码行数:29,代码来源:DirtAndScratchesSubrenderer.cs

示例6: Render

            public void Render(SpriteBatch spriteBatch, Environment env, GameTime time, Rectangle mapDest, float posLerp)
            {
                int tile;
                Rectangle destination;
                int x = mapDest.X, y = mapDest.Y;
                int tileWidth = mapDest.Width / Environment.mazeSize_;
                int tileHeight = mapDest.Height / Environment.mazeSize_;

                for (int i = 0; i < Environment.mazeSize_; ++i)
                    for (int j = 0; j < Environment.mazeSize_; ++j)
                    {
                        tile = env.maze_[i][j];
                        destination = new Rectangle(x + j * tileWidth, y + i * tileHeight, tileWidth, tileHeight);
                        if (tile == -1)
                            spriteBatch.Draw(WallTex, destination, Color.White);
                        else
                        {
                            spriteBatch.Draw(FloorTex, destination, Color.White);
                            spriteBatch.Draw(DirtTex, destination, Color.Lerp(Color.Transparent, Color.White, tile / MAX_DIRT));
                        }
                    }

                destination = new Rectangle(x + env.agentPosY_ * tileWidth, y + env.agentPosX_ * tileHeight,
                    tileWidth, tileHeight);

                switch (env.preAction_)
                {
                    case ActionType.actIDLE:
                        spriteBatch.Draw(CleanerTex, destination, Color.Yellow);
                        break;
                    case ActionType.actSUCK:
                        spriteBatch.Draw(CleanerTex, destination, Color.Green);
                        break;
                    case ActionType.actUP:
                        spriteBatch.Draw(CleanerTex, destination, env.isJustBump ? Color.Red : Color.White);
                        break;
                    case ActionType.actRIGHT:
                        destination.Offset(tileWidth, 0);

                        spriteBatch.Draw(CleanerTex, destination, null, env.isJustBump ? Color.Red : Color.White,
                            MathHelper.PiOver2, Vector2.Zero, SpriteEffects.None, 0f);
                        break;
                    case ActionType.actDOWN:
                        destination.Offset(tileWidth, tileHeight);
                        spriteBatch.Draw(CleanerTex, destination, null, env.isJustBump ? Color.Red : Color.White,
                            MathHelper.Pi, Vector2.Zero, SpriteEffects.None, 0f);
                        break;
                    case ActionType.actLEFT:
                        destination.Offset(0, tileHeight);
                        spriteBatch.Draw(CleanerTex, destination, null, env.isJustBump ? Color.Red : Color.White,
                            -MathHelper.PiOver2, Vector2.Zero, SpriteEffects.None, 0f);
                        break;
                }
            }
开发者ID:Troilk,项目名称:VacuumCleaner,代码行数:54,代码来源:TileMap2D.cs

示例7: Initialize

 public static void Initialize(Texture2D texture, Rectangle particaleFrame, Rectangle explosionFrame, int explosionFrameCount)
 {
     Texture = texture;
     ParticleFrame = particaleFrame;
     ExplosionFrames.Clear();
     ExplosionFrames.Add(explosionFrame);
     for (int x = 1; x < explosionFrameCount; x++)
     {
         explosionFrame.Offset(explosionFrame.Width, 0);
         ExplosionFrames.Add(explosionFrame);
     }
 }
开发者ID:CrimsonBlade,项目名称:Robot-Rampage,代码行数:12,代码来源:EffectsManager.cs

示例8: Engine

        public Engine()
        {
            //**** Size of the game "view port"
            int width = 600;
            int height = 800;
            bounds = new Rectangle(0, 0, width, height);
            bounds.Offset((int)((PROPERTIES.screen.Width - width) / 2.0f),
                          (int)((PROPERTIES.screen.Height - height) / 2.0f));

            //Create the (unloaded) level objects
            levels = new Level[4];
            levels[0] = new Level01(bounds);
            levels[1] = new Level02(bounds);
            levels[2] = new Level03(bounds);
            levels[3] = new Level04(bounds);
        }
开发者ID:JoseLSG,项目名称:2008-independence-day,代码行数:16,代码来源:Engine.cs

示例9: Textbox

        public Textbox( int screen_width, int screen_height, Texture2D speechPorts, SullyGame g )
        {
            game = g;
            boxes_of_text = new List<object>();
            currently_rendering_text = new List<string>();
            vertical_padding = 2;
            horizontal_padding = 7;
            long_step = 2;
            short_step = 1;

            full_reset();

            //textbox.image = Content.Load<Texture2D>( "textbox" );

            image = _.MakeBox( 317, 50, _.sg.boxcolors );

            speechPortraits = speechPorts;

            bounds = new Rectangle( 0, 0, image.Width, image.Height );

            int yloc = screen_height - bounds.Height - 4;

            bounds.Offset( ( screen_width - bounds.Width ) / 2, yloc );

            speech_bounds = new Rectangle( 2, yloc - 33, 32, 32 );

            inner_bounds = bounds; // copy value
            color_bounds = bounds;
            inner_bounds.Inflate( -horizontal_padding, -vertical_padding );
            color_bounds.Inflate( -2, -2 );

            bgColor = new Texture2D( _.sg.GraphicsDevice, 1, 1, false, SurfaceFormat.Color );
            bgColor.SetData(new[] { new Color(140, 0, 140) });

            McgLayer l = game.renderstack.GetLayer( "textbox" );

            RenderDelegate a1 = ( int x, int y ) => {
                //game.spritebatch.Draw( inactiveBgColor, mainBox.color_bounds, Color.White * .5f );
                //game.spritebatch.Draw( mainBox.image, mainBox.bounds, Color.White );
                Draw();
            };

            l.AddNode(
                new McgNode( a1, l, 0, 0, 300, 300, 3000 )
            );
        }
开发者ID:Gayo,项目名称:XNAVERGE,代码行数:46,代码来源:Textbox.cs

示例10: Draw

        // Draw the Animation Strip
        public void Draw(SpriteBatch spriteBatch)
        {
            // Only draw the animation when we are active
            if (Active)
            {
                float rot = rotFrame * 3.1416f * 2.0f / 360.0f;

            //   spriteBatch.Draw(spriteStrip, destinationRect, sourceRect, color);

               Rectangle offRect = new Rectangle(destinationRect.Left, destinationRect.Top, destinationRect.Width, destinationRect.Height);
               offRect.Offset(sourceRect.Center.X - sourceRect.Left, sourceRect.Center.Y - sourceRect.Top);
               spriteBatch.Draw(spriteStrip, offRect,
                   sourceRect, Color.White, rot,
                    //new Vector2(0f, 0f),
                    new Vector2(sourceRect.Center.X - sourceRect.Left, sourceRect.Center.Y - sourceRect.Top),
                    SpriteEffects.None, 0);

            }
        }
开发者ID:Anniepoo,项目名称:8mmlook,代码行数:20,代码来源:Animation.cs

示例11: ARefillController

        public ARefillController(Vector2 position, string refillType)
        {
            this.IsActive = true;

            m_position = position;
            m_refillType = refillType;

            m_refillArea = new Rectangle(s_refillArea.X, s_refillArea.Y, s_refillArea.Width, s_refillArea.Height);
            m_refillArea.Offset((int)m_position.X, (int)m_position.Y);

            Rectangle bounds = new Rectangle(-40, -120, 80, 120);
            m_collider = new Collider(this, bounds, ColliderType.Scenery);

            m_animationController =
                new AnimationController(
                    "Animation/Data/MissionObjects",
                    "Animation/Textures/MissionObjects",
                    AnimationName);
        }
开发者ID:dallasmccall,项目名称:metroid-ai-project,代码行数:19,代码来源:ARefillController.cs

示例12: CharacterController

        /// <summary>
        /// Protected ctor - use the construct() method
        /// </summary>
        protected CharacterController(
            Vector2 startPosition,
            int speed,
            Rectangle bounds,
            ColliderType type,
            float animationScale,
            string animationDataPath,
            string animationTexturePath)
        {
            this.m_previousPosition = startPosition;
            this.m_position = startPosition;
            this.m_speedMax = speed;

            bounds.Offset((int)m_position.X, (int)m_position.Y);
            this.m_collider = new Collider(this, bounds, type);

            this.AnimationController = new AnimationController(animationDataPath, animationTexturePath);
            this.AnimationController.ActionTriggered += new ActionTriggeredEventHandler(this.handleAction);
            this.AnimationController.Scale = animationScale;

            this.GravityEffect = Gravity.Normal;
            this.Health = this.MaxHealth;
            this.m_previousAngle = (float)Math.PI / 2;
        }
开发者ID:dallasmccall,项目名称:metroid-ai-project,代码行数:27,代码来源:CharacterController.cs

示例13: MessageBox

        public MessageBox(string text, SpriteFont spriteFont, Vector2 v2Center, BaseGame baseGame, EventHandler<PressEventArgs> OnOK)
            : base(v2Center, baseGame)
        {
            _text = text;
            _spriteFont = spriteFont;

            _buttonOK = new Button(new Rectangle(0, 0, 0, 0), "OK", _spriteFont, Color.Black, true);
            _buttonOK.Press += new EventHandler<PressEventArgs>(_buttonOK_Press);
            if (OnOK != null)
                _buttonOK.Press += OnOK;

            _v2TextSize = _spriteFont.MeasureString(_text);
            int height = textTopBuffer + (int)(_v2TextSize.Y) + betweenBuffer + _buttonOK.bounds.Height + buttonBottomBuffer;
            int width = leftBuffer + (int)(_v2TextSize.X) + rightBuffer;
            Rectangle bounds = new Rectangle((int)this.v2Center.X, (int)this.v2Center.Y, width, height);
            bounds.Offset(-(bounds.Width / 2), -(bounds.Height / 2));

            this.bounds = bounds;

            Rectangle boundsOK = new Rectangle((this.bounds.Width / 2) - (_buttonOK.bounds.Width / 2), this.bounds.Height - buttonBottomBuffer - _buttonOK.bounds.Height, _buttonOK.bounds.Width, _buttonOK.bounds.Height);
            _buttonOK.bounds = boundsOK;

            this.addButton(_buttonOK);
        }
开发者ID:BigWeather,项目名称:GamesLibrary,代码行数:24,代码来源:MessageBox.cs

示例14: GetRectangle

 public virtual Rectangle GetRectangle()
 {
     rect = new Rectangle();
     rect.Offset((int)(basePosition.X + collisionMargins.X), (int)(basePosition.Y + collisionMargins.Y));
     rect.Width = spriteSheet.SourceRectangle(0).Width - (int)(collisionMargins.X + collisionMargins.Z);
     rect.Height = spriteSheet.SourceRectangle(0).Height - (int)(collisionMargins.Y + collisionMargins.W);
     return rect;
 }
开发者ID:HeavyBomber,项目名称:HeavyBomber,代码行数:8,代码来源:AnimatedObject.cs

示例15: Draw

        public void Draw(SpriteBatchProxy spriteBatch)
        {
            Rectangle dst = new Rectangle((int)_location.X - MARGIN, (int)_location.Y - MARGIN, 16, 16);
            _srcRect.X = _srcRect.Y = 0;

            for (int j = 0; j <= Math.Floor((double)((_size.Y + MARGIN * 2) / _srcRect.Height)); j++)
            {
                for (int i = 0; i <= Math.Floor((double)((_size.X + MARGIN * 2) / _srcRect.Width)); i++)
                {
                    spriteBatch.Draw(Application.MagicContentManager.GetTexture("textbox"), dst, _srcRect, Color.White);

                    dst.Offset(16, 0);

                    if (i == 0)
                    {
                        // first so offset for srcRect
                        _srcRect.Offset(16, 0);
                    }
                    else if (i == Math.Floor((double)((_size.X + MARGIN * 2) / _srcRect.Width)) - 1)
                    {
                        //last
                        _srcRect.Offset(16, 0);
                    }
                }

                dst.Offset(-16 * (int)(Math.Floor((double)((_size.X + MARGIN * 2) / _srcRect.Width)) + 1), 16);
                _srcRect.X = 0;

                if (j == 0)
                {
                    // first so offset for srcRect
                    _srcRect.Offset(0, 16);
                }
                else if (j == Math.Floor((double)((_size.Y + MARGIN * 2) / _srcRect.Height)) - 1)
                {
                    //last
                    _srcRect.Offset(0, 16);
                }
            }

            _srcRect.X = _anim * 16;
            _srcRect.Y = 48;

            dst.Offset((int)(_size.X + MARGIN * 2) - (16 + (int)_skip_size.X + 8), -((int)_skip_size.Y + 8));

            spriteBatch.Draw(Application.MagicContentManager.GetTexture("textbox"), dst, _srcRect, Color.White);

            dst.Offset(16, 0);

            spriteBatch.DrawString(Application.MagicContentManager.Font, _skip, dst.Location.ToVector2(), Color.Black);

            // Draw controls
            var devices = Application.InputManager.GetLinkedDevices(LogicalPlayerIndex.One).FindAll(d => d.IsConnected);
            int x = COLSIZE;

            for (int i = 0; i < devices.Count; i++)
            {
                var device = devices[i];

                    Vector2 loc = _location;

                    // Display name
                    string name = LocalizedStrings.GetString("Move");

                    spriteBatch.DrawString(Application.MagicContentManager.Font, name, loc, Color.White);
                    ButtonPrinter.DrawThumbstickLeft(spriteBatch, device, loc + new Vector2(i == 1 ? x - (COLSIZE / 3) : x, i == 1 ? 40 : 0), Color.White);

                    name = LocalizedStrings.GetString("Jump");
                    loc.Y += 40 * devices.Count;

                    spriteBatch.DrawString(Application.MagicContentManager.Font, name, loc, Color.White);
                    ButtonPrinter.Draw(spriteBatch, MappingButtons.A, device, loc + new Vector2(x, 0), Color.White);

                    name = LocalizedStrings.GetString("Walk");
                    loc.Y += 40;

                    spriteBatch.DrawString(Application.MagicContentManager.Font, name, loc, Color.White);
                    ButtonPrinter.Draw(spriteBatch, MappingButtons.X, device, loc + new Vector2(x, 0), Color.White);

                    name = LocalizedStrings.GetString("Action");

                    loc.Y += 40;

                    spriteBatch.DrawString(Application.MagicContentManager.Font, name, loc, Color.White);
                    ButtonPrinter.Draw(spriteBatch, MappingButtons.Y, device, loc + new Vector2(x, 0), Color.White);

                x += COLSIZE / 2;
            }
        }
开发者ID:valryon,项目名称:Rabbit-Apocalypse,代码行数:89,代码来源:ControlTextBox.cs


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