JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.16.2/phaser.min.js"></script>
<div id='phaser-example'></div>

JavaScript

var police;
var ambulance;

class Sprite extends Phaser.GameObjects.Sprite {
	constructor (scene,x,y,texture,anim_vehicle)
	{
		super(scene, x, y,texture);
    this.texture=texture
    this.anim_vehicle = anim_vehicle
    this.scene.anims.create({
			key: this.anim_vehicle,
			frames: this.scene.anims.generateFrameNumbers(this.texture, {frames:[0,0,1,1]}),
			frameRate: 8,
			repeat: -1,
		});
    setTimeout(()=>{this.anim_pinpon()},1000)
   // this.anim_pinpon()
		scene.add.existing(this)
	}
  anim_pinpon(){
      this.anims.play(this.anim_vehicle)
  }
}

config = {
	type: Phaser.CANVAS,
	width: 400,
	height: 400,
	backgroundColor: '#0d1018',
	physics: {
		default: 'matter',
		matter: {
			debug: true,
			gravity: {
                y: 3
      },
    }
	},
	callbacks: {
		postBoot: function (game) {
		}
	},
	scene: {
		preload: preload,
		create: create,
    update: update,
	}
};

var game = new Phaser.Game(config);

function preload() {
	this.load.spritesheet("police", "https://i.postimg.cc/ZKQQdhKH/police.png",{
  frameWidth: 50,
  frameHeight :50,
  
  });
	this.load.spritesheet("ambulance", "https://i.postimg.cc/BZYYrGD3/ambulance.png",{
  frameWidth: 50,
  frameHeight :50, 
  });
}

function create() {
 
	police = new Sprite(this,100,100,"police","police_anim")
  ambulance = new Sprite(this,300,100,"ambulance","ambulance_anim")
}

function update() {
}