jd.joshuadavison

Members
  • Content Count

    7
  • Joined

  • Last visited

About jd.joshuadavison

  • Rank
    Newbie

Recent Profile Visitors

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

  1. I'm using the animated tiles plugin from nkholski with the key 'animatedTiles' (how did I come up with that? It's genius). At a certain point I am destroying the game with `game.destroy(true)`. Unfortunately, when creating a new game I'm getting a warning "Scene Plugin key in use: animatedTiles" that then leads to an error "Uncaught TypeError: Cannot read property 'init' of undefined". I've checked the scene and sure enough, the plugin has not been added to it. I tried destroying the game cache before destroying the game, but that just gave me an error too. Josh
  2. Hi Samme, Thanks for taking the time to respond - and I'm sorry for my slow reply. I've been taking a break from my game for the last couple of weeks, but I'm back on it now. Do you think the tiles being culled whilst they are still within the cameras viewport is a bug then? Also, my layer is definitely not receiving the x and y values from from my JSON. But I can set them myself in the code with no problems. Is this also a bug? Should I report them on GitHub? I'm going to move onto working out a workaround now. I'm thinking that I can probably take this layer out of the tilemap altogether and dynamically place them as images at the correct coordinates. There are only 25 "tiles". Do you have any other suggestions for me to look into? Josh
  3. Okay so, Horizontal Offset is definitely what I want and is definitely not supported - I will raise a feature request on GitHub shortly. In the meantime I've had no luck with a work around. It seems that in phaser 2, tilemap layers had a property called `cameraOffsetX`, which might have done the job, although, equally, that might have done exactly the same thing as phaser 3's `x` property. But I can't find anything like that in Phaser 3. Any suggestions?
  4. I'm using a callback function on the overlap method, but it's firing at the wrong time. After a bit of calculation/trial and error I worked out that it is firing where the sprite would have been if the scrollFactor of the sprite was the default setting of 1. I assume this is a bug? See demo on jsFiddle. Update: it also ignores the objects origin and assumes its origin is the default 0.5. I've updated the demo. Update 2: I'm now fairly certain this is not expected behaviour, so I've raised an issue on GitHub. Thanks, Josh
  5. Hello, I've built a tilemap using Tiled. The only thing is, I want to offset the tilemap (or preferably, individual tilemap layers) dynamically in the game (i.e. by a variable/calculated number of pixels). Tiled does have a 'Horizontal Offset' property for the layer. Obviously that would be a fixed value, but I thought it would map to a property of the tilemap layer object which I would then be able to dynamically modify, but as far as I can tell Phaser doesn't do anything with the 'Horizontal Offset' property. So I tried setting the tilemap layer's x position. This did offset the layer, but it doesn't just offset where the tilemap starts it offsets where the tilemap exists. By which I mean, that the tiles are culled as the move further left than it's x position, so my tiles disappear/appear at the left edge of the tilemap layer instead of the game viewport. I'm a bit stuck... I'm fairly sure that the Horizontal Offset is what I want, but as I said, it doesn't seem to be used by Phaser. Am I missing something? Is there another way to do what I want? Thanks, Josh
  6. Thanks Doug! I really wish I'd found the labs earlier! That's exactly what I'm looking for. In fact, Phasers keydown event works differently from the regular javascript onkeydown. Javascript's onkeydown will keep firing repeatedly if you hold the key down, Phasers keydown only fires once, so I think I prefer keydown to keyup! Here's my new event listener in the create function. this.input.keyboard.on('keydown_UP', function (event) { if (player.body.onFloor()) { player.body.setVelocityY(-400); player.anims.play('idle', true); jumpCount = 1; jumpTime = new Date().getTime(); } else if (jumpCount === 1 && ((new Date().getTime() - jumpTime) < 1500)) { player.body.setVelocityY(-300); player.anims.play('idle', true); jumpCount = 0; } }); This certainly feels more right than what I'd written in the update function. Thanks, Josh
  7. Hi, Broad question It's my second day learning Phaser. I've dived straight into Phaser 3, but its proving challenging since the docs are only available in the GitHub repo. It looks like there was an event handler in Phaser 2 called 'onUp' which would only fire once when a key was released instead of continuously firing for as long as the key is held down like 'isDown' does. This doesn't seem to exist in Phaser 3 - what is the correct way of doing this in Phaser 3? In this particular instance I'm trying to do this on a cursor key, but it would be useful to know how to do it on any key if it's different. Specific scenario I've enabled my player sprite to 'double jump' using the following code in the update function. if (cursors.up.isUp) { jumpReleased = true; } if (cursors.up.isDown && player.body.onFloor()) { player.body.setVelocityY(-300); player.anims.play('idle', true); jumpCount = 1; jumpReleased = false; jumpTime = new Date().getTime(); } else if (cursors.up.isDown && jumpReleased === true && jumpCount === 1 && ((new Date().getTime() - jumpTime) < 1500)) { player.body.setVelocityY(-400); player.anims.play('idle', true); jumpCount = 2; jumpReleased = false; } `isDown` simply fires if the key is being pressed at the time that the update function fires, which is a lot. I was hoping to find a way to simply fire this event on key up (like the native javascript event handler) - this way I wouldn't have to set and check `jumpReleased`. Is there a way to do this? More to the point, is there a correct way to do this? Thanks, Josh