Commit 4b3b5eb4 authored by Viktor Lidholt's avatar Viktor Lidholt

Fixes analyzer warnings in SpriteBox

parent 122add43
...@@ -48,9 +48,10 @@ class SpriteBox extends RenderBox { ...@@ -48,9 +48,10 @@ class SpriteBox extends RenderBox {
// Tracking of frame rate and updates // Tracking of frame rate and updates
double _lastTimeStamp; double _lastTimeStamp;
int _numFrames = 0;
double _frameRate = 0.0; double _frameRate = 0.0;
double get frameRate => _frameRate;
// Transformation mode // Transformation mode
SpriteBoxTransformMode _transformMode; SpriteBoxTransformMode _transformMode;
...@@ -342,20 +343,13 @@ class SpriteBox extends RenderBox { ...@@ -342,20 +343,13 @@ class SpriteBox extends RenderBox {
if (!attached) if (!attached)
return; return;
// Calculate the time between frames in seconds // Calculate delta and frame rate
if (_lastTimeStamp == null) _lastTimeStamp = timeStamp; if (_lastTimeStamp == null) _lastTimeStamp = timeStamp;
double delta = (timeStamp - _lastTimeStamp) / 1000; double delta = (timeStamp - _lastTimeStamp) / 1000;
_lastTimeStamp = timeStamp; _lastTimeStamp = timeStamp;
// Count the number of frames we've been running
_numFrames += 1;
_frameRate = 1.0/delta; _frameRate = 1.0/delta;
// // Print frame rate
// if (_numFrames % 60 == 0)
// print("delta: $delta fps: $_frameRate");
_runActions(delta); _runActions(delta);
_callUpdate(_rootNode, delta); _callUpdate(_rootNode, delta);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment