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


C# Sprite.GetGlobalBounds方法代码示例

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


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

示例1: Draw

        public override void Draw(RenderTarget rt)
        {
            Vector2f actualPosition = Position + (Selected ? new Vector2f(0, -12.0f - 5.0f * GetSelectedIndex()) : new Vector2f());

            // Draw card
            Sprite sprite = new Sprite(Assets.LoadTexture(Info.Type == CardType.White ? "CardWhite.png" : "CardBlack.png"));
            Size = new Vector2f(sprite.GetGlobalBounds().Width, sprite.GetGlobalBounds().Height);
            sprite.Position = actualPosition;
            sprite.Scale = Scale;
            rt.Draw(sprite);

            // Draw text
            Text text = GameUtility.Wrap(Info.Value, Assets.LoadFont("arialbd.ttf"), (uint)Math.Floor(24.0f * Scale.X),
                                     Math.Floor(207.0f * Scale.X));

            text.Color = Info.Type == CardType.White ? Color.Black : Color.White;
            text.Position = actualPosition + new Vector2f(16.0f * Scale.X, 10.0f * Scale.Y);
            text.Round();
            rt.Draw(text);

            // Draw decorations
            if (Info.PickCount > 1)
            {
                Sprite pickMultiple = new Sprite(Assets.LoadTexture(Info.PickCount == 2 ? "PickTwo.png" : "PickThree.png"))
                {
                    Position =
                        actualPosition +
                        new Vector2f((241.0f - 56.0f - 10.0f - 4.0f) * Scale.X, (320.0f - 10.0f - 20.0f) * Scale.Y),
                    Scale = Scale
                };

                rt.Draw(pickMultiple);
            }
        }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:34,代码来源:Card.cs

示例2: Added

        public override void Added()
        {
            var x = _cBody.X.ToPixels();
            var y = _cBody.Y.ToPixels();

            Sprite = new Sprite(Assets.GetTexture(_textureName));
            if (_tilesetName != null && _labelName != null) Sprite.TextureRect = Assets.GetTileset(_tilesetName).GetTextureRect(_labelName);
            Sprite.Rotation = _rotation;
            Sprite.Position = new Vector2f(x, y);
            Sprite.Origin = new Vector2f(Sprite.GetGlobalBounds().Width/2, Sprite.GetGlobalBounds().Height/2);

            _game.AddDrawAction(Draw);
        }
开发者ID:SuperV1234,项目名称:TestGenericShooter,代码行数:13,代码来源:CRender.cs

示例3: Collision

        public bool Collision(Sprite sprite1, Sprite sprite2, uint alphaLimit)
        {
            FloatRect intersection;
            if (sprite1.GetGlobalBounds().Intersects(sprite2.GetGlobalBounds(), out intersection))
            {
                IntRect subRect1 = sprite1.TextureRect;
                IntRect subRest2 = sprite2.TextureRect;
                uint[] mask1 = Bitmasks[sprite1.Texture];
                uint[] mask2 = Bitmasks[sprite2.Texture];

                for (int i = (int)intersection.Left; i < intersection.Left + intersection.Width; i++)
                    for (int j = (int)intersection.Top; j < intersection.Top + intersection.Height; j++)
                    {
                        Vector2f vector1 = sprite1.InverseTransform.TransformPoint(i, j);
                        Vector2f vector2 = sprite2.InverseTransform.TransformPoint(i, j);

                        if (vector1.X > 0 && vector1.Y > 0 && vector2.X > 0 && vector2.Y > 0 &&
                           vector1.X < subRect1.Width && vector1.Y < subRect1.Height &&
                           vector2.X < subRest2.Width && vector2.Y < subRest2.Height)
                            if (GetPixel(mask1, sprite1.Texture, (uint)(vector1.X) + (uint)subRect1.Left, (uint)(vector1.Y) + (uint)subRect1.Top) > alphaLimit &&
                                GetPixel(mask2, sprite2.Texture, (uint)vector2.X + (uint)subRest2.Left, (uint)vector2.Y + (uint)subRest2.Top) > alphaLimit)
                                return true;
                    }

            }

            return false;
        }
开发者ID:Kaev,项目名称:Alieanum,代码行数:28,代码来源:CollisionManager.cs

示例4: UnitCell

        public UnitCell(Cell targetCell, Cell sourceCell, int units, PlayerInstance player)
        {
            TargetCell = targetCell;
            SourceCell = sourceCell;
            Units = UnitsLeft = units;
            _currentVelocity = Velocity;

            string colorName = null;
            if (SourceCell.Player.Color.R == 255 && SourceCell.Player.Color.G == 0 && SourceCell.Player.Color.B == 0)
            {
                colorName = "red";
            }
            else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 255 && SourceCell.Player.Color.B == 0)
            {
                colorName = "green";
            }
            else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 0
                     && SourceCell.Player.Color.B == 255)
            {
                colorName = "blue";
            }

            _sprite = new Sprite(ResourceManager.Instance["game/unit_cell_" + colorName] as Texture);

            _text = new Text(units.ToString(), ResourceManager.Instance["fonts/verdana"] as Font, FontSize);
            _text.Origin = new Vector2f(
                _text.GetLocalBounds().Left + _text.GetLocalBounds().Width / 2,
                _text.GetLocalBounds().Top);

            _particleSystem = new ParticleSystem(ResourceManager.Instance["game/particle"] as Texture);

            var scale = 0.5f + Units * 0.0125f;
            if (scale >= 1f)
            {
                scale = 1f;
            }

            Scale = _initialScale = new Vector2f(scale, scale);

            Radius = _sprite.GetGlobalBounds().Height / 2;
            _sprite.Origin = new Vector2f(_sprite.GetLocalBounds().Width / 2, _sprite.GetLocalBounds().Height / 2);
            SourcePlayer = player;
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:43,代码来源:UnitCell.cs


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