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
dd568690
Commit
dd568690
authored
Oct 14, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1614 from vlidholt/master
Adds missing sprite physics shapes
parents
1beda0d6
29f2a0f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
1 deletion
+75
-1
physics_shape.dart
packages/flutter_sprites/lib/src/physics_shape.dart
+75
-1
No files found.
packages/flutter_sprites/lib/src/physics_shape.dart
View file @
dd568690
...
...
@@ -32,7 +32,6 @@ class PhysicsShapeCircle extends PhysicsShape {
}
class
PhysicsShapePolygon
extends
PhysicsShape
{
PhysicsShapePolygon
(
this
.
points
);
final
List
<
Point
>
points
;
...
...
@@ -53,6 +52,81 @@ class PhysicsShapePolygon extends PhysicsShape {
}
}
class
PhysicsShapeBox
extends
PhysicsShape
{
PhysicsShapeBox
(
this
.
width
,
this
.
height
,
[
this
.
center
=
Point
.
origin
,
this
.
rotation
=
0.0
]);
final
double
width
;
final
double
height
;
final
Point
center
;
final
double
rotation
;
box2d
.
Shape
_createB2Shape
(
PhysicsNode
node
)
{
box2d
.
PolygonShape
shape
=
new
box2d
.
PolygonShape
();
shape
.
setAsBox
(
width
/
node
.
b2WorldToNodeConversionFactor
,
height
/
node
.
b2WorldToNodeConversionFactor
,
new
Vector2
(
center
.
x
/
node
.
b2WorldToNodeConversionFactor
,
center
.
y
/
node
.
b2WorldToNodeConversionFactor
),
radians
(
rotation
)
);
return
shape
;
}
}
class
PhysicsShapeChain
extends
PhysicsShape
{
PhysicsShapeChain
(
this
.
points
,
[
this
.
loop
=
false
]);
final
List
<
Point
>
points
;
final
bool
loop
;
box2d
.
Shape
_createB2Shape
(
PhysicsNode
node
)
{
List
<
Vector2
>
vectors
=
[];
for
(
Point
point
in
points
)
{
Vector2
vec
=
new
Vector2
(
point
.
x
/
node
.
b2WorldToNodeConversionFactor
,
point
.
y
/
node
.
b2WorldToNodeConversionFactor
);
vectors
.
add
(
vec
);
}
box2d
.
ChainShape
shape
=
new
box2d
.
ChainShape
();
if
(
loop
)
shape
.
createLoop
(
vectors
,
vectors
.
length
);
else
shape
.
createChain
(
vectors
,
vectors
.
length
);
return
shape
;
}
}
class
PhysicsShapeEdge
extends
PhysicsShape
{
PhysicsShapeEdge
(
this
.
pointA
,
this
.
pointB
);
final
Point
pointA
;
final
Point
pointB
;
box2d
.
Shape
_createB2Shape
(
PhysicsNode
node
)
{
box2d
.
EdgeShape
shape
=
new
box2d
.
EdgeShape
();
shape
.
set
(
new
Vector2
(
pointA
.
x
/
node
.
b2WorldToNodeConversionFactor
,
pointA
.
y
/
node
.
b2WorldToNodeConversionFactor
),
new
Vector2
(
pointB
.
x
/
node
.
b2WorldToNodeConversionFactor
,
pointB
.
y
/
node
.
b2WorldToNodeConversionFactor
)
);
return
shape
;
}
}
class
PhysicsShapeGroup
extends
PhysicsShape
{
PhysicsShapeGroup
(
this
.
shapes
);
...
...
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