1
0
Fork 0

Prevent right click on buttons and arena

This commit is contained in:
Michaël Lemaire 2018-06-11 19:10:06 +02:00
parent 7a7649e8a9
commit f39b96ad1d
3 changed files with 14 additions and 10 deletions

View File

@ -99,8 +99,10 @@ module TK.SpaceTac.UI {
// Capture clicks on background
background.setInteractive();
background.on("pointerup", () => {
this.callbacks_click.forEach(callback => callback());
background.on("pointerup", (pointer: Phaser.Input.Pointer) => {
if (pointer.buttons == 1) {
this.callbacks_click.forEach(callback => callback());
}
});
background.on("pointerout", () => {
this.callbacks_hover.forEach(callback => callback(null, null));
@ -250,7 +252,7 @@ module TK.SpaceTac.UI {
let sprite = this.findDrone(drone);
if (sprite) {
remove(this.drone_sprites, sprite);
return sprite.setDestroyed();
return sprite.setDestroyed(speed);
} else {
console.error("Drone not found in arena for removal", drone);
}

View File

@ -59,9 +59,11 @@ module TK.SpaceTac.UI {
*
* Return the animation duration
*/
async setDestroyed(): Promise<void> {
this.view.animations.addAnimation<UIContainer>(this, { alpha: 0.3 }, 300, undefined, 200);
await this.view.animations.addAnimation(this.radius, { scaleX: 0, scaleY: 0 }, 500);
async setDestroyed(speed = 1): Promise<void> {
if (speed) {
this.view.animations.addAnimation<UIContainer>(this, { alpha: 0.3 }, 300 / speed, undefined, 200 / speed);
await this.view.animations.addAnimation(this.radius, { scaleX: 0, scaleY: 0 }, 500 / speed);
}
this.destroy();
}

View File

@ -210,7 +210,7 @@ module TK.SpaceTac.UI {
enternext = Timer.global.schedule(hovertime, effectiveenter);
});
obj.on("pointerout", (pointer: Phaser.Input.Pointer) => {
obj.on("pointerout", () => {
if (destroyed) return;
if (this.hovered === obj) {
@ -222,7 +222,7 @@ module TK.SpaceTac.UI {
});
obj.on("pointerdown", (pointer: Phaser.Input.Pointer) => {
if (destroyed) return;
if (destroyed || pointer.buttons != 1) return;
if (UITools.isVisible(obj)) {
holdstart = Timer.nowMs();
@ -235,8 +235,8 @@ module TK.SpaceTac.UI {
}
});
obj.on("pointerup", (event: Phaser.Input.Pointer) => {
if (destroyed) return;
obj.on("pointerup", (pointer: Phaser.Input.Pointer) => {
if (destroyed || pointer.buttons != 1) return;
if (!cursorinside) {
effectiveleave();