Phaser and FPS

Hello) I noticed a strange thing: I created a standard particle emitter and on my computer with fps 40-60 everything looks normal. But on a PC with fps of 80 or more, particles double and triple. Someone faced this problem? How to solve it? Thanks)

What’s the frequency?

Different: in some emitters 500, in others 70, in third I do not specify frequency.

Always give a frequency. Besides that I’m not sure what could cause the difference.

Even if frequency is specified the problem remains. It turns out yhat emitter is tied not only to the frequency, but also to the fps. Try to run particles at 60 fps and 120. The difference in number of particles is two times! How to solve this? Is there any way to set default fps in emitter?

What’s the emitter code?

You’re seeing the problem with frequency: 500 also?

this.a = Game.add.particles('abc');
this.add(this.a);
this.newEmitter = me.a.createEmitter({
    x: 100,
    y: 100,
    frame: 'any.png',
    lifespan: 600,
    scale: { start: 2, end: 0 },
    alpha: { start: 0.8, end: 0 },
    on: false,
    frequency: 200 // with or without it makes no difference
});

So here’s what’s going on: I’m creating and configuring an emitter for a 30-40 fps device. Everything looks good. But then I look at the work of the emitter from a device at 120 fps - there are 10 times more particles (looks terrible). I thought it was smth with frequency or lifetime. But it doesn’t affect. It doesn’t matter what frequency I set: 10 or 500. The more fps, the more particles. How can this problem be solved? Is there a way to limit the effect of fps on the emitter? Is it possible to somehow hard set the fps for a certain emitter? Is there a way to make the emitter independent of fps? Or maybe there is a better solution.
Thanks!. Looking forward to an answer!

How do you turn the emitter on?

Please run this code in any of your example editor ( Phaser - Examples - game-objects - Particle Emitter ) . The difference will be visible if you run the code at 30 fps, 60 fps and 120 fps.

Probably I need to specify the frequency depending on the fps. :face_with_monocle: Maybe there is a better way?

var config = {
    type: Phaser.WEBGL,
    width: 800,
    height: 600,
    backgroundColor: '#000',
    parent: 'phaser-example',
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{
    this.load.image('spark', 'assets/particles/blue.png');
}

function create ()
{
    var particles = this.add.particles('spark');
    var emitter = particles.createEmitter({
        x: 300,
        y: 300,
        lifespan: 1000,
        scale: { start: 2, end: 0 },
        alpha: { start: 0.5, end: 0 },
        blendMode: 'ADD',
        emitZone: { type: 'edge', source: new Phaser.Curves.Ellipse(0, 0, 200, 150), quantity: 25},
    });
}

You need to give a frequency.

Without a frequency, it emits one particle per frame, which is exactly what you don’t want.

:crazy_face: Specifying the frequency does not affect the problem) Here is the same emitter but with the specified frequency. The problem is still there. For fps 30 everything is ok with frequency = 10. But for fps 60 particles are larger and they move faster. If you specify frequency = 40 for fps 60, everything will become ok. And I return to the very first question :see_no_evil:: how to fix this problem?
PS: please don’t answer again that i need to specify the frequency…


    var emitter = particles.createEmitter({
        x: 300,
        y: 300,
        lifespan: 1000,
        scale: { start: 2, end: 0 },
        alpha: { start: 0.5, end: 0 },
        blendMode: 'ADD',
        frequency: 10,
        emitZone: { type: 'edge', source: new Phaser.Curves.Ellipse(0, 0, 200, 150), quantity: quantityTest},
    });

Post a runnable example somewhere, please.

How are you running this at different FPS?

30 fps: 30 fps.mp4 - Google Drive
120 120 fps.mp4 - Google Drive

I run particles on different devices

In Phaser v3.55.2 and earlier, you should avoid using a frequency smaller than the largest game step delta. So if the smallest fps you expect is 30 then use frequency 33.33 or larger. In Phaser v3.60.0 you can use any frequency larger than 0.

Also print out the this.game.loop.delta values. They should be close to 33 (at 30fps) or 8 (at 120fps).

Unfortunately I don’t understand how this should help me. Also, I don’t understand why there was so much talk about the frequency, if you yourself wrote that it could be at least 0.
I solved the problem in this way. Somewhere in the code I write fps to a variable. And then I stupidly set the amount depending on the FPS.

I don’t know how correct and beautiful this solution is, but it works, although I don’t really like it.

 let quantityTest = 25  // !!!!!!!

     if(mainFps >= 30) {
        quantityTest = 25
     } else if (mainFps >= 60) {
        quantityTest = 50
    } else if (mainFps >= 120) {
        quantityTest = 100
    }

   var emitter = particles.createEmitter({
        x: 300,
        y: 300,
        lifespan: 1000,
        scale: { start: 2, end: 0 },
        alpha: { start: 0.5, end: 0 },
        blendMode: 'ADD',
        emitZone: { type: 'edge', source: new Phaser.Curves.Ellipse(0, 0, 200, 150), quantity: quantityTest},  // !!!!!!!
    });
}

I advised you to change this code from frequency: 10 to frequency: 33.

I don’t think further discussion is going to be fruitful, so I’m locking this post.