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


C# Graphics.Sprite类代码示例

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


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

示例1: MainMenu

        //Gets info from game and menu items.
        //public MainMenu(SpriteFont spriteFont, string[] menuItems)
        public MainMenu(SpriteFont spriteFont)
        {
            this.spriteFont = spriteFont;
            //this.menuItems = menuItems;
            Input.Initialize();
            fontColor = Color.White;
            //MeasureMenu();
            LoadContent();

            logo = new Sprite("logo");
            logo.Scale = 0.4f;
            logo.Position = new Vector2(Stuff.Resolution.X * 0.675f, Stuff.Resolution.Y * 0.3f);

            buttons = new List<Button>();

            //start game
            Button b = new Button("Buttons", new Vector2(150, 50), new Rectangle(0, 120 * 2, 250, 120), false, false);
            buttons.Add(b);
            //high scores
            b = new Button("Buttons", new Vector2(150, 170), new Rectangle(0, 120 * 4, 250, 120), false, false);
            buttons.Add(b);
            //settings
            b = new Button("Buttons", new Vector2(150, 290), new Rectangle(0, 120 * 5, 250, 120), false, false);
            buttons.Add(b);
            //exit game
            b = new Button("Buttons", new Vector2(150, 410), new Rectangle(0, 120 * 7, 250, 120), false, false);
            buttons.Add(b);
            menuEgg = new MenuEgg();
        }
开发者ID:markustenghamn,项目名称:EggRoll,代码行数:31,代码来源:MainMenu.cs

示例2: Slot_old

 public Slot_old(Game game)
     : base(game)
 {
     img = new Sprite(game, GraphicsCollection.GetPack("steag"));
     img.StackOrder = 6;
     AddChild(img);
 }
开发者ID:HaKDMoDz,项目名称:operation-cronos,代码行数:7,代码来源:Slot_old.cs

示例3: AttachAnimation

        public void AttachAnimation(Sprite sprite, Animation animation, params ActiveAnimationSetUpdater[] animationUpdaters)
        {
            animation.Initialize(this, sprite);

            foreach (var animationUpdater in animationUpdaters)
            {
                animationUpdater.Add(animation);
            }

            Animation activeAnimation = sprite.ActiveAnimation;

            if (activeAnimation == null)
            {
                sprite.ActiveAnimation = animation;
                this.animations.Add(animation);
            }
            else
            {
                while (activeAnimation.NextAnimation != null)
                {
                    activeAnimation = activeAnimation.NextAnimation;

                    if (activeAnimation == animation)
                        throw new ArgumentException("Same animation attached more than once");
                }

                activeAnimation.NextAnimation = animation;
            }
        }
开发者ID:jlyonsmith,项目名称:ToyBox,代码行数:29,代码来源:SpriteManager.cs

示例4: Reticle

 public Reticle(Texture2D tex, SpriteBatch sb, Vector2 pos)
 {
     this._sprite = new Sprite(tex, sb, pos);
     this._mouseState = Mouse.GetState();
     this._position.X = this._mouseState.Position.X;
     this._position.Y = this._mouseState.Position.Y;
 }
开发者ID:Kmann180,项目名称:WormsRemake,代码行数:7,代码来源:Reticle.cs

示例5: CreateCursor

 /// <summary>
 /// Instantiates the cursor.
 /// Sets the cursor's layer.
 /// Offsets the cursor to be centered on it's position.
 /// </summary>
 private void CreateCursor()
 {
     _cursor = new Sprite(Content.Load<Texture2D>("cursor"), Vector2.Zero);
         _cursor.Layer = 1.0f;
         _cursor.SetOffset(Anchor.Center);
         Drawables.Add(_cursor);
 }
开发者ID:jmcgranahan,项目名称:jusall-programinghw,代码行数:12,代码来源:GameScene.cs

示例6: Draw

        public override void Draw(GameTime gameTime)
        {
            //TODO: Handle rotation??
            //TODO: Keep only one sprite and change it, do not recreate one
            Sprite s = new Sprite(Texture, RectangleToRender, Color, Layer)
            {
                Rotation = GameObject.Transform.Rotation,
                Color = Color,
                Origin = Origin,
                Scale = GameObject.Transform.Scale
            };

            Engine.SpriteRenderer.Draw(s);

            //if (Texture != null)
                //spriteBatch.Draw(
                //    Texture,
                //    RectangleToRender,
                //    null,
                //    Color,
                //    0,
                //    //new Vector2((float)RectangleToRender.Width / 2, (float)RectangleToRender.Height / 2),//TODO: Why is the Origin acting so weird?
                //    Vector2.Zero,
                //    SpriteEffects.None,
                //    0);
        }
开发者ID:jpgdev,项目名称:JPEngine,代码行数:26,代码来源:RectRenderer.cs

