Adds small explosions to demo game

This commit is contained in:
Viktor Lidholt 2015-09-01 15:30:39 -07:00
parent 6de024f0d1
commit 37d0c1a8d8
2 changed files with 28 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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) {