Skip to content

When providing frames with duration to anims.create(), 41.6ms is added to every frame (1 frame time @24 FPS) #6712

@Nerodon

Description

@Nerodon

Version

  • Phaser Version: 3.70.0
  • Operating system: Windows 11
  • Browser: Chrome and FF

Description

When providing durations in animations using an array of frames rather than total duration or FPS, the timing is generally slower than it should, sometimes by over several hundreds of ms or more. This is especially noticeable for quick and snappy animations making it impossible to define animation durations per frame this way.

This scales with the number of frames given to anims.create()
EXAMPLE:

    this.anims.create({
            key: 'walk',
            frames: [
                { key: 'brawler', frame: 0, duration: 200 },
                { key: 'brawler', frame: 1, duration: 100 },
                { key: 'brawler', frame: 2, duration: 200 },
                { key: 'brawler', frame: 3, duration: 100 },
                ],
            repeat: 0
        });  

For each frame, the time is extended by 40ms.
So a 10 frame animation will have a total runtime of about 400ms longer.

Example Test Code

EXAMPLE JsFiddle

Simply refresh, the time displayed on screen should match the total duration for all the frames. In the fiddle is should be 2400ms, but the animation completes in about 3000ms on Chrome or Firefox browser.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions