3.0.17 • Published 11 months ago

nuxtjs-phaser v3.0.17

Weekly downloads
3
License
MIT
Repository
github
Last release
11 months ago

Nuxt Phaser

workflow

This plugin empowers your game using Vue/Nuxt.

Why Vue and Nuxt?

With Vue/Nuxt you can make web development simple and powerful, using these features:

  • Build
  • Tests
  • Plugins (like Workbox, GTM, Adsense, ...)

Setup

  • Add nuxtjs-phaser dependency using yarn or npm to your project
npm install nuxtjs-phaser --save
yarn add nuxtjs-phaser
  • Add nuxtjs-phaser to plugins section of nuxt.config.js
  plugins: [
      { src: 'node_modules/nuxtjs-phaser', mode: 'client' }
  ],

Usage

Loading phaser manually

You can load phaser on your component, where and how you want:

const myGame = new Phaser.Game()
this.$phaser.initialize(myGame)

Loading phaser by component

You can load phaser using vue component:

import PhaserGame from 'nuxtjs-phaser/phaserGame.vue'

<div>
    <PhaserGame :createGame="createGame" />
<div>

Phaser Events

Phaser uses has own Event Emitter, this plugin allows you to emit and listen to events between Vue (Nuxt) and Phaser.

// listen events
this.$phaser.eventEmitter.addListener('jump', ({ superJump = false }) => {
  myPlayer.jump(superJump)
}, this)

// emit events with args
this.$phaser.eventEmitter.emit('jump', { superJump: false })

Built-in Events

  • pause

    Pause a scene.

// emit events with args
this.$phaser.eventEmitter.emit('pause', 'level')
  • resume

    Resume a scene.

// emit events with args
this.$phaser.eventEmitter.emit('resume', 'level')
  • restart

    Restart a scene.

// emit events with args
this.$phaser.eventEmitter.emit('restart', 'default')

Project sample

Check out this project sample.

Nuxt example

Nuxt example

Articles

3.0.16

12 months ago

3.0.17

11 months ago

3.0.14

12 months ago

3.0.15

12 months ago

3.0.9

1 year ago

3.0.12

1 year ago

3.0.4

1 year ago

3.0.13

1 year ago

3.0.3

1 year ago

3.0.10

1 year ago

3.0.2

1 year ago

3.0.11

1 year ago

3.0.1

1 year ago

3.0.8

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.0

1 year ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.9-0

4 years ago

1.0.8-0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago