Наследование: LectureExamples5.DrawData
        public bool SetupAnimation(AnimationDrawData toConfigure, 
            string animationName)
        {
            AnimationPersistentInfo animationInfo;
            if (!getAnimationInfo(animationName, out animationInfo))
                return false;

            Rectangle source = new Rectangle(
                animationInfo.StartOffset.X, animationInfo.StartOffset.Y,
                animationInfo.FrameWidth, animationInfo.FrameHeight);

            toConfigure.ChangeAnimationData(
                _game.Content.Load<Texture2D>(animationInfo.TexturePath),
                source, animationInfo.NumberOfFrames
                );
            return true;
        }
Пример #2
0
        /// <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.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            _drawable =
                ((AnimationLoader) Services.GetService(
                    typeof (AnimationLoader))).CreateAnimationDrawable("Purple_Up");
            _controller = new AnimationController(_drawable, 0.2f);

            ((IDrawSprites)Services.GetService(typeof(IDrawSprites))
                ).AddDrawable(_drawable);
        }
Пример #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Texture2D blockArt = Content.Load<Texture2D>("Brown Block");
            _spriteSheet = Content.Load<Texture2D>("spritesheet");

            IDrawSprites renderer = (IDrawSprites)
                                    Services.GetService(typeof (IDrawSprites));
            for (int i = 0; i < 20; i++)
            {
                renderer.AddDrawable(new DrawData(
                    blockArt, new Rectangle(
                        blockArt.Bounds.Width * (i%4), //X
                        (i/4)*blockArt.Bounds.Height / 2, //Y
                        blockArt.Bounds.Width,//Width
                        blockArt.Bounds.Height)));//Height
            }
            _sheet = new DrawData(_spriteSheet);
            _sheet.Source = new Rectangle(0,0,24,32);
            _sheet.Destination = new Rectangle(0,0,24*4,32*4);
            renderer.AddDrawable(_sheet);

               AnimationDrawData animated = new AnimationDrawData(
               _spriteSheet, new Rectangle(0,0, 24, 32),
               new Point(100,100),24*4,32*4,3);
            renderer.AddDrawable(animated);
            _controllers.Add(
                new AnimationController(animated, 0.3f));
        }
 public AnimationController(AnimationDrawData data,
     float animationStepTime)
 {
     _drawData = data;
     _stepTime = animationStepTime;
 }