Ourcade
Phaser 3

Official Examples

TypeScript

Resources
Articles
Videos
Templates
Learn Phaser 3 Roadmap
  Courses
Memory Match Extras
JsonFile.ts index.html main.ts
Phaser v3.24.1
  • Phaser 3

  • TypeScript

  • Cache

  • Json File

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Phaser from 'phaser'
 
export default class JsonFile extends Phaser.Scene
{
    preload()
    {
        this.load.json('jsonData','/assets/atlas/megaset-0.json')
    }
 
    create()
    {
        const jsonData = this.cache.json.get('jsonData')
 
        console.log(jsonData)
 
        const str = `${JSON.stringify(jsonData, null, 2).slice(0, 500)}...`
        this.add.text(10, 10, str)
    }
}