Ejemplo n.º 1
0
        public AttackAnimation(ContentManager content, String attackName, String animationName, int x, int y, int cellSize)
        {
            AttackName = attackName;

            _animations = new Dictionary <string, Animation>()
            {
                { attackName, new Animation(content.Load <Texture2D>("spells/" + animationName), 3) }
            };

            _animationManager = new AnimationManager(_animations.First().Value);
            int newx = x * cellSize + cellSize / 2 - _animationManager.getCurrentFrameRectangle().Width / 2;
            int newy = y * cellSize + cellSize / 2 - _animationManager.getCurrentFrameRectangle().Height / 2;

            _animationManager.Position = new Vector2(newx, newy);
        }
        public Color[] getCurrentTextureData(GraphicsDevice graphicsDevice)
        {
            Texture2D multipleSpriteTexture = _animationManager._animation.Texture;

            Rectangle toCropRectangle = _animationManager.getCurrentFrameRectangle();

            Color[] singleTextureData = new Color[toCropRectangle.Width * toCropRectangle.Height];
            multipleSpriteTexture.GetData(0, toCropRectangle, singleTextureData, 0, singleTextureData.Length);

            return(singleTextureData);
        }