# Load json file and change frames

**URL:** <https://phaser.discourse.group/t/load-json-file-and-change-frames/2772>\
**Category:** Phaser 3\
**Created:** [June 13, 2019, 1:33pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772 "2019-06-13T13:33:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ananth](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Ananth](https://phaser.discourse.group/u/Ananth)\
**Post date:** [June 13, 2019, 1:33pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/1 "2019-06-13T13:33:03Z")

</div>

I load and add my json file like,

this.load.atlas(‘sprite’, sprite.png, sprite.json);

sprite=this.add.sprite(400,300,‘sprite’)

Now what i need i have 14 to 15 frames in json.how can i call particular frame using phaser3

---

<div class="post-metadata">

**Author:** ![Sturb](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Sturb](https://phaser.discourse.group/u/Sturb)\
**Post date:** [June 13, 2019, 1:39pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/2 "2019-06-13T13:39:04Z")

</div>

You could try handling it something like this:  
[https://labs.phaser.io/edit.html?src=src\animation\from%20json.js](https://labs.phaser.io/edit.html?src=src%5Canimation%5Cfrom%20json.js)

---

<div class="post-metadata">

**Author:** ![Ananth](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Ananth](https://phaser.discourse.group/u/Ananth)\
**Post date:** [June 13, 2019, 1:41pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/3 "2019-06-13T13:41:32Z")

</div>

Thanks sturb,  
can i use setFrame concept for json.is that possible?

---

<div class="post-metadata">

**Author:** ![Sturb](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Sturb](https://phaser.discourse.group/u/Sturb)\
**Post date:** [June 13, 2019, 1:53pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/4 "2019-06-13T13:53:24Z")

</div>

Yup, you should be able to. Just have to make sure you load the animations into the image/sprite like in that example. Then call setFrame(…) with the index or key of the frame you want to change to.

---

<div class="post-metadata">

**Author:** ![Ananth](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Ananth](https://phaser.discourse.group/u/Ananth)\
**Post date:** [June 13, 2019, 2:01pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/5 "2019-06-13T14:01:05Z")

</div>

I use like sprite.setFrame(3).but it doesn’t make any changes.it still in frame one.

---

<div class="post-metadata">

**Author:** ![Sturb](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Sturb](https://phaser.discourse.group/u/Sturb)\
**Post date:** [June 13, 2019, 2:09pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/6 "2019-06-13T14:09:32Z")

</div>

Try passing in the name of the frame instead of the index. So the key it uses in the atlas.

---

<div class="post-metadata">

**Author:** ![Ananth](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Ananth](https://phaser.discourse.group/u/Ananth)\
**Post date:** [June 13, 2019, 2:16pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/7 "2019-06-13T14:16:37Z")

</div>

Thanks sturb,can you give me any example using name?

---

<div class="post-metadata">

**Author:** ![Sturb](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Sturb](https://phaser.discourse.group/u/Sturb)\
**Post date:** [June 13, 2019, 2:20pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/8 "2019-06-13T14:20:33Z")

</div>

Sure. In that link I posted, you can replace the four `this.add.sprite(..)` lines with `this.add.sprite(400, 100, 'gems').setFrame("prism_0001");`.

---

<div class="post-metadata">

**Author:** ![Ananth](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Ananth](https://phaser.discourse.group/u/Ananth)\
**Post date:** [June 13, 2019, 2:26pm UTC](https://phaser.discourse.group/t/load-json-file-and-change-frames/2772/9 "2019-06-13T14:26:39Z")

</div>

it works,thanks sturb
