Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Animation lags when played for the fist time

Fractal Games

Recommended Posts

Hey everyone,

My question is quite basic. We have a game with lots of animations. One animation has a quite large spritesheet. When we play the animation for the first time the whole game lags for a couple of ms. Afterwards, there is absolutely no lag when we play the animation.

Is there any way to preload/prerender/preplay the animation? Below is the relevant code:

1. Loading the spritesheet in the Boot Scene's preload method: 

 this.load.spritesheet('some-anim', /some-anim.png', {
      frameWidth: 160,
      frameHeight: 546,
      startFrame: 0,
      endFrame: 29

2. Creating an animation in the Boot Scene's create method:

      key: 'some-anim-key',
      frames: this.anims.generateFrameNames('some-anim'),
      frameRate: 30,
      repeat: -1

3. The Sprite class

export class MyAnim extends Phaser.GameObjects.Sprite {
  scene: Phaser.Scene;

  constructor(scene: Phaser.Scene) {
    super(scene, -1500, -1500, null);
    this.scene = scene;

4. Playing the animation in the game state:

this.myAnim = new MyAnim(this); //this points to the game scene.


Thank you in advance for your help :)

Link to comment
Share on other sites


  • Recently Browsing   0 members

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