Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
¿Qué debo cambiar para usar en un navegador de teléfono celular móvil para que el reproductor salte automáticamente cuando toque la pantalla?

¿Qué debo cambiar para usarlo en el navegador de un teléfono móvil para que el reproductor corra automáticamente hacia la derecha y salte cuando se toca la pantalla? He buscado durante años pero no puedo encontrar la respuesta y estoy tratando de aprender

aquí está el código

 update(time, delta) { moveBackgroundPlatform(this.mountainGroup, this.mountainWidth, 'mountains', 0.5); moveBackgroundPlatform(this.plateauGroup, this.plateauWidth, 'plateau', 1.5); moveBackgroundPlatform(this.groundGroup, this.groundWidth, 'ground', 4); if (this.health <= 0) { const myUrl = `${fetchScoreData.apiUrl + fetchScoreData.apiKey}/scores`; fetchScoreData.postScores(myUrl, { user: gameState.playerName, score: gameState.score }); this.gameTheme.stop(); this.scene.stop(); this.scene.start('GameOver'); } if (this.missileScore >= 1) { this.health += 1; this.missileScore -= 1; } this.player.anims.play('run', true); this.birdGroup.children.iterate((child) => { child.anims.play('fly', true); }); this.missileGroup.children.iterate((child) => { child.x -= 5; }); this.timer += delta; if (this.timer >= 5000) { this.createMissile(415, 'missile'); this.timer = 0; } this.secondTimer += delta; if (this.secondTimer >= 7000) { this.createMissile(300, 'missile2'); this.secondTimer = 0; } if (Phaser.Input.Keyboard.JustDown(this.cursors.up)) { //this.input.on('pointerdown', this.jump, this); console.log(' up preess'); if (this.player.body.touching.down || (this.jump < this.jumpTimes && (this.jump > 0))) { this.player.setVelocityY(-400); this.jumpSound.play(); if ((this.player.body.touching.down)) { this.jump = 0; } this.jump += 1; } } if (!this.player.body.touching.down) { this.player.anims.play('jump', true); } if (this.cursors.down.isDown) { if (!this.player.body.touching.down) { this.player.setGravityY(1300); } } if (this.player.body.touching.down) { this.player.setGravityY(800); } } } export default Game;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hay muchas formas de resolver esto, no soy un profesional, pero agregaría un detector de eventos de puntero en el método de create de la escena:

 this.input.on('pointerdown', jump, this);

y el método de jump , que contiene toda la lógica de salto:

 jump(){ if (this.player.body.touching.down || (this.jump < this.jumpTimes && (this.jump > 0))) { this.player.setVelocityY(-400); this.jumpSound.play(); if ((this.player.body.touching.down)) { this.jump = 0; } this.jump += 1; } }

este método de jump podría llamar a la función de update para evitar la duplicación de código.

 update(time, delta) { ... if (Phaser.Input.Keyboard.JustDown(this.cursors.up)) { jump(); ... } ... }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!