Beispiel #1
0
 public TextBox(Game game, string name, AnimatedTexture animatedTexture, List<AnimatedGuiAnimations> animations, Vector2 position, SpriteFont font, string text = "")
     : base(game, name, animatedTexture, animations, position)
 {
     inputTextProcessor = new InputTextProcessor(game);
     Text = text;
     Font = font;
 }
 public AnimatedGuiBase(Game game, string name, AnimatedTexture animatedTexture, List<AnimatedGuiAnimations> animations, Vector2 position)
     : base(game, name, animatedTexture.Texture, position)
 {
     this.animations = animations;
     this.animatedTexture = animatedTexture;
     this.animatedTexture.Position = position;
 }
Beispiel #3
0
 private Player2D(Player2D player)
     : base(player.Game)
 {
     Name = player.Name;
     EnableCollisionDetection = player.EnableCollisionDetection;
     EnableMovement = player.EnableMovement;
     EnableAnimation = player.EnableAnimation;
     directionsAvailable = player.directionsAvailable;
     AnimatedTexture = new AnimatedTexture(player.AnimatedTexture);
 }
        protected override void LoadContent()
        {
            List<AnimatedTextureRegion> textureRegions = new List<AnimatedTextureRegion>
            {
                new AnimatedTextureRegion("exp1", 1, 8, 67, 67),
                new AnimatedTextureRegion("exp2", 2, 8, 67, 67),
                new AnimatedTextureRegion("exp3", 3, 8, 67, 67),
                new AnimatedTextureRegion("exp4", 4, 8, 67, 67)
            };
            explosion = new AnimatedTexture(game, SceneContent.Load<Texture2D>("UI image/explosion"), textureRegions);
            explosion.Position = new Vector2(200, 200);
            explosion.AnimationSpeed = 0;
            explosion.AnimateAllRegions = true;
            AddDrawableGameComponent(explosion);

            base.LoadContent();
        }
        public AnimatedTexture(AnimatedTexture at)
            : base(at.Game)
        {
            if (at.regions == null || at.regions.Count == 0)
                throw new UtilityException("regions list cannot be null or empty!");

            if (at.texture == null)
                throw new UtilityException("texture cannot be null!");

            this.spriteBatch = at.Game.Services.GetService<SpriteBatch>();
            this.texture = at.texture;
            this.regions = at.regions;
            this.Position = at.Position;
            this.AnimationSpeed = at.AnimationSpeed;
            this.destRect = at.destRect;
            this.sourceRect = at.sourceRect;

            SetRegion(at.currentRegion.Name); //set first region with default
        }
Beispiel #6
0
        protected override void LoadContent()
        {
            List<AnimatedTextureRegion> regions = new List<AnimatedTextureRegion>
            {
                new AnimatedTextureRegion("non_focused", 1, 1, 311, 55),
                new AnimatedTextureRegion("focused", 2, 1, 311, 55)
            };
            List<AnimatedGuiAnimations> animations = new List<AnimatedGuiAnimations>()
            {
                new AnimatedGuiAnimations(AnimatedGuiEvents.OnFocused, "focused"),
                new AnimatedGuiAnimations(AnimatedGuiEvents.OnLostFocus, "non_focused")
            };
            AnimatedTexture textBoxTexture = new AnimatedTexture(game, SceneContent.Load<Texture2D>("UI image/textbox_example"), regions);

            label = new Label(game, "label1", SceneContent.Load<SpriteFont>("Fonts/curier_new"), "prova", Vector2.Zero);
            textbox = new TextBox(game, "textbox1", textBoxTexture, animations, new Vector2(200, 200), SceneContent.Load<SpriteFont>("Fonts/curier_new"));
            textbox.SpacingFromBorder = 20;
            textbox.MaxLenght = 15;
            textbox.TextChanged += OnTextChanged;
            AddGuiComponent(label);
            AddGuiComponent(textbox);
            base.LoadContent();
        }
        protected override void LoadContent()
        {
            List<AnimatedTextureRegion> textureRegions = new List<AnimatedTextureRegion>
            {
                new AnimatedTextureRegion("down", 1, 4, 70, 124),
                new AnimatedTextureRegion("left", 2, 4, 70, 124),
                new AnimatedTextureRegion("right", 3, 4, 70, 124),
                new AnimatedTextureRegion("up", 4, 4, 70, 124),
            };
            AnimatedTexture texture1 = new AnimatedTexture(game, SceneContent.Load<Texture2D>("UI image/texture_atlas_example"), textureRegions);
            AnimatedTexture texture2 = new AnimatedTexture(game, SceneContent.Load<Texture2D>("UI image/texture_atlas_example"), textureRegions);
            texture1.Position = new Vector2(0, 0);
            texture1.AnimationSpeed = 500;
            texture2.Position = new Vector2(100, 100);
            texture2.AnimationSpeed = 500;

            player1.AnimatedTexture = texture1;
            player2.AnimatedTexture = texture2;

            AddDrawableGameComponent(player1);
            AddDrawableGameComponent(player2);

            collision2DManager.EnableCollisionDetection = true;

            base.LoadContent();
        }
Beispiel #8
0
 public Button(Game game, string name, AnimatedTexture animatedTexture, List<AnimatedGuiAnimations> animations, Vector2 position)
     : base(game, name, animatedTexture, animations, position)
 {
 }