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

View File

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

View File

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