• Content count

  • Joined

  • Last visited

About jdotr

  • Rank

Profile Information

  • Location
    San Francisco, CA
  1. jdotr

    How do we reload a scene in Phaser 3

    I wrote a thing about scenes which might fill in some of the gaps about how they can be used: https://github.com/jdotrjs/phaser-guides/blob/master/Basics/Part3.md. The Phaser.io newsletters I link to at the bottom go into more detail and are also great reading though, IMO, they're better as a sort of reference text than a guide. tl;dr: super generally a scene is just a collection of things that should be displayed together in relation to other scenes and they doesn't imply any exclusivity, e.g., multiple scenes can be running at the same time. (I guess a caveat to that would be that an object can not belong to multiple scenes)
  2. jdotr

    How do we reload a scene in Phaser 3

    It's additionally worth noting `registry` is a globally shared object so even if you destroy the previous scene it won't clean up any data that you put in the registry. You'll still need to manually reset all of that. If you want a scene-specific `DataManager` instance you can use this.data (remember though that access to it won't be trivially available to other scenes if you're using the registry to share information).
  3. jdotr

    Does this example still exist? Point Light

    You can kind of fake it! ...it's distinctly slower than if it was all done in a GL pipeline but it still looks cool and is sufficiently performant if carefully applied (the jitter in the gif is a result of screencap, the scene runs at 60pfs): It's basically two layers: The background (becomes the unlit version) that has the tint set to the ambient color of the light. Next I add the layer that I want to have lit and apply a geometry mask based on a raycast from my light's point. Red Blob Games has a good guide on how raycasting works & how to implement it. My code is not quite in a state that it would be useful to share though I can try to nudge it in that direction if folks want. There are plenty of caveats and limitations on what you can do with this but for a lot of situations this can probably get you pretty close to what you had in mind. best of luck, lmk if you have any questions
  4. Hey All! I needed to display some dialog boxes in a recent game and the old 9-slice plugin wasn't ported to v3 yet so I wrote one (github repo). I have a live demo here and a gif of it in use follows. Would love to see this get some use outside of my projects so give it a spin. I'm pretty active on the discord and try to check in here weekly so feel free to ping if you have any questions! Happy hacking!
  5. jdotr

    Collision shapes into Phaser 3 from Tiled

    As far as I know Patrick has it right. If you look at the example which actually uses the collisions shapes to perform collisions it uses the matter physics system: Tiled collision shape example (with Matter). Your usage of this.physics suggests you are intending to use the Arcade system which supports a much less complex simulation and as was called out doesn't support the arbitrary shapes that are pulled from the map. The reason that you're seeing outlines of what you want to collide is because you explicitly call graphics functions which draw them -- this was used in the example to highlight the shapes that were detected and are unrelated to using them in your physics simulation.
  6. So my reading Yea, I saw that as well. My reading was that you should be applying a mask to the container for all children instead of attempting to stack the container mask with a child mask and expecting a union of the two masks to be applied or something similar. In any case there is no nested masking going on -- there is a single mask being applied to a container which (based on docs) I would expect to be used to determine which of it's children should be visible. Even if that isn't the case the existing behavior of displaying the children objects only when intersected seems weird and wrong: Container with no mask: https://imgur.com/a/qAKnWM6 vs with a mask applied (as defined by the cyan rectangle): https://imgur.com/a/mk76UTa In fact if you swap from a Geometry to a Bitmap mask it works as I would expect: https://imgur.com/a/KXIfTYJ (code at https://jsfiddle.net/jdotrjs/59tc3gbu/4/) Still think it's a bug; now just with the stencil test for the geometry mask, but if not would be interested to see doc updates to make expected behavior more clear.
  7. We figured out in discord that this definitely seems to be a bug in container masking; full repro case at https://jsfiddle.net/jdotrjs/59tc3gbu/ will try to update this thread when we get around to filing a bug on it
  8. jdotr

    Multiple problems with my phaser-project

    @Arnon dropped by the discord ask asked about this -- I did some digging and came up with the following change to their `create()` method in `game.js` which achieves the behavior they were looking for: function create() { _game.physics.startSystem(Phaser.Physics.ARCADE); // set references _keyboardInput = _game.input.keyboard; // in theory ScaleManager.setMinMax doesn't work with SHOW_ALL (see docs // at https://photonstorm.github.io/phaser-ce/Phaser.ScaleManager.html#setMinMax) // but empirical evidence definitely suggests that this works and is way // better than EXACT_FIT because of a weird tendency to scale only in // the X direction when resizing larger after the game has shrank. _game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; // make sure that our max is set to the max that the lesser of the width // and height -- this is because we don't want scale manager to use the // wrong axis as a scale guide. We could probably get away without doing // this if I understood how SHOW_ALL selected scaling axis better var sz = Math.min(window.innerWidth, window.innerHeight) // Make sure that the game doesn't scale anything larger than our selected // size. There is some interplay here between the aspect ratio (meaning we // can just use the same value) but that's left handwaved away. _game.scale.setMinMax(0, 0, sz, sz) // when the canvas resizes the window width/height changes which may mean // our game is no longer appriately sized. This will recompute all that // shit we just talked about _game.scale.setResizeCallback(function() { var newSz = Math.min(window.innerWidth, window.innerHeight) _game.scale.setMinMax(0, 0, newSz, newSz) }) // init game objects _map.init(); _player.init(); _ausgang.init() }