Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephane303/a6f52a0ea31728eef2dc882886e1b4e2 to your computer and use it in GitHub Desktop.
Save stephane303/a6f52a0ea31728eef2dc882886e1b4e2 to your computer and use it in GitHub Desktop.
<template>
<div :id="id" style="float:left;margin:20px;">
</div>
</template>
<script>
import Phaser from 'phaser'
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App',
id: null,
game: null
}
},
destroyed () {
console.log('id:' + this.game.canvas.parentNode.id)
this.game.canvas.parentNode.removeChild(this.game.canvas)
this.game.destroy()
},
beforeMount () {
this.id = 'game' + this._uid
},
mounted () {
var config = {
parent: this.id,
type: Phaser.CANVAS,
audio: {noAudio: true},
width: 200,
height: 200,
scene: {
preload: preload,
create: create
}
}
this.game = new Phaser.Game(config)
function preload () {
}
function create () {
console.log(this)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment