• Content count

  • Joined

  • Last visited

  1. Best way to handle event

    Hey there guys! I working on chess game with Phaser 3. And so far everything is amazing. Right now I'm working on event handlers for the pieces(figures). Take a look: for(let i = 0; i < this.pieces.length; i++) { this.pieces[i].setInteractive(); this.pieces[i].on('clicked', ()=>{ console.log('Piece clicked')); }, this); } This is taken from the example HERE. So my problem is this fragrament of the code: this.input.on('gameobjectup', function (pointer, gameObject) { gameObject.emit('clicked', gameObject); }, this); Can someone explain the whole structure? Or maybe suggest cleaner way to do it?
  2. Is it still acceptable to use Phaser 2?

    I suggest you to use Phaser 2.6. It's a stable and has a great documentation. If you use Phaser 3, you will need some basic understandings, since there is no documentation right now(correct me if I'm wrong). There are some examples HERE.
  3. Can't add image in non Scene class

    Works perfectly! Thanks
  4. Can't add image in non Scene class

    Hey there guys! I working on first MVC project with Phaser 3(3.4.0) with Typescript export class Game extends Phaser.Scene { constructor() { super({ key: GAME_SCENE_KEY }); } create() { console.log('This is game scene'); this.add.image(500, 300, BLACK_CELL_IMAGE_KEY); this.add.image(564, 300, WHITE_CELL_IMAGE_KEY); this.add.image(500, 364, WHITE_CELL_IMAGE_KEY); this.add.image(564, 364, BLACK_CELL_IMAGE_KEY); } } So this code fragment works perfectly. But when I try to add a image in non Scene class it doesn't work. export abstract class UIElement{ game: Phaser.Game; cellSprite: Phaser.GameObjects.Image; position: Phaser.Geom.Point; constructor(game: Phaser.Game, rowPos: number, columnPos: number) { this.game = game; this.position = new Phaser.Geom.Point(rowPos, columnPos); this.add.image(this.position.x, this.position.y); } } This is a part of the View that I'm working for the MVC but I can't really get away from this. this.add.image(this.position.x, this.position.y); Any ideas?
  5. Hello guys, I'm new to game development but I have some background on HTML/CSS/JS that's why I found Phaser perfect for me. So far I'm really loving it but can't understand some basic game logics. For example: What is the best way to build platforms? I was reading about groups but not sure is it the right way to do it. Let's just say that I have sprite and I want to build specific pattern. So far I tried : Every platform is diffrent sprite Using single tile to build platforms Also is there any books or other sources for information about game logics and good practices? Thank you and sorry for my bad English