Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ed81aa6b
Commit
ed81aa6b
authored
Aug 03, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactors matrix handling in sprites
parent
dc9a4ccd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
node.dart
packages/flutter/example/game/lib/node.dart
+13
-10
No files found.
packages/flutter/example/game/lib/node.dart
View file @
ed81aa6b
...
...
@@ -102,7 +102,7 @@ class Node {
void
set
rotation
(
double
rotation
)
{
assert
(
rotation
!=
null
);
_rotation
=
rotation
;
_
invalidateTransformMatrix
();
invalidateTransformMatrix
();
}
/// The position of this node relative to its parent.
...
...
@@ -113,7 +113,7 @@ class Node {
void
set
position
(
Point
position
)
{
assert
(
position
!=
null
);
_position
=
position
;
_
invalidateTransformMatrix
();
invalidateTransformMatrix
();
}
/// The draw order of this node compared to its parent and its siblings.
...
...
@@ -147,7 +147,7 @@ class Node {
void
set
scale
(
double
scale
)
{
assert
(
scale
!=
null
);
_scaleX
=
_scaleY
=
scale
;
_
invalidateTransformMatrix
();
invalidateTransformMatrix
();
}
/// The horizontal scale of this node relative its parent.
...
...
@@ -158,7 +158,7 @@ class Node {
void
set
scaleX
(
double
scaleX
)
{
assert
(
scaleX
!=
null
);
_scaleX
=
scaleX
;
_
invalidateTransformMatrix
();
invalidateTransformMatrix
();
}
/// The vertical scale of this node relative its parent.
...
...
@@ -169,7 +169,7 @@ class Node {
void
set
scaleY
(
double
scaleY
)
{
assert
(
scaleY
!=
null
);
_scaleY
=
scaleY
;
_
invalidateTransformMatrix
();
invalidateTransformMatrix
();
}
/// A list of the children of this node.
...
...
@@ -264,10 +264,13 @@ class Node {
///
/// Matrix4 matrix = myNode.transformMatrix;
Matrix4
get
transformMatrix
{
if
(
_transformMatrix
!=
null
)
{
if
(
_transformMatrix
==
null
)
{
_transformMatrix
=
computeTransformMatrix
();
}
return
_transformMatrix
;
}
Matrix4
computeTransformMatrix
()
{
double
cx
,
sx
,
cy
,
sy
;
if
(
_rotation
==
0.0
)
{
...
...
@@ -287,15 +290,15 @@ class Node {
}
// Create transformation matrix for scale, position and rotation
_transformM
atrix
=
new
Matrix4
(
cy
*
_scaleX
,
sy
*
_scaleX
,
0.0
,
0.0
,
Matrix4
m
atrix
=
new
Matrix4
(
cy
*
_scaleX
,
sy
*
_scaleX
,
0.0
,
0.0
,
-
sx
*
_scaleY
,
cx
*
_scaleY
,
0.0
,
0.0
,
0.0
,
0.0
,
1.0
,
0.0
,
_position
.
x
,
_position
.
y
,
0.0
,
1.0
);
return
_transformM
atrix
;
return
m
atrix
;
}
void
_
invalidateTransformMatrix
()
{
void
invalidateTransformMatrix
()
{
_transformMatrix
=
null
;
_invalidateToBoxTransformMatrix
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment