From 37d0c1a8d88bcc1aec5ed39bb71eaf83fb844420 Mon Sep 17 00:00:00 2001 From: Viktor Lidholt Date: Tue, 1 Sep 2015 15:30:39 -0700 Subject: [PATCH] Adds small explosions to demo game --- examples/game/lib/explosions.dart | 24 ++++++++++++++++++++++++ examples/game/lib/game_objects.dart | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/examples/game/lib/explosions.dart b/examples/game/lib/explosions.dart index 9a8290e7a90..73c5bec8787 100644 --- a/examples/game/lib/explosions.dart +++ b/examples/game/lib/explosions.dart @@ -81,5 +81,29 @@ class ExplosionBig extends Explosion { } class ExplosionMini extends Explosion { + ExplosionMini(SpriteSheet sheet) { + for (int i = 0; i < 2; i++) { + Sprite star = new Sprite(sheet["star_0.png"]); + star.scale = 0.5; + star.colorOverlay = new Color(0xff95f4fb); + star.transferMode = sky.TransferMode.plus; + addChild(star); + double rotationStart = randomDouble() * 90.0; + double rotationEnd = 180.0 + randomDouble() * 90.0; + if (i == 0) { + rotationStart = -rotationStart; + rotationEnd = -rotationEnd; + } + + ActionTween rotate = new ActionTween((a) => star.rotation = a, rotationStart, rotationEnd, 0.2); + actions.run(rotate); + + ActionTween fade = new ActionTween((a) => star.opacity = a, 1.0, 0.0, 0.2); + actions.run(fade); + } + + ActionSequence seq = new ActionSequence([new ActionDelay(0.2), new ActionRemoveNode(this)]); + actions.run(seq); + } } diff --git a/examples/game/lib/game_objects.dart b/examples/game/lib/game_objects.dart index 582d9108bad..fca5096f3d2 100644 --- a/examples/game/lib/game_objects.dart +++ b/examples/game/lib/game_objects.dart @@ -165,6 +165,10 @@ class Laser extends GameObject { void move() { position += _offset; } + + Explosion createExplosion() { + return new ExplosionMini(f.sheet); + } } Color colorForDamage(double damage, double maxDamage) {