BlueLemming

Members
  • Content Count

    4
  • Joined

  • Last visited

About BlueLemming

  • Rank
    Newbie

Recent Profile Visitors

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

  1. Is there a way to check if a physics sprite would collide with another object at a given position? I have tried something like this: // desired position to check player collision at const checkPosition = { x: 100, y: 100 } // temporarily change player position const pos = { x: player.x, y: player.y } player.setPosition(checkPosition.x, checkPosition.y) // test collision const collision = this.scene.physics.collide(player, otherObj) // set back to original position player.setPosition(pos.x, pos.y) however, I can't get the collision to return true. I suspect there needs to be an update cycle between updating the position and testing for collisions, but I can't find any documentation to suggest that is the case. Is there a good way to go about this?
  2. I think the game.destroy() function is still a dummy function in Phaser 3 beta 20. So, in other words, you could either make a build from the Phaser 3 source or just wait till the next release which should be tomorrow.
  3. I was able to make my own quick solution for detecting when a key was first pressed. I used lodash for a helper function, apologies if you don't want to use lodash. You'll just have to rewrite the "getKeyByKeycode" function if so. // snipped from my ES6 Scene class import _find from 'lodash/find' export default class extends Phaser.Scene { create() { this.keys = this.input.keyboard.addKeys({ left: Phaser.Input.Keyboard.KeyCodes.LEFT, right: Phaser.Input.Keyboard.KeyCodes.RIGHT, jump: Phaser.Input.Keyboard.KeyCodes.A }) this.input.keyboard.on('keydown', event => { const key = this.getKeyByKeyCode(event.keyCode) if (key) { if (key.timeUp === 0 || key.timeDown < key.timeUp) { if (key.timeUp === 0) { key.timeUp = 1 } this.input.keyboard.emit('keypressed', event) } } }) } getKeyByKeyCode(keyCode) { return _find(this.keys, { keyCode }) } }
  4. I've been struggling to figure out if the "_justDown" property of a key is working properly or not. It seems to always be true as long as the key is held just like "isDown" when accessed directly (ex: someKey._justDown). It seems that the intention is to use the Phaser.Input.Keyboard.JustDown() getter method, but it returns the same results as key.isDown and key._justDown (ex: Phaser.Input.Keyboard.JustDown(someKey)) If this is a bug then I'm comfortable enough to try and make a fix, but I figured I should first see if I'm misunderstanding how to use it in the first place. (Using Phaser 3 beta 19)