![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Phavuer is a wrapper library for Phaser 3 with Vue 3.
It makes able to develop games with declarative rendering.
*** Attention ***
However, I am keep going to use it for make my game.
Feel free to contribute.
MainScene.vue:
<template>
<Scene name="MainScene">
<Text @pointerdown="onClick" text="Add a Rectangle" />
<Container v-for="(n, i) in count" :key="i" :x="i * 130" :y="30">
<Rectangle :width="120" :height="30" :origin="0" :fillColor="0x333333" />
<Text :x="60" :y="15" :origin="0.5" :text="`Rectangle-${n}`" />
<MyCustomComponent />
</Container>
</Container>
</template>
<script>
import { Scene, Container, Rectangle, Text } from 'phavuer'
import { ref } from 'vue'
import MyCustomComponent from './MyCustomComponent'
export default {
components: { Scene, Container, Rectangle, Text, MyCustomComponent },
setup () {
const count = ref(1)
const onClick = () => count.value++
return { count, onClick }
}
}
</script>
The template syntax follows Vue 3 as it is. (doc)
There are no orignal syntax.
How setting up a component is also same. (doc)
index.js:
import { createPhavuerApp } from 'phavuer'
import MainScene from './MainScene'
new Phaser.Game({
..
scene: {
create () {
createPhavuerApp(this.game, MainScene)
}
}
})
In addition to Phaser 3, Vue 3 is needed.
Phavuer must be placed below them.
<script src="https://unpkg.com/phaser@3.50.1/dist/phaser.min.js"></script>
<script src="https://unpkg.com/vue@3.0.4/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/phavuer/dist/phavuer.min.js"></script>
const { Scene } = Phavuer
const MainScene = {
components: { Scene },
template: '<Scene>...</Scene>',
setup () {
return {}
}
}
new Phaser.Game({
..
scene: {
create () {
createPhavuerApp(this.game, MainScene)
}
}
})
Install Vue 3 and Phavuer:
$ yarn add vue@^3 phavuer
These packages are also necessary to compile:
$ yarn add -D @vue/compiler-sfc vue-loader@^16
Following option should be merged into your webpack.config.js
:
const { VueLoaderPlugin } = require('vue-loader')
module.exports = () => ({
// Make webpack able to compile '.vue' files with 'vue-loader'
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
}
]
},
plugins: [
new VueLoaderPlugin()
],
// Make webpack able to import '.vue' files without extension
resolve: {
extensions: ['.js', '.vue']
},
...
})
createPhavuerApp(gameInstance, rootComponent)
Parameters:
gameInstance
: Game instance of Phaser
rootComponent
: Root Vue component
Return value:
App instance of Vue
refTo(value, key)
Parameters:
value
: Initial value
key
: Key string of what property of given new value should be set
Return value:
Instance of CustomRefImpl
Usage:
Can be used to get such as a GameObject easily.
const rectangle = refTo(null, 'object')
<Rectangle ref="rectangle">
refObj(value)
A sugar function for refTo(value, 'object')
refScene(value)
A sugar function for refTo(value, 'scene')
onPreUpdate(event)
A method to register an event on pre update of the scene.
onPostUpdate(event)
A method to register an event on post update of the scene.
Scene
Scene
component is used for make your scene component.
Props:
name
: (String) Scene nameautoStart
: (Boolean) Scene is started immediately if true
The name can be received from props, so you can use it as is: <Scene :name="props.name">
Events:
init (scene, data)
create (scene, data)
update (scene, time, delta)
preload (scene)
Properties:
scene
Scene objectIf you want to handle multi scenes, root component supposed to be like this:
<template>
<GameScene />
<UIScene />
</template>
<script>
import GameScene from './GameScene'
import UIScene from './UIScene'
export default {
components: { GameScene, UIScene }
}
</script>
Base Components are basic components for each Phaser 3's GameObjects such as Sprite
or Rectangle
.
You can use them like this: <Rectangle :x="0" :y="0" :width="10" :height="10" />
object
<Rectangle ref="el" />
+ el.value.object
(from outside: el.object
)@create
(GameObject)
:tween
targets
of the options will be set automaticallyCurrently Phavuer has following base components:
If you want to use another GameObjects, plase make an issue or MR.
Also you can make base components just in your project. (refer)
initGameObject(gameObject, props, context)
This method gives following features to the given gameObject:
x
or y
(see all)@pointerup
@create
Parameters:
gameObject
: Phaser 3 GameObject instanceprops
: Vue 3 propscontext
: Vue 3 contextIt is used to define Base Components. (like this)
If you just want to use your component in your another component, you don't need this method.
For such a case, you just need to relay props to default components.
FAQs
A wrapper library that integrates Phaser 3 with Vue 3.
The npm package phavuer receives a total of 46 weekly downloads. As such, phavuer popularity was classified as not popular.
We found that phavuer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.