示例7: MainScene

        public MainScene(ContentManager content, GraphicsDeviceManager graphicsManager)
        {
            Stuff.Initialize(content, graphicsManager);
            graphics = graphicsManager;
            onScreenMessages = new OnScreenMessages();
            Camera2d.Position = Stuff.ScreenCenter;
            input = new Input();
            characters = new List<Character>();
            player = new Player(characters);

            debugTiles = new List<Sprite>();
            for (int i = -10; i < 30; i++)
            {
                Sprite s = new Sprite("SpriteSheet");
                s.Source = new Rectangle(1 * 150, 9 * 150, 150, 150);
                s.Position = new Vector2(i * 150, 400);
                debugTiles.Add(s);
            }
            for (int i = 0; i < 100; i++)
            {
                Sprite tempSprite = new Sprite("SpriteSheet");
                tempSprite.Source = new Rectangle(11 * 150, 9 * 150, 150, 150);
                tempSprite.Position = new Vector2(150*i, 250 + (-150*i));
                debugTiles.Add(tempSprite);
            }
        }
开发者ID:markustenghamn,项目名称:EggRoll,代码行数:26,代码来源:MainScene.cs

示例8: GraphBar

 public GraphBar(Game game, int percent)
     : base(game)
 {
     visual = new Sprite(game, GraphicsCollection.GetPack("pixel"));
     Percent = percent;
     AddChild(visual);
 }
开发者ID:HaKDMoDz,项目名称:operation-cronos,代码行数:7,代码来源:GraphBar.cs

示例9: MoveableTile

        /// <summary>
        /// Creates a new Moveable tile.
        /// </summary>
        /// <param name="sprite">Sprite representing texture, size, and position of the tile. </param>
        /// <param name="collision">Type of collision for the tile.</param>
        /// <param name="velocity">Tile velocity: .X is the movement angle in radians and .Y is the speed in pixels per second.</param>
        public MoveableTile(Sprite sprite, TileCollision collision, Vector2 velocity)
            : base(sprite, collision)
        {
            this.velocity = velocity;

            Leader = this; // By default, tiles lead themselves
        }
开发者ID:zmthy,项目名称:play-dead,代码行数:13,代码来源:MoveableTile.cs

示例10: CombatTextureHolder

        /// <summary>
        /// Creates the CombatTextureHolder's arrays, and all the members in them.
        /// </summary>
        /// <param name="manager">Main game class's Content Loader.</param>
        protected CombatTextureHolder(GraphicsDevice graphics)
        {
            int numAbilities = ConstantHolder.textureLoader.getTexturesByType((int)TextureTypes.Ability).Count;
            int numAbilityEffects = ConstantHolder.textureLoader.getTexturesByType((int)TextureTypes.AbilityEffect).Count;
            abilityButtonSprites = new Sprite[numAbilities];
            abilityAnimationSprites = new Sprite[numAbilities];
            abilityEffectSprites = new Sprite[numAbilityEffects];
            abilityImpactSprites = new Sprite[numAbilities];
            effectIconSprites = new Sprite[numAbilityEffects];

            int abilityIndex = 0;

            foreach (TextureXML tex in ConstantHolder.textureLoader.textureCategories[(int)TextureTypes.Ability])
            {
                ConstantHolder.AbilityButtonDict.Add(tex.fileName, abilityIndex);
                //For abilities, portrait = impact
                loadAbilityAnimation(graphics, abilityIndex++, tex.fileName, tex.mainSize.vec, tex.ColumnHeights,
                                     tex.portraitName, tex.portraitSize.vec, tex.PortraitColumnHeights,
                                     tex.buttonName, tex.buttonSize.vec, tex.ButtonColumnHeights);
            }

            int effectIndex = 0;

            foreach (TextureXML tex in ConstantHolder.textureLoader.textureCategories[(int)TextureTypes.AbilityEffect])
            {
                ConstantHolder.AbilityEffectSpriteDict.Add(tex.fileName, effectIndex);
                loadEffect(graphics, effectIndex++, tex.fileName, tex.mainSize.vec, tex.ColumnHeights,
                    tex.iconName, tex.iconSize.vec, tex.IconColumnHeights);
            }
        }
开发者ID:isaac109,项目名称:mainframe-tbs-engine,代码行数:34,代码来源:CombatTextureHolder.cs

示例11: Update

        //check for colisions
        public void Update(List<Sprite> collisionArray)
        {
            for (int x = 0; x < collisionArray.Count; ++x)
            {
                //where the sprite collisions happened
                Collided_Bottom = null;
                Collided_Top = null;
                Collided_Left = null;
                Collided_Right = null;

                for (int y = 0; y < collisionArray.Count; ++y)
                {
                    //check if it contains the bottom center

                    //If bottom left overlaps check if it is more bottom or more left
                    if (x !=y && collisionArray[x].HitBox.Intersects(collisionArray[y].HitBox))
                    {

                        //CollisionArray returns 0 when the objects should collide normally, 1 if it should ignore collisions

                        //Check if the mid points of figure y touch figure x
                        if (collisionArray[y].HitBox.Contains((int)(collisionArray[x].HitBox.X + collisionArray[x].HitBox.Width / 2), (int)(collisionArray[x].HitBox.Y + collisionArray[x].HitBox.Height)) && collisionArray[y].HitBox.Y > collisionArray[x].HitBox.Y)
                                Collided_Bottom = collisionArray[y];
                        if (collisionArray[y].HitBox.Contains((int)(collisionArray[x].HitBox.X + collisionArray[x].HitBox.Width / 2), (int)(collisionArray[x].HitBox.Y)) && collisionArray[x].HitBox.Y > collisionArray[y].HitBox.Y)
                               Collided_Top = collisionArray[y];
                        if (collisionArray[y].HitBox.Contains((int)(collisionArray[x].HitBox.X), (int)(collisionArray[x].HitBox.Y + collisionArray[x].HitBox.Height / 2)) && collisionArray[y].HitBox.X < collisionArray[x].HitBox.X)
                                Collided_Left = collisionArray[y];
                        if (collisionArray[y].HitBox.Contains((int)collisionArray[x].HitBox.X + collisionArray[x].HitBox.Width, (int)collisionArray[x].HitBox.Y + collisionArray[x].HitBox.Height / 2) && collisionArray[x].HitBox.X < collisionArray[y].HitBox.X)
                                Collided_Right = collisionArray[y];
                        //Adjusts the location of the collisionArray so that they are no longer colliding and changes their velocity
                        AdjustPosition(collisionArray, x);
                    }
                }
            }
        }
开发者ID:DanielWieder,项目名称:Dota-2d,代码行数:36,代码来源:CollisionDetection.cs

示例12: Mask

        public Mask(Sprite spriteMask, Sprite spriteTarget)
        {
            _spriteMask = spriteMask;
            _spriteTarget = spriteTarget;

            Render.Viewport.ResolutionChanged += Setup;
            Setup();

            _maskStencilState = new DepthStencilState
            {
                StencilEnable = true,
                StencilFunction = CompareFunction.Always,
                StencilPass = StencilOperation.Replace,
                ReferenceStencil = 1,
                DepthBufferEnable = false,
            };

            _targetStencilState = new DepthStencilState
            {
                StencilEnable = true,
                StencilFunction = CompareFunction.LessEqual,
                StencilPass = StencilOperation.Replace,
                ReferenceStencil = 1,
                DepthBufferEnable = false,
            };

            Add(new DrawComponent(Draw));
        }
开发者ID:hgrandry,项目名称:Mgx,代码行数:28,代码来源:Mask.cs

示例13: Actor

 public Actor(Vector2 position, Vector2 size, Sprite sprite)
 {
     Position = position;
     Size = size;
     Sprite = sprite;
     facingLeft = false;
 }
开发者ID:thormme,项目名称:WsoftCompo2013,代码行数:7,代码来源:Actor.cs

示例14: BrainMapManager

        //private BrainMapMarker currentMapMarker = null;
        public BrainMapManager(SpriteBatch spriteBatch, Soul game, AudioManager audioManager, InputManager controls, Vector2 position)
        {
            this.audioManager = audioManager;
            bg = new Sprite(spriteBatch, game, Constants.BRAIN_MAP_BG);
            mapList = new List<BrainMapMarker>();

            List<BrainMapMarker> tmpList = new List<BrainMapMarker>();
            /*mapList.Add(tmpList);
            tmpList = new List<BrainMapMarker>();
            mapList.Add(tmpList);
            tmpList = new List<BrainMapMarker>();
            mapList.Add(tmpList);*/

            menuManager = new MenuManager(controls);
            ImageButton button = new ImageButton(spriteBatch, game, controls, new Vector2((float)Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f - 150, (float)Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200), Constants.GUI_CLEANSE, "cleanse");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            button = new ImageButton(spriteBatch, game, controls, new Vector2((float)Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 150, (float)Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200), Constants.GUI_BACK, "back");
            button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress);
            menuManager.AddButton(button);
            menuManager.initialize();
            fadeinOut = new FadeInOut(spriteBatch, game, 100);
            this.position = position;
            offset = new Vector2((float)bg.X * 0.5f, (float)bg.Y *0.5f);
            this.controls = controls;
        }
开发者ID:rodstrom,项目名称:soul,代码行数:27,代码来源:BrainMapManager.cs

示例15: Goomba

 public Goomba(Vector2 initialPosition)
     : base(initialPosition)
 {
     death = new Sprite(Textures.GetTexture(Textures.Texture.goomba), new Rectangle(16, 0 + (16 * World.WorldType), 16, 16));
     goomba = new Sprite(Textures.GetTexture(Textures.Texture.goomba), new Rectangle(0, 0 + (16 * World.WorldType), 16, 16));
     velocity.X = -walkingSpeed;
 }
开发者ID:Exor,项目名称:SuperMarimoBros,代码行数:7,代码来源:Goomba.cs


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