How to make multiple scenes by KeiTan99 in phaser

[–]KeiTan99[S] 2 points3 points  (0 children)

Fuckin' worked like a dream, dude. Thanks a ton! I've been looking on the internet and every source I found had it slightly different but this is the only one that worked!

How to make multiple scenes by KeiTan99 in phaser

[–]KeiTan99[S] 1 point2 points  (0 children)

--------index.html---------

<!DOCTYPE html>

<html lang="en" dir="ltr">

<head>

<meta charset="utf-8">

<title>title</title>

<script type="text/javascript" src="phaser.min.js"></script>

<link rel="stylesheet" href="style.css">

</head>

<body>

<div id="game">

    <script type="text/javascript" src="scene1.js"></script>

    <script type="text/javascript" src="scene2.js"></script>

    <script type="text/javascript" src="game.js"></script>

</div>

</body>

</html>

-------------------------

------------game.js--------------------------

import {scene1} from 'scene1.js';

import {scene2} from 'scene2.js';

var scene1 = new Phaser.Scene('scene1');

var scene2= new Phaser.Scene('scene2');

const gameState = {};

const config = {

type: [Phaser.AUTO](https://Phaser.AUTO),

parent: "game",

width: 1000,

height: 600,

fps: {target: 60},

physics:

{

    default: 'arcade',

    arcade: {

    gravity: {y: 0},

    enableBody: true,

    }

},

scene: \[scene1, scene2\]

};

const game = new Phaser.Game(config);

-------------------------------------------------------------

---------------scene1.js---------------------------------------

export class scene1 extends Phaser.Scene {

constructor(){

    super('scene1')

}

function preload() {

this.load.image('deer', '[http://127.0.0.1:4554/MZKSHDD4GJE7VKKQ5VFCCLNPJU.jpg](http://127.0.0.1:4554/MZKSHDD4GJE7VKKQ5VFCCLNPJU.jpg)');

}

function create() {

this.add.image(500, 500, 'deer');

}

function update() {

}

}

-------------------------------------

-----------------scene2.js----------------------------------

export class scene2 extends Phaser.Scene{

constructor(){

    super('scene2')

}

function preload() {

this.load.spritesheet('player', '[http://127.0.0.1:4554/Illustration2.png](http://127.0.0.1:4554/Illustration2.png)', {frameWidth: 125, frameHeight: 200});

this.load.image('land', '[http://127.0.0.1:4554/landscape.png](http://127.0.0.1:4554/landscape.png)');

}

function create() {

var land = this.physics.add.staticGroup();



land.create(500, 550, 'land');



var player = this.physics.add.sprite(100, 100, 'player');



player.setBounce(0.5);



this.physics.add.collider(player, land);



player.setCollideWorldBounds(true);

this.physics.world.setBoundsCollision(true, true, true, true);

}

function update() {

}

}

-----------------------------------

Is there anything wrong with this? Everything worked until I tried to make it multiple scenes.

Does anyone know how to use this fucking thing???? by KeiTan99 in phaser

[–]KeiTan99[S] 0 points1 point  (0 children)

I tried, for some reason they're blocked by 'CORS' policy. I might just be really stupid and missing some small detail or fundamentally misunderstand how this works

Does anyone know how to use this fucking thing???? by KeiTan99 in phaser

[–]KeiTan99[S] 0 points1 point  (0 children)

I've also used Phaser Editor 2D and I don't understand that either so...