• Content count

  • Joined

  • Last visited

About Polska296

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I found that you could use this.scene.start('Scene2', {Level : 2, Health : this.hero.health}) to pass data to another scene. However the next step I see in every example online is what confuses me which uses init in the next scene to get the data. Any time I use init, I get an error saying either init or data is not defines. Would someone be able to show me an example of passing the data to another scene and then logging the data in the console when moving to the new scene?
  2. Thank you B3L7! Your response helped me to understand a github example I found (https://github.com/jackyrusly/jrgame) and I just got it to work by creating a Basescene class that has the upload methods and then extending my scene 1 and scene 2 to Basescene, which each had different methods to load a different scene and characters. I am curious about your second way of doing it and would love to see an example once you get it to work in Phaser 3 if you would be willing to show it.
  3. I am creating my first game in Phaser (an RPG) and was wondering what the best way to set up the game would be. I have already set up the first scene and gotten everything to work as I want it. For different scenes, I will be changing the code in the preload and create functions to have different background images and characters show up on each scene. But I would like to keep the update function the same for all my scenes. What is the best way to get the update function into all my scenes? Below is a summary of how I set up my scene. class Scene1 extends Phaser.scene { preload() { This is where I load all my images used in the current scene} Will change for each scene create() { This is where I add my images and any text I have to the screen } Will change for each scene update() { Where all my functions for the game that allow the main character to battle other characters, assign movement to computer players, and other game play functions } Will stay the same for each scene }
  4. Polska296

    Loading an image by extending it to an object

    Just as an update and more info, I am able to get the sprite to show up and then assign it all the properties by using the below code. However I will have characters in this game that I will be reusing multiple times and do not want to have to write this each time the character appears. this.hero = this.add.sprite(300, 300, 'hero'); // Hero character this.hero.name = "Hero"; this.hero.power = 3; this.hero.defense = 3; this.hero.health = 15; this.hero.maxhealth = 15; this.hero.powerExp = 0; this.hero.defenseExp = 0; this.hero.healthExp = 0; this.hero.attackStance = "Aggressive";
  5. I am trying to load a character image along with the character object but am having trouble. Currently the game loads without any errors but my sprite does not appear on the screen. I have tried to find a solution online and have looked through the "including sprites/extending sprite demo" phaser example and another topic on here that was for extending phaser game objects. I think I may be close since the character object values appear on the screen but the character image does not. Below is my code. function Hero() { this.name = "Hero"; this.power = 3; this.defense = 3; this.health = 15; this.maxhealth = 15; this.powerExp = 0; this.defenseExp = 0; this.healthExp = 0; this.attackStance = "Aggressive"; } class Scene1 extends Phaser.Scene { constructor() { super({key:"Scene1"}); } preload() { this.load.image('hero', 'assets/sprites/characters/hero.png', 41, 55); } create() { this.hero = new Hero({ scene: this, x: 300, y: 300, key: 'hero', }) } Also, I just started using Phaser 3 and have no prior web game development experience so this might be something simple I am just missing.] Thanks in advance. Let me know if you need to see more of the code because I just included what is related to the character I want to load.