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
79c23548
Commit
79c23548
authored
Oct 09, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1562 from vlidholt/master
Adds debug drawing for weld joints in sprite physics
parents
f864ec26
dcad79e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
physics_node.dart
packages/flutter_sprites/lib/physics_node.dart
+49
-0
No files found.
packages/flutter_sprites/lib/physics_node.dart
View file @
79c23548
...
...
@@ -240,7 +240,56 @@ class PhysicsNode extends Node {
}
}
// Draw joints
shapePaint
.
color
=
new
Color
(
0xff0000ff
);
for
(
box2d
.
JointEdge
edge
=
body
.
getJointList
();
edge
!=
null
;
edge
=
edge
.
next
)
{
box2d
.
Joint
joint
=
edge
.
joint
;
// Make sure we only draw each joint once
if
(
joint
.
getBodyB
()
==
body
)
continue
;
// Get anchor A
Vector2
anchorA
=
new
Vector2
.
zero
();
joint
.
getAnchorA
(
anchorA
);
Point
ptAnchorA
=
new
Point
(
anchorA
.
x
*
b2WorldToNodeConversionFactor
,
anchorA
.
y
*
b2WorldToNodeConversionFactor
);
// Get anchor B
Vector2
anchorB
=
new
Vector2
.
zero
();
joint
.
getAnchorB
(
anchorB
);
Point
ptAnchorB
=
new
Point
(
anchorB
.
x
*
b2WorldToNodeConversionFactor
,
anchorB
.
y
*
b2WorldToNodeConversionFactor
);
// Get body A position
Point
ptBodyA
=
new
Point
(
joint
.
getBodyA
().
position
.
x
*
b2WorldToNodeConversionFactor
,
joint
.
getBodyA
().
position
.
y
*
b2WorldToNodeConversionFactor
);
Point
ptBodyB
=
new
Point
(
joint
.
getBodyB
().
position
.
x
*
b2WorldToNodeConversionFactor
,
joint
.
getBodyB
().
position
.
y
*
b2WorldToNodeConversionFactor
);
// Draw the joint depending on type
box2d
.
JointType
type
=
joint
.
getType
();
if
(
type
==
box2d
.
JointType
.
WELD
)
{
// Draw weld joint
canvas
.
drawCircle
(
ptAnchorA
,
5.0
,
shapePaint
);
canvas
.
drawLine
(
ptBodyA
,
ptAnchorA
,
shapePaint
);
canvas
.
drawLine
(
ptAnchorB
,
ptBodyB
,
shapePaint
);
}
}
}
}
}
...
...
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