• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SpriteEffects类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SpriteEffects的典型用法代码示例。如果您正苦于以下问题:C# SpriteEffects类的具体用法?C# SpriteEffects怎么用?C# SpriteEffects使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SpriteEffects类属于命名空间,在下文中一共展示了SpriteEffects类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Human

        public Human(Game game, SpriteBatch screenSpriteBatch,
            PlayerSide playerSide)
            : base(game, screenSpriteBatch)
        {
            string idleTextureName = "";
            this.playerSide = playerSide;

            if (playerSide == PlayerSide.Left)
            {
                catapultPosition = new Vector2(140, 332);
                idleTextureName = "Textures/Catapults/Blue/blueIdle/blueIdle";
            }
            else
            {
                catapultPosition = new Vector2(600, 332);
                spriteEffect = SpriteEffects.FlipHorizontally;
                idleTextureName = "Textures/Catapults/Red/redIdle/redIdle";
            }

            Catapult = new Catapult(game, screenSpriteBatch,
                                    idleTextureName, catapultPosition,
                                    spriteEffect,
                                    playerSide == PlayerSide.Left
                                        ? false : true, true);
        }
开发者ID:VoronFX,项目名称:SummerPractice,代码行数:25,代码来源:Human.cs


示例2: Draw

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, SpriteEffects spriteEffects)
        {
            if (Animation == null)
            {
                throw new NotSupportedException("No animation is currently playing.");
            }

            time += (float)gameTime.ElapsedGameTime.TotalSeconds;
            while (time > Animation.frameTime)
            {
                time -= Animation.frameTime;

                if (Animation.isLooping)
                {
                    frameIndex = (frameIndex + 1) % Animation.FrameCount;

                }
                else
                {
                    frameIndex = Math.Min(frameIndex + 1, Animation.FrameCount - 1);
                }
            }

            Rectangle source = new Rectangle(FrameIndex * Animation.FrameWidth, 0, Animation.FrameWidth, Animation.FrameHeight);

            spriteBatch.Draw(animation.texture, position, source, Color.White, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f);
        }
开发者ID:WINPROG20152016,项目名称:Penaranda_TapTitanXNA,代码行数:27,代码来源:AnimationPlayer.cs


示例3: SpriteRenderer

 public SpriteRenderer(Entity parent)
     : base(parent)
 {
     this.Color = Color.White;
     this.Scale = 1;
     this.SpriteEffects = SpriteEffects.None;
 }
开发者ID:sippeangelo,项目名称:DepthsBelow,代码行数:7,代码来源:SpriteRenderer.cs


示例4: Graphic

 public Graphic(Texture2D texture)
 {
     this.texture = texture;
     this.mode = Mode.Sprite;
     this.rotation = 0.0f;
     this.effect = SpriteEffects.None;
 }
开发者ID:niallsull,项目名称:ChopCommSevenWindowsPhoneGame,代码行数:7,代码来源:Graphic.cs


示例5: Robot

        public Robot(ADHDGame g, Stage st)
        {
            //init anims
            right = new Animation(new Rectangle(0, 206, Size.X, Size.Y), 9, rate, true);
            up = new Animation(new Rectangle(0, 103, Size.X, Size.Y), 9, rate, true);
            down = new Animation(new Rectangle(0, 0, Size.X, Size.Y), 9, rate, true);
            banjo = new Animation(new Rectangle(0, 618, Size.X, Size.Y), 9, 1.0f / 10.0f, false);
            banjoPlay = new Animation(new Rectangle(0, 721, Size.X, Size.Y), 9, 1.0f / 10.0f, true);
            die = new Animation(new Rectangle(0, 824, Size.X, Size.Y), 9, 1.0f / 10.0f, false);
            pushDown = new Animation(new Rectangle(0, 309, Size.X, Size.Y), 9, 1.0f / 20.0f, false);
            pushUp = new Animation(new Rectangle(0, 412, Size.X, Size.Y), 9, 1.0f / 20.0f, false);
            pushRight = new Animation(new Rectangle(0, 515, Size.X, Size.Y), 9, 1.0f / 20.0f, false);

            tex = g.Content.Load<Texture2D>("robot");
            batch = st.batch;
            stage = st;
            position = Stage.TileToPos(new Point(11, 17));
            currAnim = down;
            currAnim.Stop();
            Dir = Direction.Down;
            velocity = Vector2.Zero;
            flip = SpriteEffects.None;
            game = g;
            SnapToTile();
        }
开发者ID:Raidenthequick,项目名称:T01H,代码行数:25,代码来源:Robot.cs


