• Content count

  • Joined

  • Last visited

About FlopshotQQ

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. FlopshotQQ

    [Solved] Multiple key.isDown

    Turns out this was hardware related.
  2. FlopshotQQ

    [Solved] Multiple key.isDown

    Somewhat new to Phaser, the game is similar to pong and there's a two player mode. The problem I'm encountering is that when both directional keys for one paddle are being held down (A&D or LEFT&RIGHT) no more input is being accepted. Leaving the other player unable to move their paddle. Below is a simplified version of the code. Any help or information is appreciated //something to the effect of var paddle1Speed = 900; var paddle1Acceleration = 0; var paddle1Pressure = 10; var paddle2Speed = 900; var paddle2Acceleration = 0; var paddle2Pressure = 10; var maxPaddleAcceleration = 300; function update () { player2ControlListen (); player2ControlListen (); } function player1ControlListen () { if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { if (paddle1.body.velocity.x > -paddle1Speed) { if (paddle1Acceleration > -maxPaddleAcceleration) { paddle1Acceleration -= paddle1Pressure; } paddle1.body.velocity.x += paddle1Acceleration; } } if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { if (paddle1.body.velocity.x < paddle1Speed) { if (paddle1Acceleration < maxPaddleAcceleration) { paddle1Acceleration += paddle1Pressure; } paddle1.body.velocity.x += paddle1Acceleration; } } } function player2ControlListen () { if (game.input.keyboard.isDown(Phaser.Keyboard.A)) { if (paddle2.body.velocity.x > -paddle2Speed) { if (paddle2Acceleration > -maxPaddleAcceleration) { paddle2Acceleration -= paddle2Pressure; } paddle2.body.velocity.x += paddle2Acceleration; } } if (game.input.keyboard.isDown(Phaser.Keyboard.D)) { if (paddle2.body.velocity.x < paddle2Speed) { if (paddle2Acceleration < maxPaddleAcceleration) { paddle2Acceleration += paddle2Pressure; } paddle2.body.velocity.x += paddle2Acceleration; } } }
  3. FlopshotQQ

    [solved] Mobile viewport inconsistency

    I managed to find a work around myself. Figured I would post it here if anyone else ran into similar problems. I don't know what the problem is, but after scouring the internet and days of testing I have a guess. This seems to be a time based issue. It checks the window.innerWidth provided by the embedded container, in this case the one I set for itch.io, and scales to it before window.innerWidth is adjusted by the phone going fullscreen. This doesn't explain why it works the first time you load the game though, and why it only fails after refreshing the itch.io page the game is embedded in. Either way I solved the problem by creating a function that restarts the game after a timer goes off. I removed any scaling calculations and game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; from the original game declaration, and used '100%' so it loads (and fails) faster. The timer runs this function: { aspect_ratio = window.innerWidth / window.innerHeight; testWidth = 960 * aspect_ratio; if (testWidth <= 645) { var canvasWidth = 640; var canvasHeight = 640/aspect_ratio; } else { var canvasWidth = 960 * aspect_ratio; var canvasHeight = 960; } game.scale.setGameSize(canvasWidth, canvasHeight); game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.refresh(); game.state.restart(); } This works, despite not knowing 100% why. It's not perfect because you can see the game restart and the assets adjust. Though I'm just going to cover that up with a splash. This solution has been tested on PC, iPhone, and Andriod on many devices. The game scales as intended. Test it yourself here: https://flopshotqq.itch.io/screen-scale-test Hopefully this helps someone Happy coding!
  4. Hey. I need help, I've been banging my head against this for hours. I've been scaling my game to fit screens on all devices, while maintaining the asset ratios. The game size increases so the controls work where ever you touch. I've run into an issue with Android/Chrome and itch.io. I'm not sure if it's specific to the browser, or the site, or mobile. It might be a full screen mobile issue all together, but I'm testing it on itch and an android with chrome. The first time the game loads it scales and works perfectly. Then, if I refresh the page or visit it later this happens: The game gets put into the view port ratio set in Itch, and doesn't adjust like it should in fullscreen. This being 640x960. 2:3 ratio, the screen has a higher Y axis. This causes the white bar at the bottom which is unresponsive to the touch controls. I've removed the padding in CSS: <style> html { margin:0; padding:0; } body { margin: 0; padding: 0; } #canvasholder { width: 99vw; height: 99vh; margin: 0 auto; } </style> and my canvas code looks something like this: // ~A Canvas and Game Setup aspect_ratio = window.innerWidth / window.innerHeight; testWidth = 960 * aspect_ratio; //if the aspect ratio stretches the Y axis if (testWidth <= 640) { var canvasWidth = 640; var canvasHeight = 640/aspect_ratio; } // else if it stretches the X axis else { var canvasWidth = 960 * aspect_ratio; var canvasHeight = 960; } //test versions //var canvasWidth = 640; //var canvasHeight = 960; var game = new Phaser.Game(canvasWidth, canvasHeight, Phaser.CANVAS, 'game', { preload: preload, create: create, update: update }); function create() { // ~2.1 Game Scaling game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.refresh(); Maybe I've over complicated the original solution? This worked the way I intended on Desktop tests. You can test it yourself here: https://flopshotqq.itch.io/screen-scale-test Thanks so much, any help is appreciated.