Fade actions in actionbar when interaction is disabled
This commit is contained in:
parent
3886f99cda
commit
f0228f9846
|
@ -107,11 +107,15 @@ module TS.SpaceTac.UI {
|
|||
* Set the interactivity state
|
||||
*/
|
||||
setInteractive(interactive: boolean) {
|
||||
this.interactive = interactive;
|
||||
if (this.interactive != interactive) {
|
||||
this.interactive = interactive;
|
||||
|
||||
this.game.tweens.removeFrom(this.icon_waiting);
|
||||
this.battleview.animations.setVisible(this.icon_waiting, !this.interactive, 100);
|
||||
this.game.tweens.create(this.icon_waiting).to({ "angle": 360 }, 3000).loop().start();
|
||||
this.game.tweens.removeFrom(this.icon_waiting);
|
||||
this.battleview.animations.setVisible(this.icon_waiting, !this.interactive, 100);
|
||||
this.game.tweens.create(this.icon_waiting).to({ "angle": 360 }, 3000).loop().start();
|
||||
|
||||
this.battleview.animations.setVisible(this.actions, interactive, 100, 1, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,18 +8,18 @@ module TS.SpaceTac.UI.Specs {
|
|||
let ship = nn(testgame.battleview.battle.playing_ship);
|
||||
let sprite = nn(testgame.battleview.arena.findShipSprite(ship));
|
||||
|
||||
expect(sprite.effects.children.length).toBe(0);
|
||||
expect(sprite.effects_messages.children.length).toBe(0);
|
||||
|
||||
sprite.displayValueChanged(new ValueChangeEvent(ship, ship.attributes.power_generation, -4));
|
||||
|
||||
expect(sprite.effects.children.length).toBe(1);
|
||||
let t1 = <Phaser.Text>sprite.effects.getChildAt(0);
|
||||
expect(sprite.effects_messages.children.length).toBe(1);
|
||||
let t1 = <Phaser.Text>sprite.effects_messages.getChildAt(0);
|
||||
expect(t1.text).toBe("power generation -4");
|
||||
|
||||
sprite.displayValueChanged(new ValueChangeEvent(ship, ship.values.shield, 12));
|
||||
|
||||
expect(sprite.effects.children.length).toBe(2);
|
||||
let t2 = <Phaser.Text>sprite.effects.getChildAt(1);
|
||||
expect(sprite.effects_messages.children.length).toBe(2);
|
||||
let t2 = <Phaser.Text>sprite.effects_messages.getChildAt(1);
|
||||
expect(t2.text).toBe("shield +12");
|
||||
});
|
||||
|
||||
|
@ -27,19 +27,19 @@ module TS.SpaceTac.UI.Specs {
|
|||
let ship = nn(testgame.battleview.battle.playing_ship);
|
||||
let sprite = nn(testgame.battleview.arena.findShipSprite(ship));
|
||||
|
||||
expect(sprite.sticky_effects.children.length).toBe(0);
|
||||
expect(sprite.active_effects_display.children.length).toBe(0);
|
||||
|
||||
ship.addStickyEffect(new StickyEffect(new BaseEffect("test")));
|
||||
testgame.battleview.log_processor.jumpToEnd();
|
||||
expect(sprite.sticky_effects.children.length).toBe(1);
|
||||
expect(sprite.active_effects_display.children.length).toBe(1);
|
||||
|
||||
ship.addStickyEffect(new StickyEffect(new BaseEffect("test")));
|
||||
testgame.battleview.log_processor.jumpToEnd();
|
||||
expect(sprite.sticky_effects.children.length).toBe(2);
|
||||
expect(sprite.active_effects_display.children.length).toBe(2);
|
||||
|
||||
ship.cleanStickyEffects();
|
||||
testgame.battleview.log_processor.jumpToEnd();
|
||||
expect(sprite.sticky_effects.children.length).toBe(0);
|
||||
expect(sprite.active_effects_display.children.length).toBe(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,6 +19,20 @@ module TS.SpaceTac.UI.Specs {
|
|||
expect(obj.visible).toBe(true);
|
||||
expect(obj.alpha).toBe(1);
|
||||
expect(testgame.baseview.animations.simulate(obj, 'alpha')).toEqual([1, 0.75, 0.5, 0.25, 0]);
|
||||
|
||||
obj.alpha = 0.2;
|
||||
testgame.baseview.animations.setVisible(obj, true, 1000, 0.6);
|
||||
|
||||
expect(obj.visible).toBe(true);
|
||||
expect(obj.alpha).toBe(0.2);
|
||||
expect(testgame.baseview.animations.simulate(obj, 'alpha')).toEqual([0.2, 0.3, 0.4, 0.5, 0.6]);
|
||||
|
||||
obj.alpha = 0.6;
|
||||
testgame.baseview.animations.setVisible(obj, false, 1000, 0.6, 0.2);
|
||||
|
||||
expect(obj.visible).toBe(true);
|
||||
expect(obj.alpha).toBe(0.6);
|
||||
expect(testgame.baseview.animations.simulate(obj, 'alpha')).toEqual([0.6, 0.5, 0.4, 0.3, 0.2]);
|
||||
});
|
||||
|
||||
it("animates rotation", function () {
|
||||
|
|
|
@ -77,37 +77,39 @@ module TS.SpaceTac.UI {
|
|||
}
|
||||
tween.start();
|
||||
} else {
|
||||
obj.alpha = 1;
|
||||
obj.alpha = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide an object, with opacity transition
|
||||
*/
|
||||
hide(obj: IAnimationFadeable, duration = 1000): void {
|
||||
hide(obj: IAnimationFadeable, duration = 1000, alpha = 0): void {
|
||||
if (obj.input) {
|
||||
obj.input.enabled = false;
|
||||
}
|
||||
|
||||
if (duration) {
|
||||
let tween = this.createTween(obj);
|
||||
tween.to({ alpha: 0 }, duration);
|
||||
tween.onComplete.addOnce(() => obj.visible = false);
|
||||
tween.to({ alpha: alpha }, duration);
|
||||
if (alpha == 0) {
|
||||
tween.onComplete.addOnce(() => obj.visible = false);
|
||||
}
|
||||
tween.start();
|
||||
} else {
|
||||
obj.alpha = 0;
|
||||
obj.visible = false;
|
||||
obj.alpha = alpha;
|
||||
obj.visible = alpha > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an object visibility, with opacity transition
|
||||
*/
|
||||
setVisible(obj: IAnimationFadeable, visible: boolean, duration = 1000): void {
|
||||
setVisible(obj: IAnimationFadeable, visible: boolean, duration = 1000, alphaon = 1, alphaoff = 0): void {
|
||||
if (visible) {
|
||||
this.show(obj, duration);
|
||||
this.show(obj, duration, alphaon);
|
||||
} else {
|
||||
this.hide(obj, duration);
|
||||
this.hide(obj, duration, alphaoff);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue