Esempio n. 1
0
        /// <summary>
        /// Add frame to frame list
        /// </summary>
        /// <param name="frame"></param>
        public void AddFrame(Frame frame)
        {
            frames.Add(frame);

            currentFrame = 0;

            Sprite = frames[(int)currentFrame].Sprite;

            Enabled = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Remove frame from frame list
        /// </summary>
        /// <param name="frame"></param>
        public void RemoveFrame(Frame frame)
        {
            frames.Remove(frame);

            if (frames.Count == 0)
            {
                currentFrame = null;
                Sprite = null;
                Enabled = false;
            }

            frameTimeEllapsed = 0;
        }
Esempio n. 3
0
        /// <summary>
        /// This method create viewer with animation frames. 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isVisible"></param>
        /// <returns></returns>
        private Animation CreateAnimatedViewer(Int32 id, Boolean isVisible)
        {
            List<Frame> animation = new List<Frame>();

            foreach (ResourceFrame frame in tmxAnimations[id])
            {
                ResourceImage resImg = tmxTilesetsImages[frame.Key];

                Frame nFrame = new Frame(new Sprite(resImg.Image), frame.Duration);

                animation.Add(nFrame);

                WriteImageToResources(resImg);
            }

            return new Animation(animation);
        }
Esempio n. 4
0
        public void BuildBoom(Locator locator, Vector size, List<BitmapImage> frames)
        {
            Action action = () =>
            {
                Animation Boom = new Animation();

                foreach (BitmapImage image in frames)
                {
                    Frame frame = new Frame(new Sprite(image), 10);
                    Boom.AddFrame(frame);
                }

                Explosion explosion = new Explosion("boom");

                explosion.LocalCenter = locator.Center;
                explosion.LocalAngle =  locator.Angle;
                explosion.LocalZIndex = locator.ZIndex;

                explosion.Viewer = Boom;

                explosion.Size = size;

                explosion.CollisionShape = CollisionShape.None;

                explosion.LocationChanged += map.UpdateObject;
                explosion.Crashed += map.RemoveObject;
            
                map.AddObject(explosion);      
            };


            if (!Application.Current.Dispatcher.CheckAccess())
            {
                 Application.Current.Dispatcher.Invoke(action);
            }
            else
            {
                 action();
            }

        }