NUGA

Members
  • Content Count

    9
  • Joined

  • Last visited

About NUGA

  • Rank
    Newbie

Recent Profile Visitors

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

  1. When designing a game, at some point we will have to switch to another scene (level, main menu whatever). A way to do this is every level, for example, will be a scene. When the time to change scenes comes, just change them. However some code, at least the way i'm doing, reapeats: input handler in the update, score texts, etc. So i wonder if there is a better way of structuring the code in way that this won't happen?
  2. Just like when you flip the sprite of you character you would do something like: this.mario.flipX = true; Is it possible to do the something but for an entire group?
  3. NUGA

    Play Group animation

    There's a lot of examples on this in Phaser 2 but i cannot find anything about phaser 3 on how to make every child of a given group to play an animation
  4. I'm trying to make a Mario styled platformer, and i'm running into a problem where the jumping animation is overridden by the walking animation when pressing the up and right(or left) arrow keys together. Here's what i have in regards of the update and playing the animations. The character sprite is loaded as a spritesheet if it makes a difference. if(this.cursors.right.isDown){ this.mario.play('walk', true); this.mario.flipX = false; this.mario.body.setVelocityX(500); } else if(this.cursors.left.isDown){ this.mario.play('walk', true); this.mario.flipX = true; this.mario.body.setVelocityX(-500); } else{ if(this.mario.body.onFloor()){ this.mario.play('stand'); }else { this.mario.play('jumping'); } this.mario.body.setVelocityX(0); } if(this.cursors.up.isDown && this.mario.body.onFloor()){ //this.mario.play('jumping'); this.mario.body.setVelocityY(-600); }
  5. So i'm trying to switch scenes when a tween is complete, however i get the titular error 'Cannot read property 'start' of undefined' , and i don't know why this is... Here's the code: class StartScreen extends Phaser.Scene{ constructor(){ super({key: "StartScreen"}); } preload() { this.load.image('Logo', 'assets/Logo.png'); this.load.spritesheet('background', 'assets/backs.png' , { frameWidth: 480, frameHeight: 320 }); } create() { this.anims.create({ key: 'stars', frames: this.anims.generateFrameNames('background', { start: 0, end: 127 }), repeat: -1 }); this.add.sprite(1024/2 , 400, 'background').play('stars', true).setScale(2.5); this.logo = this.add.image(1024/2 , 300, 'Logo').setScale(2); this.text = this.add.text(320, 450, 'Push Enter', { font: '50px NES', fill: '#FFF'}); this.enter = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ENTER); } update(){ if(this.enter.isDown){ this.text.destroy(); this.enter = ''; this.tweens.add({ targets: this.logo, y: 150, duration: 2000, onComplete: this.onCompleteHandler }); } } onCompleteHandler(){ this.scene.start('MainMenu'); } } class MainMenu extends Phaser.Scene{ constructor(){ super({key: "MainMenu"}); } preload() { this.load.image('Logo', 'assets/Logo.png'); this.load.spritesheet('background', 'assets/backs.png' , { frameWidth: 480, frameHeight: 320 }); this.anims.create({ key: 'stars', frames: this.anims.generateFrameNames('background', { start: 0, end: 127 }), repeat: -1 }); this.add.sprite(1024/2 , 400, 'background').play('stars', true).setScale(2.5); this.add.image(150 , 300, 'Logo').setScale(2); } create() { } }
  6. NUGA

    Playing GIFs in Phaser 3

    For anyone interested, i solved this by converting my GIF to a sprite sheet. Keep in mind that if your sprite sheet has only 1 column, it may become to big of a file (in one of its dimensions) and unable to be loaded by phaser. If this happens, try making a matrix sprite sheet, that is, a sprite sheet with multiple column. Then just create an animation as you would with a simple character model (as in the 'making your first game' tutorial provided for phaser 3 getting started guide).
  7. NUGA

    Playing GIFs in Phaser 3

    Is it possible, and if so how, to play GIFs in phaser 3?
  8. let MainMenu = new Phaser.Class({ Extends: Phaser.Scene, initialize: function MyScene(config) { Phaser.Scene.call(this, config) }, preload: function () { this.load.image('Logo', 'assets/Logo.png'); }, create: function () { this.Logo = this.add.image(1024/2 ,100, 'Logo').setScale(2); Phaser.Display.Align.In.TopCenter(Logo); } }); I have this class (Scene?) that should represent my game's main menu. But, i want to pass to this class the game object that i'm creating in another file. In this case i want it merely to set my game's logo in top center using game.width and game.height as a way to make the logo be correctly placed with any size of the canvas. How can i do it?
  9. Hey i'm doing a small project in which, when i click on an object the game resets: positions, timers, everything goes back to the same way it was when it was first opened. Is there a way to do this? Something like game = new Phaser.Game(config) ?