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
46415fa0
Commit
46415fa0
authored
Oct 15, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remember last position in sprite physics
parent
f1642892
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
physics_body.dart
packages/flutter_sprites/lib/src/physics_body.dart
+3
-0
physics_node.dart
packages/flutter_sprites/lib/src/physics_node.dart
+6
-0
No files found.
packages/flutter_sprites/lib/src/physics_body.dart
View file @
46415fa0
...
@@ -40,6 +40,9 @@ class PhysicsBody {
...
@@ -40,6 +40,9 @@ class PhysicsBody {
this
.
active
=
active
;
this
.
active
=
active
;
}
}
Vector2
_lastPosition
;
double
_lastRotation
;
Object
tag
;
Object
tag
;
final
PhysicsShape
shape
;
final
PhysicsShape
shape
;
...
...
packages/flutter_sprites/lib/src/physics_node.dart
View file @
46415fa0
...
@@ -113,6 +113,9 @@ class PhysicsNode extends Node {
...
@@ -113,6 +113,9 @@ class PhysicsNode extends Node {
}
}
void
_updatePosition
(
PhysicsBody
body
,
Point
position
)
{
void
_updatePosition
(
PhysicsBody
body
,
Point
position
)
{
if
(
body
.
_lastPosition
==
null
)
body
.
_lastPosition
=
body
.
_body
.
position
;
Vector2
newPos
=
new
Vector2
(
Vector2
newPos
=
new
Vector2
(
position
.
x
/
b2WorldToNodeConversionFactor
,
position
.
x
/
b2WorldToNodeConversionFactor
,
position
.
y
/
b2WorldToNodeConversionFactor
position
.
y
/
b2WorldToNodeConversionFactor
...
@@ -123,6 +126,9 @@ class PhysicsNode extends Node {
...
@@ -123,6 +126,9 @@ class PhysicsNode extends Node {
}
}
void
_updateRotation
(
PhysicsBody
body
,
double
rotation
)
{
void
_updateRotation
(
PhysicsBody
body
,
double
rotation
)
{
if
(
body
.
_lastRotation
==
null
)
body
.
_lastRotation
=
body
.
_body
.
getAngle
();
Vector2
pos
=
body
.
_body
.
position
;
Vector2
pos
=
body
.
_body
.
position
;
double
newAngle
=
radians
(
rotation
);
double
newAngle
=
radians
(
rotation
);
body
.
_body
.
setTransform
(
pos
,
newAngle
);
body
.
_body
.
setTransform
(
pos
,
newAngle
);
...
...
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