mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #345 from vlidholt/master
Fixes analyzer warnings in sprites
This commit is contained in:
commit
6dc4bc32ff
@ -561,9 +561,10 @@ class Laser extends Sprite {
|
||||
|
||||
// Background starfield
|
||||
|
||||
class StarField extends Node {
|
||||
Image _image;
|
||||
class StarField extends NodeWithSize {
|
||||
sky.Image _image;
|
||||
int _numStars;
|
||||
bool _autoScroll;
|
||||
List<Point> _starPositions;
|
||||
List<double> _starScales;
|
||||
List<Rect> _rects;
|
||||
@ -573,7 +574,7 @@ class StarField extends Node {
|
||||
..isAntiAlias = false
|
||||
..setTransferMode(sky.TransferMode.plus);
|
||||
|
||||
StarField(SpriteSheet spriteSheet, this._numStars) {
|
||||
StarField(SpriteSheet spriteSheet, this._numStars, [this._autoScroll = false]) : super(new Size(1024.0, 1024.0)) {
|
||||
_starPositions = [];
|
||||
_starScales = [];
|
||||
_colors = [];
|
||||
@ -618,6 +619,12 @@ class StarField extends Node {
|
||||
_starPositions[i] = new Point(xPos, yPos);
|
||||
}
|
||||
}
|
||||
|
||||
void update(double dt) {
|
||||
if (_autoScroll) {
|
||||
move(dt * 100.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Hud extends NodeWithSize {
|
||||
|
||||
@ -416,7 +416,7 @@ class Node {
|
||||
}
|
||||
|
||||
void _prePaint(PaintingCanvas canvas) {
|
||||
_savedTotalMatrix = canvas.getTotalMatrix();
|
||||
_savedTotalMatrix = new Matrix4.fromFloat32List(canvas.getTotalMatrix());;
|
||||
|
||||
// Get the transformation matrix and apply transform
|
||||
canvas.concat(transformMatrix.storage);
|
||||
@ -467,7 +467,7 @@ class Node {
|
||||
}
|
||||
|
||||
void _postPaint(PaintingCanvas canvas) {
|
||||
canvas.setMatrix(_savedTotalMatrix);
|
||||
canvas.setMatrix(_savedTotalMatrix.storage);
|
||||
}
|
||||
|
||||
// Receiving update calls
|
||||
|
||||
@ -68,7 +68,7 @@ class Sprite extends NodeWithSize {
|
||||
|
||||
void paint(PaintingCanvas canvas) {
|
||||
// Store old matrix
|
||||
Matrix4 savedMatrix = canvas.getTotalMatrix();
|
||||
Matrix4 savedMatrix = new Matrix4.fromFloat32List(canvas.getTotalMatrix());
|
||||
|
||||
// Account for pivot point
|
||||
applyTransformForPivot(canvas);
|
||||
@ -113,6 +113,6 @@ class Sprite extends NodeWithSize {
|
||||
}
|
||||
|
||||
// Restore matrix
|
||||
canvas.setMatrix(savedMatrix);
|
||||
canvas.setMatrix(savedMatrix.storage);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user