Giter Club home page Giter Club logo

vue-phaser3's Introduction

vue-phaser3

Webpack boilerplate that integrates Phaser 3 into a Vue 3 project.

This project template has been set up using the Vue CLI 5 and includes:

  • Sass
  • CSS Postprocessing
  • Babel
  • Source Minification

Build Setup

# install dependencies
npm install

# serve with live reloading at localhost:8080
npm run serve

# build for production with transpilation / minification
npm run build

# serve your production build at localhost:5000
npm start

Extending the project to your needs

If you want to add more features like linting, unit testing or Typescript to your own project, you can do so quite easily via Vue CLI's plugin system. Read the documentation if you want to know more.

Converting into your own repository

If you want to maintain your own repo based on this boilerplate, you first need to detach it from this repo. Here is what you need to do:

  1. edit these files and enter your own project info

    • package.json
    • README.md
    • public/index.html
  2. delete LICENSE (and perhaps add your own)

  3. reinitialize git

rm -rf .git
git init
git add .
git commit -m "Initial commit"

Sharing data between Vue and Phaser

You might want to expose some game state that lives inside of your Phaser code to your Vue components and vice versa, for example a highscore. Here are two ways you can achieve sharing state between the frameworks.

  • Import a Phaser EventEmitter instance in both your Vue components and Phaser modules. Both sides can then listen to and emit events on that emitter.

  • Have both sides share a Pinia store instance. It works like an event emitter, but can also hold state. The Pinia store is nicely integrated into your Vue components and is easily accessible on the Phaser side by applying the useStore hook.

vue-phaser3's People

Contributors

dependabot[bot] avatar sun0fabeach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-phaser3's Issues

How to import spine plug-ins

Looking forward to your answer!
This is the first time I have built a project in this way,Want to use spine plug-ins.But I don't know what to do.

Phaser parent not taking effect

The issue seems to be with the components/Game.vue. The div is broken and there should only be one item in the template tag. This should fix the issue:

<template>
  <div>
    <div id="game-container"></div>
    <div class="placeholder" v-if="!downloaded">
      Downloading ...
    </div>
  </div>
</template>

import for game fails on Heroku

This line causes an error on Heroku deployment:
const game = await import(/* webpackChunkName: "game" */ '@/game')

This dependency was not found:
       
       * @/game in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Game.vue?vue&type=script&lang=js&
       
       To install it, you can run: npm install --save @/game
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.o4QiG/_logs/2020-05-26T10_47_11_732Z-debug.log
-----> Build failed

Same line of code is working on local dev and local build.

Error: Loading chunk game failed.

Hi..I have a problem when working on project on serve mode using vue-cli-service serve. When I open the application, thus the chunk game is loaded but when I change something in the application and reload the page I get this error..

Error in mounted hook (Promise/async): "ChunkLoadError: Loading chunk game failed.

Screenshot from 2021-04-10 13-59-44

Why Phaser + Vue.js ?

I am using Phaser with Vue.js also. But I have a hard time to figure out why I use it with Vue.js 😄 ?
What is the benefit of using Phaser with Vue.js? Love to hear some good reasons!

Module build failed: SyntaxError: 'import' and 'export' may only appear at the top level (20:4)

Hello,
It's more a question than really an issue.
I didn't use all of your code, but tried to integrate most of it to my current project.

in Game.vue, in the mounted() event, you did this :

mounted() {
    import(/* webpackChunkName: "game" */ '@/game/game').then(game => {
      this.downloaded = true
      this.$nextTick(() => game.launch())
    })
  }

There it crashes for me, stating that import can only appear at top level.
But then I notice there is an annotation for webpack...
Any lead on how this works ?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.