• Content Count

  • Joined

  • Last visited

About fariazz

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling

Contact Methods

  • Twitter

Recent Profile Visitors

1780 profile views
  1. Thanks that worked! If it helps anyone, this is how you can then retrieve the loaded object: // in preload() this.load.json('levelData', 'assets/level.json'); // in create() let data = this.cache.json.get('levelData');
  2. I'm using multiple scenes on a game, I'm using a scene (each one in it's own file) for the following: - Game itself - home screen - loading screen - a "boot" scene where I load the logo that I want to show in the loading screen I'm using mainly in ES5 and loading the files in this manner: <!-- index.html --> <script src="js/scenes/bootScene.js"></script> <script src="js/scenes/loadingScene.js"></script> <script src="js/scenes/homeScene.js"></script> <script src="js/scenes/gameScene.js"></script> <script src="js/main.js"></script> Each scene file looks like so: // create a new scene let homeScene = new Phaser.Scene('Home'); homeScene.create = function(){ // game background, with active input let bg = this.add.sprite(0, 0, 'backyard').setInteractive(); bg.setOrigin(0, 0); ETC... Adding them to my game like so: // our game's configuration let config = { type: Phaser.AUTO, width: 360, height: 640, scene: [bootScene, loadingScene, homeScene, gameScene], title: 'Virtual Pet', pixelArt: false, backgroundColor: 'ffffff' }; // create the game, and pass it the configuration let game = new Phaser.Game(config); Note I'm just loading my scenes in global variables, yes I'm polluting the global scope but I don't care. If you want to do it more elegantly you can load them in individual commonJS modules or ES6 modules, in my case I don't want to install 1000 node.js packages just to run the game so I'm doing it a bit old school.
  3. I think both are good options. Phaser 2 is a production-ready, mature frameworks that's been used professionally in all platforms. Phaser 3 on the other hand is just getting started, and as @blade2xs pointed out, the doc and examples are a bit behind. However, Phaser 3 is definitely mature enough to be used in production, you'll just have to do more work when it comes to finding answers. Phaser 3 offers significant performance improvements over Phaser 2. Also lots of new features which might be relevant to your game, more clean code and the option to code in ES6 all along the way. If you need to produce a game in a short period of time I'd suggest Phaser 2, if you want to learn and build skills I'd suggest Phaser 3 as the documentation and whatnot will catch up soon enough.
  4. All the assets are cached between scenes. If you load an asset in Scene A, you can then create say sprites from it in Scene B.
  5. Never mind! Found the answer in the Phaser newsletter:
  6. I'm looking at creating a loading screen, followed by a home screen, and the game screen. For that, I was thinking of using a Scene for each. My question is, if I do the preloading of the assets in the first scene (loading screen), and then move to the home scene, will the assets be available and cached between scenes? or does each scene need to load it's own assets?
  7. Does anyone know how to load a json file in the preload method in Phaser 3? The JSON folder of the examples in the Loader class are empty so I'm a bit stuck: http://labs.phaser.io/index.html?dir=loader/json/&q=
  8. I was wondering if it's expected behavior that camera effects are not reset when a scene is restarted. The following code will fade out, and the screen will remain black after the scene is restarted: gameScene.create = function() { // create a sprite let bg = this.add.sprite(100, 100, 'treasure'); // fade out this.cameras.main.fade(1000); // restart the scene this.time.delayedCall(2000, function() { this.scene.restart(); }, [], this); What I'm adding at the moment is `this.cameras.main.resetFX();` when initiating a scene in order to have the view back, but it kind of feels like the camera subsystem should refresh as well when using `this.scene.restart()`.
  9. fariazz

    Resetting a scene

    this.scene.restart(); works in Phaser 3.4
  10. I can confirm this is fixed on my end when using Phaser 3.4 for the `restart` method, however not when using the `rebootScene` method. The following code works fine on my end (sprites get cleared after scene restarting): // called once after the preload ends gameScene.create = function() { // create sprites at random let sprite1 = this.add.sprite(Math.random() * 400, Math.random() * 400, 'treasure'); let sprite2 = this.add.sprite(Math.random() * 400, Math.random() * 400, 'treasure'); let sprite3 = this.add.sprite(Math.random() * 400, Math.random() * 400, 'treasure'); let sprite4 = this.add.sprite(Math.random() * 400, Math.random() * 400, 'treasure'); this.time.delayedCall(3000, function() { this.scene.restart(); }, [], this); }; If instead of using `this.scene.restart()` I type `this.scene.manager.bootScene(this);`, the sprites don't get cleared after scene rebooting - they just accumulate on the screen. Not sure if that's the intended behavior of bootScene but thought it'd be good to mention it.
  11. Using this.scene.restart() unfortunately still doesn't solve the issue. Sprites are still not cleaned from the scene. Just tested building from the latest master branch commit:
  12. There is a new Scene manager restart() method coming in Phaser 3.4: https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md#new-features Will give this a try tomorrow
  13. I'm with you. The main thing I want to know is if we are doing it right but there is a bug in how scenes are being rebooted, or if we are doing it wrong and missing something important.