/// <summary> /// Creates an animation manager /// </summary> /// <param name="p_fps">FpsTimer object onwhich to sync the animations</param> public SpriteManager(FpsTimer p_fps) { fps = p_fps; SpriteManager.globalFps = fps.FPS; fps.Start(); selfTiming = false; }
/// <summary> /// Create DrawManager for a given form /// </summary> /// <param name="p_form">Form to draw on</param> /// <param name="p_fps">FpsTimer object</param> public DrawManager(Control p_form, FpsTimer p_fps) { fpsTimer = p_fps; formBuffer = new FormBuffer(p_form); drawables = new LinkedList <IDrawable>(); fpsTimer.Start(); selfTiming = false; }
public void ShowAnimation(IList<Bitmap> bitmaps, IList<double> delays, bool startPlaying) { fpsTimer = new FpsTimer(60); LoopControl.FpsTimer = fpsTimer; LoopControl.SetAndStartAction(control1, Go); drawManager = null; var myDrawManager = new DrawManager(control1, fpsTimer); if (bitmaps.Count != delays.Count) throw new ArgumentException("must have same number of bitmaps as delays"); IList<Bitmap> oldBitmaps = null; if (flipBook != null ) { oldBitmaps = flipBook.Bitmaps; } spriteManager = new SpriteManager(fpsTimer); sprite = new JustSitThereSprite(new Point(0, 0)); if (flipBook != null) { flipBook.FrameChanged -= flipBook_FrameChanged; } flipBook = new FlipBook(bitmaps, delays); flipBook.Loop = true; flipBook.Paused = true; flipBook.FrameChanged += new EventHandler(flipBook_FrameChanged); sprite.AddAlteration(flipBook); spriteManager.AddObject(sprite); myDrawManager.AddDrawable(spriteManager); playButton.Enabled = true; drawManager = myDrawManager; trackBar1.Minimum = 0; trackBar1.Maximum = bitmaps.Count - 1; trackBar1.Value = 0; if (startPlaying) Play(); if (oldBitmaps != null) { foreach (Bitmap b in oldBitmaps) { b.Dispose(); } } }
private static LoopAction loopAction; // our ptr to the function called in each frame iteration #endregion Fields #region Constructors /// <summary> /// Constructor sets Application.Idle handler /// </summary> static LoopControl() { loopAction = DefaultAction; fpsTimer = null; }
/// <summary> /// Constructor sets Application.Idle handler /// </summary> static LoopControl() { loopAction = DefaultAction; fpsTimer = null; }