Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fixes to demo game #1506

Merged
merged 2 commits into from
Oct 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/game/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ class GameDemoState extends State<GameDemo> {
width: 128.0,
height: 128.0
),
new Text(
"Last Score: $_lastScore",
new DefaultTextStyle(
child: new Text(
"Last Score: $_lastScore"
),
style: new TextStyle(fontSize:20.0)
)
],
Expand Down
74 changes: 65 additions & 9 deletions skysprites/lib/physics_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class PhysicsBody {
PhysicsBody(this.shape, {
this.tag: null,
this.type: PhysicsBodyType.dynamic,
this.density: 1.0,
this.friction: 0.0,
this.restitution: 0.0,
this.isSensor: false,
double density: 1.0,
double friction: 0.0,
double restitution: 0.0,
bool isSensor: false,
this.linearVelocity: Offset.zero,
this.angularVelocity: 0.0,
this.linearDampening: 0.0,
Expand All @@ -23,18 +23,74 @@ class PhysicsBody {
this.bullet: false,
this.active: true,
this.gravityScale: 1.0
});
}) {
this.density = density;
this.friction = friction;
this.restitution = restitution;
this.isSensor = isSensor;
}

Object tag;

PhysicsShape shape;

PhysicsBodyType type;

double density;
double friction;
double restitution;
bool isSensor;
double _density;

double get density => _density;

set density(double density) {
_density = density;

if (_body == null)
return;
for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
f.setDensity(density);
}
}

double _friction;

double get friction => _friction;

set friction(double friction) {
_friction = friction;

if (_body == null)
return;
for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually put a space after for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, will add

f.setFriction(friction);
}
}

double _restitution;

double get restitution => _restitution;

set restitution(double restitution) {
_restitution = restitution;

if (_body == null)
return;
for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
f.setRestitution(restitution);
}
}

bool _isSensor;

bool get isSensor => _isSensor;

set isSensor(bool isSensor) {
_isSensor = isSensor;

if (_body == null)
return;
for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
f.setSensor(isSensor);
}
}

Offset linearVelocity;
double angularVelocity;
Expand Down