Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: sky/sdk/example/game/lib/game_demo_world.dart

Issue 1216573009: Adds particle systems to sprites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/example/game/lib/game_demo.dart ('k') | sky/sdk/example/game/lib/particle_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/example/game/lib/game_demo_world.dart
diff --git a/sky/sdk/example/game/lib/game_demo_world.dart b/sky/sdk/example/game/lib/game_demo_world.dart
index 5f2d32351a553d4635ff111a87b7b7f4cc3b8870..a65ed98d979f5d4efdaad38b2c4990ea61d9d99a 100644
--- a/sky/sdk/example/game/lib/game_demo_world.dart
+++ b/sky/sdk/example/game/lib/game_demo_world.dart
@@ -90,6 +90,7 @@ class GameDemoWorld extends NodeWithSize {
void addLaser() {
Laser laser = new Laser(_spriteSheet["laser.png"], _ship);
laser.zPosition = 8.0;
+ laser.constrainProportions = true;
_lasers.add(laser);
_gameLayer.addChild(laser);
}
@@ -98,7 +99,17 @@ class GameDemoWorld extends NodeWithSize {
_nebula = new Nebula.withImage(_imgNebula);
_gameLayer.addChild(_nebula);
}
-
+
+ void addExplosion(AsteroidSize asteroidSize, Point position) {
+ // Add particles
+ ParticleSystem particles = new ParticleSystem(_spriteSheet["laser.png"], rotateToMovement: true,
eseidel 2015/06/30 01:04:50 I'm not sure what the dart style is, but I would h
+ startRotation:90.0, startRotationVar: 0.0, endRotation: 90.0, startSize: 0.2, startSizeVar: 0.1, endSize: 0.2, endSizeVar: 0.1,
+ numParticlesToEmit: 25, emissionRate:1000.0, blueVar: 127);
+ particles.zPosition = 1010.0;
+ particles.position = position;
+ _gameLayer.addChild(particles);
+ }
+
void update(double dt) {
// Move asteroids
for (Asteroid asteroid in _asteroids) {
@@ -138,7 +149,7 @@ class GameDemoWorld extends NodeWithSize {
laser.removeFromParent();
_lasers.removeAt(i);
- // Add asteroids
+ // Add asteroids and explosions
if (asteroid._asteroidSize == AsteroidSize.large) {
for (int a = 0; a < 3; a++) addAsteroid(AsteroidSize.medium, asteroid.position);
}
@@ -146,6 +157,8 @@ class GameDemoWorld extends NodeWithSize {
for (int a = 0; a < 5; a++) addAsteroid(AsteroidSize.small, asteroid.position);
}
+ addExplosion(asteroid._asteroidSize, asteroid.position);
+
// Remove asteroid
asteroid.removeFromParent();
_asteroids.removeAt(j);
@@ -333,10 +346,10 @@ class Ship extends Sprite {
class Laser extends Sprite {
int _frameCount = 0;
Point _movementVector;
- double radius = 10.0;
+ double radius = 20.0;
Laser(Texture img, Ship ship) : super(img) {
- size = new Size(20.0, 20.0);
+ size = new Size(30.0, 30.0);
position = ship.position;
rotation = ship.rotation + 90.0;
transferMode = TransferMode.plus;
« no previous file with comments | « sky/sdk/example/game/lib/game_demo.dart ('k') | sky/sdk/example/game/lib/particle_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698