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
ca724ae1
Commit
ca724ae1
authored
Oct 20, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds support for scaling sprite physics groups
parent
4187bcf9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
test_physics.dart
examples/game/test_physics.dart
+3
-1
node.dart
packages/flutter_sprites/lib/src/node.dart
+15
-3
No files found.
examples/game/test_physics.dart
View file @
ca724ae1
...
...
@@ -51,6 +51,8 @@ class TestBed extends NodeWithSize {
TestBed
()
:
super
(
new
Size
(
1024.0
,
1024.0
))
{
_physicsNode
=
new
PhysicsWorld
(
new
Offset
(
0.0
,
100.0
));
PhysicsGroup
group
=
new
PhysicsGroup
();
_physicsNode
.
addChild
(
group
);
_obstacle
=
new
Sprite
(
_spriteSheet
[
"ship.png"
]);
_obstacle
.
position
=
new
Point
(
512.0
,
800.0
);
...
...
@@ -62,7 +64,7 @@ class TestBed extends NodeWithSize {
friction:
0.5
,
tag:
"obstacle"
);
_physicsNode
.
addChild
(
_obstacle
);
group
.
addChild
(
_obstacle
);
_physicsNode
.
addContactCallback
(
myCallback
,
"obstacle"
,
"ship"
,
PhysicsContactType
.
begin
);
// Animate obstacle
...
...
packages/flutter_sprites/lib/src/node.dart
View file @
ca724ae1
...
...
@@ -277,15 +277,27 @@ class Node {
void
set
scale
(
double
scale
)
{
assert
(
scale
!=
null
);
if
(
_physicsBody
!=
null
&&
parent
is
PhysicsWorld
)
{
PhysicsWorld
physicsNode
=
parent
;
physicsNode
.
_updateScale
(
this
.
physicsBody
,
scale
);
if
(
_physicsBody
!=
null
&&
(
parent
is
PhysicsWorld
||
parent
is
PhysicsGroup
))
{
_updatePhysicsScale
(
physicsBody
,
scale
,
parent
);
}
_scaleX
=
_scaleY
=
scale
;
invalidateTransformMatrix
();
}
void
_updatePhysicsScale
(
PhysicsBody
body
,
double
scale
,
Node
physicsParent
)
{
if
(
physicsParent
==
null
)
return
;
if
(
physicsParent
is
PhysicsWorld
)
{
PhysicsWorld
world
=
physicsParent
;
world
.
_updateScale
(
body
,
scale
);
}
else
if
(
physicsParent
is
PhysicsGroup
)
{
_updatePhysicsScale
(
body
,
scale
*
physicsParent
.
scale
,
physicsParent
.
parent
);
}
else
{
assert
(
false
);
}
}
/// The horizontal scale of this node relative its parent.
///
/// myNode.scaleX = 5.0;
...
...
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