Skip to content

Commit

Permalink
Ajustar puertas para controles táctiles
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCastUCM committed Aug 9, 2024
1 parent eae6d15 commit ee5c7a0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/UI/messageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class MessageBox extends Phaser.GameObjects.Container {
// Configuracion de texto para la el texto del mensaje
let textConfig = { ...scene.gameManager.textConfig };
textConfig.fontFamily = 'roboto-regular';
textConfig.fontStyle = 'bold';
textConfig.fontSize = 15 + 'px';
textConfig.color = '#000';
textConfig.wordWrap = {
Expand Down
2 changes: 2 additions & 0 deletions src/UI/phone/settingsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class SettingsScreen extends BaseScreen {
let yesText = this.i18next.t("settings.yes", { ns: "phoneInfo" })
let yesButton = new Button(scene, this.BG_X, this.BG_Y * 1.1, 1,
() => {
yesButton.reset();
this.gameManager.startLangMenu();
},
this.gameManager.textBox.fillName, normalColor, hoverColor, pressedColor,
Expand All @@ -46,6 +47,7 @@ export default class SettingsScreen extends BaseScreen {
let noText = this.i18next.t("settings.no", { ns: "phoneInfo" })
let noButton = new Button(scene, this.BG_X, this.BG_Y * 1.4, 1,
() => {
noButton.reset();
phone.toPrevScreen();
},
this.gameManager.textBox.fillName, normalColor, hoverColor, pressedColor,
Expand Down
33 changes: 30 additions & 3 deletions src/scenes/gameLoop/baseScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,29 +613,56 @@ export default class BaseScene extends Phaser.Scene {
closed.setInteractive({ useHandCursor: true });
opened.setInteractive({ useHandCursor: true });

// Oculta la imagen de la puerta abierta
opened.visible = false;

// Establece el tipo de evento de puntero segun si
// hay que hacer click o pasar el raton por encima
let openEvt = 'pointerdown';
let closeEvt = 'pointerdown';

if (!click) {
openEvt = 'pointerover';
closeEvt = 'pointerout';
}

// Al producir el evento de puntero en la puerta cerrada, se oculta la
// imagen de la puerta cerrada y se muestra la imagen de la puerta abierta.
closed.on(openEvt, () => {
closed.visible = false;
opened.visible = true;
});
// Al producir el evento de puntero en la puerta abierta, se oculta la
// imagen de la puerta abierta y se muestra la imagen de la puerta cerrada.
opened.on(closeEvt, () => {
opened.visible = false;
closed.visible = true;
});


// Al pulsar la puerta abierta, se produce el evento indicado
opened.on('pointerdown', () => {
if (onClick !== null && typeof onClick === 'function') {
onClick();
}
})
});


// Al pulsar la puerta cerrada, si se esta usando input tactil, se abre la puerta por un
// momento, se produce el evento indicado despues de que se abra la puerta, y luego se cierra
closed.on('pointerdown', () => {
if (IS_TOUCH) {
opened.visible = true;
closed.visible = false;
setTimeout(() => {
if (onClick !== null && typeof onClick === 'function') {
onClick();
}
if (!click) {
opened.visible = false;
closed.visible = true;
}
}, 100);
}
});
}

}
2 changes: 1 addition & 1 deletion src/scenes/gameLoop/busScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class BusScene extends BaseScene {
create(params) {
super.create(params);

let duration = 2000;
let duration = 1500;
let nextScene = "";

if (params.duration) {
Expand Down

0 comments on commit ee5c7a0

Please sign in to comment.