public void Add(SpriteSheet otherSheet)
 {
     foreach (var sprite in otherSheet.spriteList)
     {
         spriteList.Add(sprite);
     }
 }
Beispiel #2
0
 public AnimatedTexture(GraphicsDevice graphicsDevice, int width, int height, double milisecondsPerFrame, SpriteSheet spriteSheet, List<string> frames)
     : base(graphicsDevice, width, height)
 {
     this.spriteSheet = spriteSheet;
     this.frames = frames;
     this.milisecondsPerFrame = milisecondsPerFrame;
     ended = false;
 }
        public SpriteSheet MultiLoad(string imageResourceFormat, int numSheets)
        {
            SpriteSheet result = new SpriteSheet();
            for (int i = 0; i < numSheets; i++)
            {
                string imageResource = string.Format(imageResourceFormat, i);

                SpriteSheet tmp = Load(imageResource);
                result.Add(tmp);
            }
            return result;
        }
Beispiel #4
0
 public static void Load(Microsoft.Xna.Framework.Content.ContentManager Content)
 {
     background = Content.Load<Texture2D>("Images/background");
     dialogBackground = Content.Load<Texture2D>("Images/dialogBackground");
     playButton = Content.Load<Texture2D>("Images/playButton");
     okButton = Content.Load<Texture2D>("Images/okButton");
     elements[Element.Type.Blue] = Content.Load<Texture2D>("Images/blue");
     elements[Element.Type.Cyan] = Content.Load<Texture2D>("Images/cyan");
     elements[Element.Type.Grey] = Content.Load<Texture2D>("Images/grey");
     elements[Element.Type.Pink] = Content.Load<Texture2D>("Images/pink");
     elements[Element.Type.Red] = Content.Load<Texture2D>("Images/red");
     elements[Element.Type.Yellow] = Content.Load<Texture2D>("Images/yellow");
     font = Content.Load<SpriteFont>("font");
     var spriteSheetLoader = new SpriteSheetLoader(Content);
     glowingBall = spriteSheetLoader.Load("Images/glowingBall");
     explosion = spriteSheetLoader.Load("Images/Explosion");
     bombBonus = spriteSheetLoader.Load("Images/bombBonus");
 }
        public SpriteSheet Load(string imageResource)
        {
            var texture = this.contentManager.Load<Texture2D>(imageResource);

            var dataFile = Path.Combine(
                this.contentManager.RootDirectory,
                Path.ChangeExtension(imageResource, "txt"));

            var dataFileLines = this.ReadDataFile(dataFile);

            var sheet = new SpriteSheet();
            CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
            ci.NumberFormat.CurrencyDecimalSeparator = ".";
            foreach (
                var cols in
                    from row in dataFileLines
                    where !string.IsNullOrEmpty(row) && !row.StartsWith("#")
                    select row.Split(';'))
            {
                if (cols.Length != 10)
                {
                    throw new InvalidDataException("Incorrect format data in spritesheet data file");
                }
                
                var isRotated = int.Parse (cols [1]) == 1;
                var name = cols[0];
                var sourceRectangle = new Rectangle(
                    int.Parse(cols[2]),
                    int.Parse(cols[3]),
                    int.Parse(cols[4]),
                    int.Parse(cols[5]));
                var size = new Vector2(
                    int.Parse(cols[6]),
                    int.Parse(cols[7]));
                var pivotPoint = new Vector2(
                    float.Parse(cols[8], NumberStyles.Any, ci),
                    float.Parse(cols[9], NumberStyles.Any, ci));
                var sprite = new SpriteFrame(texture, sourceRectangle, size, pivotPoint, isRotated);

                sheet.Add(name, sprite);
            }

            return sheet;
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            this.spriteBatch = new SpriteBatch(GraphicsDevice);
            this.spriteRender = new SpriteRender(this.spriteBatch);

            var spriteSheetLoader = new SpriteSheetLoader(this.Content);
            this.spriteSheet = spriteSheetLoader.Load("CapGuyDemo.png");
            this.backgroundSprite = this.spriteSheet.Sprite(TexturePackerMonoGameDefinitions.CapGuyDemo.Background);
            this.centreScreen = new Vector2 (this.GraphicsDevice.Viewport.Width / 2, this.GraphicsDevice.Viewport.Height / 2);

            this.InitialiseAnimationManager();
        }
 public AnimationManager(SpriteSheet spriteSheet, Vector2 initialPosition, Animation[] animations)
 {
     this.spriteSheet = spriteSheet;
     this.animations = animations;
     this.currentPosition = initialPosition;
 }