# Organizing Scenes

**URL:** <https://phaser.discourse.group/t/organizing-scenes/3214>\
**Category:** Phaser 3\
**Created:** [July 23, 2019, 3:38pm UTC](https://phaser.discourse.group/t/organizing-scenes/3214 "2019-07-23T15:38:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackBruno](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jackbruno/32/3459_2.png) [@JackBruno](https://phaser.discourse.group/u/JackBruno)\
**Post date:** [July 23, 2019, 3:38pm UTC](https://phaser.discourse.group/t/organizing-scenes/3214/1 "2019-07-23T15:38:25Z")

</div>

Greetings!  
I am creating a 2d side-scroller game where I have only 2 levels but I have a problem. I will re-write all the codes again in the `create()` function in `level1Scene into my level2Scene`.

So my question is, is there a way where I can create a scene where I can drop the `character creation, character control functions, sounds, etc...` so it can be accessed in any scenes?  
Thank you.

---

<div class="post-metadata">

**Author:** ![ThePandaJam](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thepandajam/32/1814_2.png) [@ThePandaJam](https://phaser.discourse.group/u/ThePandaJam)\
**Post date:** [July 23, 2019, 4:39pm UTC](https://phaser.discourse.group/t/organizing-scenes/3214/2 "2019-07-23T16:39:24Z")

</div>

You can, if you make the character sprites into separate objects. I use something similar to this:

```
/*Obstacle class*/
class Obstacle extends Phaser.Physics.Arcade.Sprite {
	constructor(scene, x=0, y=0, texture = 'obstacle', frame = 0) {
	  super(scene,x,y,texture,frame)
	  scene.add.existing(this)
	  scene.events.on('update', this.update, this)
	}
}

```

This object can be accessed in any scene, but I still have to have this code in the `create()` function for each level:

```
this.obstacle = new Obstacle(this,x, y,texture,frame);

```

You can make character control into a function, but I currently do not know if you can make it into a function outside of the scene. perhaps if you add it to your character class?

Hope this helps a bit.

P.S. what changes between the scenes? Because if it’s just the background or map, I believe you can keep it in the same scene and just change the assets

---

<div class="post-metadata">

**Author:** ![JackBruno](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jackbruno/32/3459_2.png) [@JackBruno](https://phaser.discourse.group/u/JackBruno)\
**Post date:** [July 23, 2019, 5:43pm UTC](https://phaser.discourse.group/t/organizing-scenes/3214/3 "2019-07-23T17:43:29Z")

</div>

Thanks for the reply.

-Okay, I’ll give it a try to apply this code you gave.

> P.S. what changes between the scenes? Because if it’s just the background or map, I believe you can keep it in the same scene and just change the assets

-Yes, only the JSON Tilemap will change.

---

<div class="post-metadata">

**Author:** ![jorbascrumps](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jorbascrumps/32/1649_2.png) [@jorbascrumps](https://phaser.discourse.group/u/jorbascrumps)\
**Post date:** [July 23, 2019, 11:03pm UTC](https://phaser.discourse.group/t/organizing-scenes/3214/4 "2019-07-23T23:03:09Z")

</div>

If you’re interested, I wrote an [article](https://dev.to/jorbascrumps/loading-server-generated-tilemaps-with-phaser-4mm7) that may help you with this. I approached it from the angle of loading map data from an API, but I do go over a technique that you could easily adapt to your use case.
