public override void create ()
		{

			FlxG.debug = true;
					
			// The grass background
			FlxSprite grass = new FlxSprite (0, 0).loadGraphic (ImgGrass, false, false, FlxG.width, FlxG.height);
			add (grass);

			add (_bunnies = new FlxGroup ());
			
			
			// Text display
			add (_bunnyCounter = new FlxText (0, FlxG.height - 20, FlxG.width).setFormat (null, 8, Color.White, "right", Color.Black));
			add (_memoryUsage = new FlxText (5, FlxG.height - 20, 200).setFormat (null, 8, Color.White, "left", Color.Black));
			
			// Buttons Left side
			float leftBtnY = 20;

			add (new FlxButton (leftBtnY, 25, "+" + INITIAL_AMOUNT, addBunnies));
			add (new FlxButton (leftBtnY, 50, "-" + INITIAL_AMOUNT, removeBunnies));
			
			// Buttons right side
			float rightBtnX = FlxG.width - 100;
			add (_complexityButton = new FlxButton (rightBtnX, 25, "Complex", ComplexityCallback));			
			add (_collisionButton = new FlxButton (rightBtnX, 65, "Collision ON", CollisionCallback));			
			
			// Finally create the bunnies
			addBunnies ();
			
			// Force GC
			GC.Collect ();
			
			// Timer to update the memory usage
			_memoryTimer = new FlxTimer ();
			updateMemoryUsage ();

			// Show mouse pointer
			FlxG.mouse.show ();
		}
Exemple #2
0
        /**
         * Remove a timer from the timer manager. Usually called automatically by
         * <code>FlxTimer</code>'s <code>stop()</code> function.
         *
         * @param Timer The <code>FlxTimer</code> you want to remove from the
         *        manager.
         */
        public void remove(FlxTimer Timer)
        {
            int index = _timers.IndexOf(Timer);

            if (index >= 0)
            {
                _timers.RemoveAt(index);
            }
        }
		public bool updateMemoryCallback (FlxTimer Timer)
		{
			_buffer = ((GC.GetTotalMemory (false) / 1024f) / 1024f).ToString ("0.00");
			_memoryUsage.text = _buffer + " Mb";

			updateMemoryUsage ();
			return true;
		}
Exemple #4
0
 /**
  * Add a new timer to the timer manager. Usually called automatically by
  * <code>FlxTimer</code>'s constructor.
  *
  * @param Timer The <code>FlxTimer</code> you want to add to the manager.
  */
 public void add(FlxTimer Timer)
 {
     _timers.Add(Timer);
 }
Exemple #5
0
 /**
  * Remove a timer from the timer manager. Usually called automatically by
  * <code>FlxTimer</code>'s <code>stop()</code> function.
  *
  * @param Timer The <code>FlxTimer</code> you want to remove from the
  *        manager.
  */
 public void remove(FlxTimer Timer)
 {
     int index = _timers.IndexOf (Timer);
     if (index >= 0)
         _timers.RemoveAt (index);
 }
Exemple #6
0
 /**
  * Add a new timer to the timer manager. Usually called automatically by
  * <code>FlxTimer</code>'s constructor.
  *
  * @param Timer The <code>FlxTimer</code> you want to add to the manager.
  */
 public void add(FlxTimer Timer)
 {
     _timers.Add (Timer);
 }