Error message in Phaser 3 (Typescript): "The property 'start' is not defined on the 'Scene' type."

I've encountered an issue with switching scenes in Phaser 3. I have attempted to use scene.switch and scene.start, but it seems that these are not recognized methods on the Phaser.Scene object in Phaser 3. How can I go about changing scenes in Phaser 3? Any assistance would be highly appreciated, as I have been unable to find any alternative solutions. Thank you!

// Entry point for My Game

    HomePage.ngZone.runOutsideAngular(() => {
      this.config = {
        type: Phaser.AUTO,
        scale: {
          mode: Phaser.Scale.FIT,
        },
        parent: 'game',
        scene: [MazeScene, MainScene],
        physics: {
          default: 'matter',
          matter: {
            debug: false,
            gravity: {
              y: 0.0,
              x: 0.0,
            },
          },
        },
      };
      this.phaserGame = new Phaser.Game(this.config);
    });

After trying both scene.start('main') and scene.swap('main'), I discovered that neither of these methods exist within the Phaser.Scene class in Phaser 3.

Answer №1

After some trial and error, I discovered that referencing the scene from sys.game.scene was necessary in order to make it work.

this.scene.sys.game.scene.switch('mazeScene', 'mainScene')

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Panoramic viewer for Three.js with multi-resolution image support

Is there a way to incorporate a three.js panorama viewer with multi-resolution images similar to pannellum? Check out pannellum's example here: . You can find the current code using three.js here:(//codepen.io/w3core/pen/vEVWML). Starting from an e ...

Issue with Angular custom toggle functionality not functioning properly on mobile devices

I've been working on creating a custom toggle feature in Angular. While everything runs smoothly on desktop, I'm encountering issues on mobile devices. On desktop, the toggle works by clicking and dragging to the right, whereas on mobile, it shou ...

Create a filter for a table using select and jQuery

I've been working on a select filter to update a table, and while it works perfectly for one select element, I'm encountering an issue when trying to use multiple select elements simultaneously. Here is the code snippet (also available in this J ...

Utilizing jQuery to Construct a Multi-Level Array

Struggling to understand how to create a multidimensional array in jQuery. I've declared the array outside of the loop. <script> var myArray = []; </script> Within the loop, I intend to add elements to the array. i = 0 [loop sta ...

Remove any extra space from the fields before sending an Angular post request

I am looking for a way to eliminate all whitespace from three fields (leading, trailing, and between characters) before they are sent to the backend via an Angular post request. The data is coming from the form data object. Currently, I have managed to ach ...

Using AJAX to Post Data with Relative Path in ASP.NET MVC 5

I have been developing an MVC 5 web application that utilizes AJAX Posts to invoke Controller Actions. For example, I have a controller named "Account" with an action called "Create". In my Account/Index view, which is rendered by accessing an Account/Ind ...

html5-jquery checkbox change event not firing

I successfully implemented an on/off switch using the method outlined in for HTML5. The functionality of the switch itself is working perfectly - click on it to toggle between states and query the checked state of the input/checkbox. However, I am facing ...

Isolating Express.js Requests for Enhanced Security

In my Node.js Express app, multiple users send requests to the server for various actions such as earning points, changing email addresses, and interacting with other users. My server code utilizes several setTimeouts, leading me to question whether diffe ...

How can I trigger a modal when I receive data in a partial view from the controller in ASP.NET MVC?

How can I call a modal after returning data in a partial view from my controller? Here are the details of my controller and view: Controller [HttpPost] public async Task<ActionResult> Items(List<string> items) { var dto ...

Iterate through and conduct conditional verification

In my project using AngularJS and HTML, I have created a table to display records. I am looking for a way to iterate through the column values and strike through any value in the column that meets a certain condition. For example, in the demo provided her ...

Discovering the process of extracting a date from the Date Picker component and displaying it in a table using Material-UI in ReactJS

I am using the Date Picker component from Material-UI for React JS to display selected dates in a table. However, I am encountering an error when trying to show the date object in a table row. Can anyone provide guidance on how to achieve this? import ...

Restrict the occurrence of a specific element in the array to a maximum of X times

Functionality: A feature in this program will randomly display elements from an array. Each element can only be shown a certain number of times. Issue: I am unsure how to limit the number of times each element in the array is displayed. Currently, all ...

Uncovering the xpath of an element within an iframe using QTP

When attempting to set a value in the <input type="file" name="file007"> element using QTP, I encountered an issue. The element is located within an iframe, making it inaccessible through xpath on the page. <iframe id="file_007" src="javascript:& ...

The ng-token-auth plugin in combination with the ui-router resolver leads to a blank

I have been referring to the ng-token-auth documentation here in an attempt to implement a resolver for authentication using the validateUser function. However, when I add the code snippet provided in the documentation to my app.js file under the "home" st ...

Error Message in Terminal When Launching React Application Using Webpack

I am encountering several errors in the node terminal while attempting to launch my react-app [at-loader] ./node_modules/@types/webpack/index.d.ts:23:16 TS2665: The module name in augmentation is invalid. Module 'webpack/lib/dependencies/HarmonyE ...

STLLoader not working as expected in Vue component

I've been working on incorporating the THREE STLLoader to display an object within my Vue scene. (I am utilizing the Vuetify framework, although that shouldn't impact the functionality of the THREE renderer.) Despite my efforts, I am struggling ...

Angular 2 component downgrade issue: What causes the error when constructor parameters are involved? (SystemJS) Unable to resolve all parameters for (?)

Consider this line as an example: constructor(private elementRef: ElementRef, private zone: NgZone) {} In order for the downgrade to be successful without any errors, I must remove the parameters from the constructor. Otherwise, I encounter the follo ...

Error came up as "backbone.radio.js" and it threw Uncaught SyntaxError since the token import appeared unexpectedly

I've been struggling to transition an application from Backbone to Marionette (v3) for the past two days. Every time I try to run the app in the browser, I keep encountering this error in the console (resulting in a blank screen): Uncaught SyntaxErr ...

Deactivate the submission button when there are no search results in typeahead.js

How can I disable the submit button if there are no search results found? The form should not be submitted in this scenario. I am currently using typeahead.js for my code. $('.typeahead').typeahead(null, { name: 'suburb', disp ...

Preserve and recover the dynamic form value following an AJAX update

Looking for a solution for saving and restoring user comments on dynamically created form fields in a page where users can comment on posts. How can we save and restore the typed comments before an ajax refreshes the div holding all the post and comments? ...