Commit 6a6567d7 authored by Viktor Lidholt's avatar Viktor Lidholt

Fixes formatting and removes redundant code in sprites

parent 972417f5
...@@ -631,7 +631,10 @@ class Hud extends NodeWithSize { ...@@ -631,7 +631,10 @@ class Hud extends NodeWithSize {
} }
void _updateHud() { void _updateHud() {
sprtBgScore.removeAllChildren();
String scoreStr = _score.toString();
} }
} }
......
...@@ -70,7 +70,8 @@ class SpriteBox extends RenderBox { ...@@ -70,7 +70,8 @@ class SpriteBox extends RenderBox {
Rect _visibleArea; Rect _visibleArea;
Rect get visibleArea { Rect get visibleArea {
if (_visibleArea == null) _calcTransformMatrix(); if (_visibleArea == null)
_calcTransformMatrix();
return _visibleArea; return _visibleArea;
} }
...@@ -135,7 +136,8 @@ class SpriteBox extends RenderBox { ...@@ -135,7 +136,8 @@ class SpriteBox extends RenderBox {
// Add childrens that are behind this node // Add childrens that are behind this node
while (i < children.length) { while (i < children.length) {
Node child = children[i]; Node child = children[i];
if (child.zPosition >= 0.0) break; if (child.zPosition >= 0.0)
break;
_addEventTargets(child, eventTargets); _addEventTargets(child, eventTargets);
i++; i++;
} }
...@@ -154,7 +156,8 @@ class SpriteBox extends RenderBox { ...@@ -154,7 +156,8 @@ class SpriteBox extends RenderBox {
} }
void handleEvent(Event event, _SpriteBoxHitTestEntry entry) { void handleEvent(Event event, _SpriteBoxHitTestEntry entry) {
if (!attached) return; if (!attached)
return;
if (event is PointerEvent) { if (event is PointerEvent) {
...@@ -191,7 +194,8 @@ class SpriteBox extends RenderBox { ...@@ -191,7 +194,8 @@ class SpriteBox extends RenderBox {
if (node.handleMultiplePointers || event.pointer == node._handlingPointer) { if (node.handleMultiplePointers || event.pointer == node._handlingPointer) {
// Dispatch event // Dispatch event
bool consumedEvent = node.handleEvent(new SpriteBoxEvent(new Point(event.x, event.y), event.type, event.pointer)); bool consumedEvent = node.handleEvent(new SpriteBoxEvent(new Point(event.x, event.y), event.type, event.pointer));
if (consumedEvent == null || consumedEvent) break; if (consumedEvent == null || consumedEvent)
break;
} }
} }
...@@ -317,7 +321,8 @@ class SpriteBox extends RenderBox { ...@@ -317,7 +321,8 @@ class SpriteBox extends RenderBox {
} }
void _tick(double timeStamp) { void _tick(double timeStamp) {
if (!attached) return; if (!attached)
return;
// Calculate the time between frames in seconds // Calculate the time between frames in seconds
if (_lastTimeStamp == null) _lastTimeStamp = timeStamp; if (_lastTimeStamp == null) _lastTimeStamp = timeStamp;
...@@ -330,7 +335,8 @@ class SpriteBox extends RenderBox { ...@@ -330,7 +335,8 @@ class SpriteBox extends RenderBox {
_frameRate = 1.0/delta; _frameRate = 1.0/delta;
// Print frame rate // Print frame rate
if (_numFrames % 60 == 0) print("delta: $delta fps: $_frameRate"); if (_numFrames % 60 == 0)
print("delta: $delta fps: $_frameRate");
_runActions(_rootNode, delta); _runActions(_rootNode, delta);
_callUpdate(_rootNode, delta); _callUpdate(_rootNode, delta);
......
...@@ -85,7 +85,6 @@ class GameDemoApp extends App { ...@@ -85,7 +85,6 @@ class GameDemoApp extends App {
} }
Widget _buildGameScene(navigator, route) { Widget _buildGameScene(navigator, route) {
if (_game == null) _game = new GameDemoWorld(_app, navigator, _loader, _spriteSheet);
return new SpriteWidget(_game); return new SpriteWidget(_game);
} }
...@@ -101,7 +100,3 @@ class GameDemoApp extends App { ...@@ -101,7 +100,3 @@ class GameDemoApp extends App {
); );
} }
} }
void resetGame() {
_app.scheduleBuild();
}
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