示例6: SetSpriteEffects

 public override void SetSpriteEffects(int i, int j, ref SpriteEffects effects)
 {
     if (i % 2 == 1)
     {
         effects = SpriteEffects.FlipHorizontally;
     }
 }
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:7,代码来源:ExampleSapling.cs


示例7: Gun

        public Gun(Texture2D[] inputTexture, SoundEffect inputZap)
        {
            // Gun's textures.
            textureHolding = inputTexture;
            gunTexture = inputTexture[0];
            borderTexture = inputTexture[2];
            // Munitions-in-flight.
            BULLETS = new List<Bullet>();
            // Offset for animation rotation.
            rotationOffset = new Vector2(17.5F, 9);
            // Width and height of the gun's sprite.
            frameWidth = 35;
            frameHeight = 18;
            // Color, rotation, and effects.
            color = Color.White;
            rotation = 0;
            effects = SpriteEffects.None;
            // Where do you want the gun placed relative to the vector it is attached too?
            placementXOffset = 15;
            placementYOffset = 35;
            // Zap sound effect.
            zap = inputZap;
            animationFrame = new Rectangle(0, 0, frameWidth, frameHeight);

            mineSpawn = new Stopwatch();
        }
开发者ID:bhalash,项目名称:Flyatron,代码行数:26,代码来源:Gun.cs


示例8: CreateColored

        /// <summary>
        /// Creates a <see cref="ColoredString"/> object from an existing string with the specified foreground and background, setting the ignore properties if needed.
        /// </summary>
        /// <param name="value">The current string.</param>
        /// <param name="foreground">The foreground color. If null, <see cref="ColoredString.IgnoreForeground"/> will be set.</param>
        /// <param name="background">The background color. If null, <see cref="ColoredString.IgnoreBackground"/> will be set.</param>
        /// <param name="spriteEffect">The background color. If null, <see cref="ColoredString.IgnoreEffect"/> will be set.</param>
        /// <returns>A <see cref="ColoredString"/> object instace.</returns>
        public static ColoredString CreateColored(this string value, Color? foreground = null, Color? background = null, SpriteEffects? spriteEffect = null)
        {
            var stacks = new ParseCommandStacks();

            if (foreground.HasValue)
                stacks.AddSafe(new ParseCommandRecolor() { R = foreground.Value.R, G = foreground.Value.G, B = foreground.Value.B, A = foreground.Value.A, CommandType = CommandTypes.Foreground });

            if (background.HasValue)
                stacks.AddSafe(new ParseCommandRecolor() { R = background.Value.R, G = background.Value.G, B = background.Value.B, A = background.Value.A, CommandType = CommandTypes.Background });

            if (spriteEffect.HasValue)
                stacks.AddSafe(new ParseCommandSpriteEffect() { Effect = spriteEffect.Value, CommandType = CommandTypes.SpriteEffect });

            ColoredString newString = ColoredString.Parse(value, initialBehaviors: stacks);

            if (!foreground.HasValue)
                newString.IgnoreForeground = true;

            if (!background.HasValue)
                newString.IgnoreBackground = true;

            if (!spriteEffect.HasValue)
                newString.IgnoreSpriteEffect = true;

            return newString;
        }
开发者ID:Thraka,项目名称:SadConsole,代码行数:34,代码来源:StringExtensions.cs


示例9: DrawAnimation

 // draw with sprite effect
 public static void DrawAnimation(this SpriteBatch spriteBatch, Animation animation, Vector2 position, float angle, SpriteEffects effect)
 {
     Point tile = animation.GetTile(animation.CurrentFrame);
     Rectangle source = new Rectangle(tile.X * animation.TileWidth, tile.Y * animation.TileHeight, animation.TileWidth, animation.TileHeight);
     Rectangle dest = new Rectangle(Round(position.X), Round(position.Y), animation.TileWidth, animation.TileHeight);
     spriteBatch.Draw(animation.Texture, dest, source, Color.White, angle, new Vector2(animation.TileWidth / 2, animation.TileHeight / 2), effect, 0);
 }
开发者ID:shiroto,项目名称:Devil-s-Armageddon-Pacamari-of-Death-Heavy-Metal-Edition,代码行数:8,代码来源:Renderer.cs


示例10: musicToggleButton

 public musicToggleButton(String artName, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color, float rotation,
     Vector2 origin, SpriteEffects effects, float layerDepth, Game game)
     : base(artName, destinationRectangle, sourceRectangle, color, rotation, origin, effects, layerDepth)
 {
     //Henter audiomanager fra game
     _audioManager = (IManageAudio)(game.Services.GetService(typeof(IManageAudio)));
 }
开发者ID:struckAnerve,项目名称:vikingvalg,代码行数:7,代码来源:musicToggleButton.cs


示例11: Animation

 public Animation(Vector2 characterVelocity, TimeSpan timePerFrame, SpriteEffects effect, string[] sprites)
 {
     this.Sprites = sprites;
     this.TimePerFrame = timePerFrame;
     this.Effect = effect;
     this.CharacterVelocity = characterVelocity;
 }
开发者ID:RandolphBurt,项目名称:TexturePacker-MonoGame-Demo,代码行数:7,代码来源:Animation.cs


示例12: BadGuy

        //30sec ttl
        /// <summary>
        /// Super constructor for enemies. You must call it in subclasses
        /// </summary>
        /// <param name="_location">Screen location</param>
        /// <param name="_pattern">Move pattern to use</param>
        /// <param name="_scrollValue">Scroll value trigger</param>
        /// <param name="flags">Flags to set on death</param>
        /// <param name="flip">Type of flip</param>
        /// <param name="scale">Sprite scaling (use Vector2.One if not necessary)</param>
        /// <param name="speed">Speed of the enemy</param>
        /// <param name="spriteSrc">Spritesheet rectangle selection</param>
        /// <param name="_bonusDroppedOnDeath">Bonus the enemy will drop on death</param>
        /// <param name="weapon">Enemy weapon</param>
        protected BadGuy(Vector2 _location, Vector2 _scrollValue, Bonus _bonusDroppedOnDeath, MovePattern _pattern, String[] flags, SpriteEffects flip, Rectangle spriteSrc, Vector2 speed, Vector2 scale, Weapon weapon)
            : base(_location, spriteSrc, speed, scale, 0.0f, 30000f)
        {
            this.dropOnDeath = _bonusDroppedOnDeath;
            this.movePattern = _pattern;
            this.scrollValue = _scrollValue;
            this.Flags = flags;

            if (_pattern != null)
            {
                bounce = false;
            }
            else
            {
                bounce = true;
            }

            this.onScreen = false;
            this.rotation = 0.0f;

            this.Flip = flip;
            this.Weapon = weapon;

            if (this.Weapon != null)
            {
                this.Weapon.Flip = flip;
            }

            this.Hitbox = new SquareHitbox(this);
            this.Removable = true;
            this.InfiniteMovePattern = false;
            this.Difficulty = 0;
            this.ttl = 120000;
            this.FiringLocation = Vectors.ConvertPointToVector2(DstRect.Center);
        }
开发者ID:Azzhag,项目名称:The-Great-Paper-Adventure,代码行数:49,代码来源:BadGuy.cs


示例13: DrawByCenter

        public void DrawByCenter(SpriteBatch sb, Vector2 location, SpriteEffects effects, float layerDepth)
        {
            Rectangle source = atlas.getSourceRectangle(currentFrame);
            Rectangle destination = new Rectangle((int)(location.X - (source.Width / 2)), (int)(location.Y - (source.Height / 2)), source.Width, source.Height);

            sb.Draw(atlas.getTexture(), destination, source, Color.White, 0, Vector2.Zero, effects, layerDepth);
        }
开发者ID:RainbowCupcake,项目名称:LunaPumpkinToss,代码行数:7,代码来源:AnimatedSpriteAtlas.cs


示例14: DrawArm

 public void DrawArm(SpriteBatch spriteBatch, Vector2 Position, Vector2 Origin, SpriteEffects effect = SpriteEffects.None)
 {
     if (armAni.ContainsKey(State))
     {
         armAni[State].Draw(spriteBatch, Position, Origin, effect);
     }
 }
开发者ID:BryceGough,项目名称:MapleSharp,代码行数:7,代码来源:MapleEquip.cs


示例15: AnimatedSprite

 public AnimatedSprite(iAnimatedSprite iAnimatedSprite)
 {
     this.iAnimatedSprite = iAnimatedSprite;
     this.sourceRectangle = new Rectangle(0, 0, 32, 32);
     this.effect = SpriteEffects.None;
     this.pivot = new Vector2(16f, 16);
 }
开发者ID:RWinning,项目名称:Toets1-GameScenes,代码行数:7,代码来源:AnimatedSprite.cs


示例16: UITextObject

 public UITextObject(string id, ObjectType objectType, Transform2D transform,
     Color color, SpriteEffects spriteEffects, float layerDepth, string text, SpriteFont spriteFont, bool isVisible)
     : base(id, objectType, transform, color, spriteEffects, layerDepth, isVisible)
 {
     this.spriteFont = spriteFont;
     this.text = text;
 }
开发者ID:SongmanW,项目名称:Group-Project-2016-Team-Magia,代码行数:7,代码来源:UITextObject.cs


示例17: Advance

        public void Advance(Position position__1, SpriteEffects flip)
        {
            if (flip == SpriteEffects.FlipHorizontally)
            {
            this.flip = SpriteEffects.None;
            }
            else
            {
            this.flip = SpriteEffects.FlipHorizontally;
            }

            if (position__1.X + SPRITE_SIZE_X - 30 <= Position.X)
            {
            //flip = SpriteEffects.None;
            spriteState.Add(Enumeration.State.advance, Enumeration.PriorityState.Normal);
            }
            else if (position__1.X - SPRITE_SIZE_X + 30 >= Position.X)
            {
            spriteState.Add(Enumeration.State.advance, Enumeration.PriorityState.Normal);
            }
            else
            {
            //flip = SpriteEffects.FlipHorizontally;
            Strike();
            //spriteState.Add(Enumeration.State.ready, Enumeration.PriorityState.Normal);
            return;
            }

            sprite.PlayAnimation(spriteSequence, spriteState.Value());
        }
开发者ID:salvadorc17,项目名称:Prince-Monogame,代码行数:30,代码来源:Guard2.cs


示例18: UIMouseObject

 public UIMouseObject(string id, ObjectType objectType, Transform2D transform,
 Color color, SpriteEffects spriteEffects, float layerDepth, Texture2D texture, bool isVisible)
     : this(id, objectType, transform, color, spriteEffects, layerDepth, texture, 
         new Rectangle(0, 0, texture.Width, texture.Height),
             new Vector2(texture.Width / 2.0f, texture.Height / 2.0f), isVisible)
 {
 }
开发者ID:SongmanW,项目名称:Group-Project-2016-Team-Magia,代码行数:7,代码来源:UIMouseObject.cs


示例19: Draw

        // <param name="position">This should be where you want the pivot point of the sprite image to be rendered.</param>
        public void Draw(SpriteFrame sprite, Vector2 position, Color? color = null, float rotation = 0, float scale = 1, SpriteEffects spriteEffects = SpriteEffects.None)
        {
            Vector2 origin = sprite.Origin;
            if (sprite.IsRotated)
            {
                rotation -= ClockwiseNinetyDegreeRotation;
                switch (spriteEffects)
                {
                    case SpriteEffects.FlipHorizontally: spriteEffects = SpriteEffects.FlipVertically; break;
                    case SpriteEffects.FlipVertically: spriteEffects = SpriteEffects.FlipHorizontally; break;
                }
            }
            switch (spriteEffects)
            {
                case SpriteEffects.FlipHorizontally: origin.X = sprite.SourceRectangle.Width - origin.X; break;
                case SpriteEffects.FlipVertically: origin.Y = sprite.SourceRectangle.Height - origin.Y; break;
            }

            this.spriteBatch.Draw(
                texture: sprite.Texture,
                position: position,
                sourceRectangle: sprite.SourceRectangle,
                color: color,
                rotation: rotation,
                origin: origin,
                scale: new Vector2(scale, scale),
                effects: spriteEffects);
        }
开发者ID:USKamicadze,项目名称:Match3,代码行数:29,代码来源:SpriteRender.cs


示例20: Draw

        public void Draw(Texture2D texture, Vector2 position, DoubleRectangle? sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
        {
            DrawCommand cmd = GetRenderer().GetAvailableCommand();
            cmd.CommandType = DrawCommand.DrawCommandType.Texture;
            cmd.Texture = texture;
            cmd.Position = position;
            cmd.Color = color;

            // Vic says - make sure this stays in, or else previously-drawn Sprites can make later-drawn Sprites have the wrong effect
            cmd.ShaderEffect = null;

            cmd.Rotation = rotation;
            cmd.Origin = origin;
            if (sourceRectangle != null)
            {
                cmd.SourceRectangle = sourceRectangle.Value;
            }
            else
            {
                cmd.SourceRectangle = DoubleRectangle.Empty;
            }
            cmd.Scale = scale;
            cmd.Effects = effects;
            cmd.LayerDepth = layerDepth;
            cmd.CalculateDestinationRectangle(texture);
        }
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:26,代码来源:GraphicsBatch.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SpriteEntry类代码示例发布时间:2022-05-24
下一篇:
C# SpriteBatch类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap