B.Guyl

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. B.Guyl

    Generic platformer + ES6 / Webpack 4 boilerplate

    Thanks, that's a great source of examples ! I'm curious about some of your choices on your Webpack config. 1. Is there any benefit from using BrowserSync instead of Webpack dev server ? Or this choice come from the others repos you refer to ? 2. In my project, I use both file-loader and a static folder for my assets. I don't know which way is the good way neither if one option is better than the other. I see you serve your assets in a static folder. Is there a reason ? 3. I copied the following part from another repo and I see you have it too. But I don't know the purposes of theses lines. Can you explain ? var definePlugin = new webpack.DefinePlugin({ __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')), WEBGL_RENDERER: true, // I did this to make webpack work, but I'm not really sure it should always be true CANVAS_RENDERER: true // I did this to make webpack work, but I'm not really sure it should always be true })
  2. B.Guyl

    Efficient drag and drop ?

    Thank's ! Now my code look like this: export class Card extends Phaser.GameObjects.Sprite { constructor (scene: Phaser.Scene, x: number, y: number, frame?: string) { super(scene, x, y, 'cards', 'back') this.setInteractive() scene.input.setDraggable(this) scene.input.on('drag', (pointer: any, gameObject: Card, dragX: number, dragY: number) => { gameObject.x = dragX gameObject.y = dragY }) } } I probably should move the event listener on the scene level. Is this working better because the `drag` event fire more events thant `pointermove` ?
  3. B.Guyl

    Efficient drag and drop ?

    Hi ! I started with Phaser3 this weekend, I wanted to make a card game. I'm struggling with the lack of documentation. My current way to make a draggable object is to track the position of the `pointermove` event. export class Card extends Phaser.GameObjects.Sprite { constructor (scene: Phaser.Scene, x: number, y: number, frame?: string) { super(scene, x, y, 'card', frame) this.setInteractive() this.on('pointerdown', () => this.dragOn()) this.on('pointerup', () => this.dragOff()) } private dragOn (): void { this.addListener('pointermove', (e: any) => { this.x = e.event.x this.y = e.event.y }) } private dragOff (): void { this.removeAllListeners('pointermove') } } But I have an issue when I move my mouse too fast. Is there a good way of doing this ? Also, bonus question: Is there a list of available events ?