Jump to content

The Phaser 3 Wishlist Thread :)


rich
 Share

Recommended Posts

Hey guys, didn't wanted to create a new topic for this so I'm gonna ask here.

I started Phaser 3 project with Visual Studio Code, and there's very little autocompletion. VSCode automatically guesses what it should show you in those little popups using JSDoc-style comments from a class-structured code (maybe it does more guessing, but thats what I discovered). So without it, I have to have source code or docs for Phaser 3 open on a second monitor or somewhere handy.

I noticed you're using some custom tool to generate classes. Are you planning to switch to ES6-style classes? You don't have to worry about browser support, as you're already using webpack, so it takes care or importing/exporting, and class keyword is supported in most of the modern browsers. If you care for IE11 you could use Babel to transpile it, or let us do the transpilation in our game projects (freedom of choice, woohoo).

Link to comment
Share on other sites

First of all, thank you for all of the hard work you have done towards Phaser. It is honestly the best HTML5 game engine I have programmed in.

This is more of an optimization if anything, but will future versions of phaser handle Tilemap collisions more efficiently?

Currently, when calling methods such as setCollisionByExclusion on large Tilemaps, the loading time can take many seconds (especially on iOS and Android). Calling setCollisionByIndex on every tile on the map appears to be wildly inefficient, as proven by the timed functions below. I assume these methods are written this way to make the code more maintainable.

5988f1fba273e_ScreenShot2017-08-07at7_01_33PM.png.6b9025fa7136e177ddc37532b2025d38.png 

I have provided a temporary fix for myself by combining the setCollisionByExclusion function and the setCollisionByIndex function. There is no noticeable delay anymore, and fairly large Tilemaps are loaded with collision in mere milliseconds.

public setCollisionByExclusion(indexes, collides?, layer?, recalculate?) {
    //refactored method from superclass to increase performance

    if (collides === undefined) { collides = true; }
    if (layer === undefined) { layer = this.currentLayer; }
    if (recalculate === undefined) { recalculate = true; }

    layer = this.getLayer(layer);

    for (var i = 0, len = this.tiles.length; i < len; i++)
    {
        if (indexes.indexOf(i) === -1)
        {
            if(collides) {
                this.collideIndexes.push(i);
            }
            else {
                var i = this.collideIndexes.indexOf(i);

          			if (i > -1)
          			{
          				this.collideIndexes.splice(i, 1);
          			}
            }
        }

    }

    for (var y = 0; y < this.layers[layer].height; y++)
    {
        for (var x = 0; x < this.layers[layer].width; x++)
        {
            var tile = this.layers[layer].data[y][x];

            if (tile && indexes.indexOf(tile.index) === -1)
            {
                if (collides)
                {
                    tile.setCollision(true, true, true, true);

                }
                else
                {
                    tile.resetCollision();
                }

                tile.faceTop = collides;
                tile.faceBottom = collides;
                tile.faceLeft = collides;
                tile.faceRight = collides;
            }
        }
    }

    if (recalculate)
    {
        //  Now re-calculate interesting faces
        this.calculateFaces(layer);
    }

    return layer;
  }

 

Link to comment
Share on other sites

I've added some tilemaps to my test and generally it works fine. But I'm getting some odd artifacts on transparent tiles. I suspects it's due to filtering issues. So I'm wondering if it is or will be possible to set the filter mode for a texture manually, at least in webgl mode? For example I would like to use Nearest neighbor filtering right now for all the images I have but in some games I would need to have some images use nearest and some use linear filtering for example.

I have attached an image to explain the issue I have. The left side if from Tiled (properly rendered) and the right side from the v3 test. I use dynamic tilemaps but with static tilemaps the result is exactly the same. You can see the outline on the dirt and the rock. You also see that the texture is smoothed in phaser.

tilemapOutline.png.a31864b3bad5b23e536748221049fb01.png

Link to comment
Share on other sites

Thanks, changing filtering solved the outline problem! :)

I think that tilemaps should default to nearest, just like how Tiled does it. That way you also don't get the outline issue I had.

Also if you could add some constants like Texture.NEAREST and Texture.LINEAR that would be neat. Ex: t.setFilter(Texture.NEAREST), or something along those lines.

Edit: I found Phaser.ScaleModes in the src. :)

Link to comment
Share on other sites

We discussed automatically setting nearest on the tileset image but there are possible side-effects, for example, a tileset that is a frame in an atlas would set nearest on the entire atlas, not just the tileset (as it's a texture-wide setting), so it felt a bit too magical to do automatically. There is a pixelArt: true game config setting you can flip which would cover cases for pixel art games, but if you're doing a mixed media game then I think it's up to you to know to split assets into 'linear' and 'nearest' atlases, and set the scale modes accordingly.

Link to comment
Share on other sites

7 hours ago, Legomite said:

String values for percentages?

Then you'd have to do a typeof check every time a Game Objects position value is set and parseFloat it if a string. I dread to think what the cost of that would be in a typical game. To me, this feels like a feature very easily implemented yourself.

Link to comment
Share on other sites

18 minutes ago, YuPi said:

Is typescript still supported? There are no definition files yet, but that's probably related to the docs not being available yet.

There are no TS defs yet. JSDocs will come first but even then we still need to find an easy way to manage the TS defs, because doing them by hand like in v2 was a royal pain in the ass, and automating them is a lot harder than it first appears.

Link to comment
Share on other sites

  • 2 weeks later...

I'm currently working with lots of groups, and I really miss a kill() for groups. Not killAll(), I mean kill(). Since groups have alive, exists and visible properties, and that applies to children, it would be just natural to be able to kill groups as well.

Of course... I'm still a newbie with Phaser. I apologize if there's already something like it, but surfing the docs there appears to be nothing.

Link to comment
Share on other sites

Hi

It would be really great to see better text formatting options.  

For example: The ability to specify a text area by setting bounds for x, y, height, width and then apply the formatting as per the current implementation, but have the text scale automatically to the size of the bounding box.

That would enable us to center align an unknown amount of text and scale it nicely to an allocated area of the screen.

An example call might be something like:

var config1 = {
  x: 10,
  y: 10,
  width: 760,
  height: 100,
  text: "This is some text that will scale to fill the text area.",
  style: {
    fill: '#ffffff',
    align: 'center',
    backgroundColor: '#ff00ff'
  }
};
this.make.text(config1);

Thanks so much!  Phaser 3 is awesome!

D

Link to comment
Share on other sites

I added some Impact physics to my test and it works very well. Some things that I needed though were getters for body position & velocity. I couldn't find any in the current code but I'm sure you'll add that later, if I didn't just miss it. In the mean time I just added some own temp stuff.

Another thing I see is that debug boxes for bodies often overlaps when moving even if the bodies themselves don't overlap. I'm not sure if it's a bug or not. It looks like you maybe get the position data before the body has been pushed back after the collision.

physicsDebugOverlap.png.3fa5287ec8fe5162dc084bdcd7d91238.png

Link to comment
Share on other sites

@Karma Octopus you can get those values from 'body.pos' and 'body.vel' (these are the original properties that Impact.js uses, so I couldn't change their names). I think maybe I may leave it like this for Impact, but when we add in Arcade Physics it should be a lot cleaner. You're right about the debug boxes though - they are drawn before the solver takes place (and update too). I could definitely move this to happen after everything has been solved, I'm just wary of yet another iteration loop.

Link to comment
Share on other sites

  • rich unpinned this topic
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...