public Player() { bmp = new AnimatedBitmap(15, 23, 8, false); bmp.AddState("assets/objects/player_run", "run", true); bmp.AddState("assets/objects/player", "stay", true); bmp.SetState("run"); AddChild(bmp); }
public static AnimatedBitmap CreateAnimation(Image[] frames, int[] delays) { var sequences = frames.Select((t, i) => new Sequence { Image = t, Delay = delays[i] }).ToArray(); var animated = new AnimatedBitmap(sequences); return(animated); }
public Bug(MovingObject target) : base(target) { bmp = new AnimatedBitmap(10, 10, 14, false); bmp.AddState("assets/objects/zombie_2-2", "stay", true); bmp.AddState("assets/objects/zombie_2", "run", true); bmp.SetState("stay"); AddChild(bmp); hp = 50; }
public Zombie(MovingObject target) : base(target) { bmp = new AnimatedBitmap(16, 23, 14, false); bmp.AddState("assets/objects/zombie_1-2", "stay", true); bmp.AddState("assets/objects/zombie_1", "run", true); bmp.SetState("stay"); AddChild(bmp); hp = 100; }
private void UpdateAnimatedBitmap() { var frameCount = AnimatedBitmap.GetFrameCount(FrameDimension.Time); _currentFrame = 0; if (frameCount > 0) { _bitmapSources = new BitmapSource[frameCount]; for (var i = 0; i < frameCount; i++) { AnimatedBitmap.SelectActiveFrame(FrameDimension.Time, i); var bitmap = new Bitmap(AnimatedBitmap); bitmap.MakeTransparent(); _bitmapSources[i] = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } StartAnimate(); } }
public static void SetAnimatedBackground(this Control control, AnimatedBitmap bitmap) { control.BackgroundImage = bitmap; control.StartAnimation(); }