public bool updateMemoryCallback(FlxTimer Timer) { _buffer = ((GC.GetTotalMemory(false) / 1024f) / 1024f).ToString("0.00"); _memoryUsage.text = _buffer + " Mb"; updateMemoryUsage(); return(true); }
void ResetTimer(FlxTimer timer = null) { if (!_snakeHead.Alive && timer != null) { timer.Dispose(); return; } new FlxTimer().Start(_movementInterval / FlxG.UpdateFrameRate, ResetTimer); MoveSnake(); }
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(); }