Comparing version 0.4.2 to 0.5.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Vue")):"function"==typeof define&&define.amd?define(["Vue"],t):"object"==typeof exports?exports.Phavuer=t(require("Vue")):e.Phavuer=t(e.Vue)}(this,(function(e){return(()=>{"use strict";var t={289:(e,t,i)=>{i.r(t),i.d(t,{Circle:()=>u,Container:()=>a,Image:()=>h,Light:()=>m,Line:()=>g,Rectangle:()=>c,RoundRectangle:()=>x,Scene:()=>l,Sprite:()=>d,Text:()=>p,TilemapLayer:()=>y,Zone:()=>f,createPhavuerApp:()=>k,initGameObject:()=>v,refObj:()=>S,refScene:()=>w,refTo:()=>b});var r=i(5);const s={Scene:{props:{name:{type:String,require:!0},autoStart:{type:Boolean,default:!0}},setup(e,t){const i=(0,r.ref)(!0),s=class extends Phaser.Scene{init(e){i.value=!0,t.emit("init",this,e)}create(e){t.emit("create",this,e)}update(e,i){t.emit("update",this,e,i)}preload(){t.emit("preload",this)}},n=(0,r.inject)("game").scene.add(e.name,s,e.autoStart);return n.events.on("shutdown",(()=>i.value=!1)),(0,r.provide)("scene",n),{scene:n,show:i}},render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div",null,[s.show?(0,r.renderSlot)(e.$slots,"default",{key:0}):(0,r.createCommentVNode)("v-if",!0)])}},Container:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Container{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0);return v(n,e,t),(0,r.provide)("container",n),{object:n}},props:["visible","width","height","rotation","x","y","depth","alpha"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div",null,[(0,r.renderSlot)(e.$slots,"default")])}},Rectangle:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Rectangle{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0,e.width,e.height);return v(n,e,t),{object:n}},props:["visible","x","y","rotation","width","height","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},RoundRectangle:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Graphics{constructor(e,t,i,r,s,n){super(e,t,i,r,s),this._originX=0,this._originY=0,this._width=r||0,this._height=s||0,this._radius=n||0,this._fillColor=null,this._fillAlpha=1,this._lineWidth=0,this._strokeColor=null,this._strokeAlpha=1,this.setRenderFlag(!0)}preUpdate(...e){this.renderFlag&&this.render(),t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}setRenderFlag(e){this.renderFlag=e}render(){this.setRenderFlag(!1);const e=this.originX*-this.width,t=this.originY*-this.height,i="number"==typeof this.radius?Math.min(this.radius,this.width.half,this.height.half):this.radius;this.clear(),null!==this.fillColor&&(this.fillStyle(this.fillColor,this.fillAlpha),this.fillRoundedRect(e,t,this.width,this.height,i)),this.lineWidth&&null!==this.strokeColor&&(this.lineStyle(this.lineWidth,this.strokeColor,this.strokeAlpha),this.strokeRoundedRect(e,t,this.width,this.height,i))}get originX(){return this._originX}set originX(e){this._originX=e,this.setRenderFlag(!0)}get originY(){return this._originY}set originY(e){this._originY=e,this.setRenderFlag(!0)}setOrigin(e,t){return this.originX=e,this.originY=void 0===t?e:t,this}get radius(){return this._radius}set radius(e){return this._radius=e}setRadius(e){return this.radius=e,this}get width(){return this._width}set width(e){this._width=e,this.fixSize(),this.setRenderFlag(!0)}get height(){return this._height}set height(e){this._height=e,this.fixSize(),this.setRenderFlag(!0)}setSize(e,t){return void 0!==e&&(this.width=e),void 0!==t&&(this.height=t),this}fixSize(){this.input&&this.input.hitArea.setSize(this.width,this.height),this.body&&this.body.setSize(this.width,this.height)}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this.setRenderFlag(!0)}get fillAlpha(){return this._fillAlpha}set fillAlpha(e){this._fillAlpha=e,this.setRenderFlag(!0)}setFillStyle(e,t){return void 0!==e&&(this.fillColor=e),void 0!==t&&(this.fillAlpha=t),this}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this.setRenderFlag(!0)}get strokeColor(){return this._strokeColor}set strokeColor(e){this._strokeColor=e,this.setRenderFlag(!0)}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(e){this._strokeAlpha=e,this.setRenderFlag(!0)}setStrokeStyle(e,t,i){return void 0!==e&&(this.lineWidth=e),void 0!==t&&(this.strokeColor=t),void 0!==i&&(this.strokeAlpha=i),this}}const n=new s(i,e.x||0,e.y||0,e.width,e.height,e.radius);return v(n,e,t),{object:n}},props:["visible","x","y","rotation","width","height","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha","radius"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},Circle:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Arc{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0,e.radius);return v(n,e,t),{object:n}},props:["visible","x","y","rotation","radius","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},Line:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Line{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0,e.x1,e.y1,e.x2,e.y2);return v(n,e,t),{object:n}},props:["visible","x","y","x1","y1","x2","y2","rotation","width","height","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","lineWidth","strokeColor","strokeAlpha"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},Image:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Image{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0,e.texture);return v(n,e,t),{object:n}},props:["visible","x","y","rotation","origin","originX","originY","scale","scaleX","scaleY","depth","alpha","blendMode","pipeline","texture","frame","tint","flipX","flipY"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},Sprite:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Sprite{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0,e.texture);return v(n,e,t),{object:n}},props:["visible","x","y","rotation","origin","originX","originY","scale","scaleX","scaleY","depth","alpha","blendMode","pipeline","texture","frame","tint","flipX","flipY"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},Text:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Text{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0,e.text);return v(n,e,t),{object:n}},props:["visible","text","rotation","x","y","origin","originX","originY","scale","scaleX","scaleY","depth","alpha","style","lineSpacing","padding"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},TilemapLayer:{props:["visible","x","y","width","height","depth","tilemap","layerIndex","tileset","collision"],setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.Tilemaps.TilemapLayer{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.tilemap,e.layerIndex,e.tileset,e.x||0,e.y||0);return v(n,e,t),{object:n}},render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}},Zone:{setup(e,t){const i=(0,r.inject)("scene");class s extends Phaser.GameObjects.Zone{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new s(i,e.x||0,e.y||0,e.width,e.height);return v(n,e,t),{object:n}},props:["active","x","y","width","height","origin","originX","originY"],render:function(e,t,i,s,n,o){return(0,r.openBlock)(),(0,r.createBlock)("div")}}},n=e=>{e.input?e.input.hitArea.setSize(e.width,e.height):(e._events.pointerdown||e._events.pointerup)&&e.setInteractive(),e.body&&e.body.setSize(e.width,e.height)},o={active:e=>t=>e.setActive(t),visible:e=>t=>e.setVisible(t),x:e=>t=>e.setPosition(t,e.y),y:e=>t=>e.setPosition(e.x,t),x1:e=>t=>e.x1=t,y1:e=>t=>e.y1=t,x2:e=>t=>e.x2=t,y2:e=>t=>e.y2=t,rotation:e=>t=>e.setRotation(t),origin:e=>t=>e.setOrigin(t,t),originX:e=>t=>e.setOrigin(t,e.originY),originY:e=>t=>e.setOrigin(e.originX,t),scale:e=>t=>e.setScale(t,t),scaleX:e=>t=>e.setScale(t,e.scaleY),scaleY:e=>t=>e.setScale(e.scaleX,t),width:e=>t=>{e.setSize(t,e.height),n(e)},height:e=>t=>{e.setSize(e.width,t),n(e)},radius:e=>t=>e.setRadius(t),displayWidth:e=>t=>e.setDisplaySize(t,e.displayHeight),displayHeight:e=>t=>e.setDisplaySize(e.displayWidth,t),displayOriginX:e=>t=>e.setDisplayOrigin(t,e.displayOriginY),displayOriginY:e=>t=>e.setDisplayOrigin(e.displayOriginX,t),flipX:e=>t=>e.setFlipX(t),flipY:e=>t=>e.setFlipY(t),depth:e=>t=>e.setDepth(t),alpha:e=>t=>e.setAlpha(t),blendMode:e=>t=>e.setBlendMode(t),pipeline:e=>t=>e.setPipeline(t),intensity:e=>t=>e.setIntensity(t),tint:e=>t=>e.setTint(t),text:e=>t=>e.setText(t),texture:e=>t=>e.setTexture(t),frame:e=>t=>e.setFrame(t),color:e=>t=>e.setColor(t),fillColor:e=>t=>e.setFillStyle(t,e.fillAlpha),fillAlpha:e=>t=>e.setFillStyle(e.fillColor,t),lineWidth:e=>(t,i)=>{e.setLineWidth?e.setLineWidth(t,i):e.setStrokeStyle(...t?[t,e.strokeColor,e.strokeAlpha]:[])},strokeColor:e=>t=>e.setStrokeStyle(e.lineWidth,t,e.strokeAlpha),strokeAlpha:e=>t=>e.setStrokeStyle(e.lineWidth,e.strokeColor,t),style:e=>t=>e.setStyle(t),lineSpacing:e=>t=>e.setLineSpacing(t),padding:e=>t=>e.setPadding(t),collision:e=>t=>e.setCollision(t)},l=s.Scene,a=s.Container,h=s.Image,d=s.Sprite,p=s.Text,c=s.Rectangle,u=s.Circle,g=s.Line,y=s.TilemapLayer,f=s.Zone,x=s.RoundRectangle,m=s.Light,k=(e,t)=>{const i=(0,r.createApp)(t);i.provide("game",e),i.provide("scene",null),i.provide("container",null);const s=window.document.createElement("div");return document.body.appendChild(s),i.mount(s)},v=(e,t,i)=>{const s=e.constructor===Phaser.GameObject.Light,n=(0,r.inject)("scene");if(s)n.lights.active&&n.lights.enable(),n.lights.lights.push(e);else{n.add.existing(e);const t=(0,r.inject)("container");t&&t.add([e])}return Object.keys(t).forEach((i=>{if(!o[i])return;const s=o[i](e);s(t[i]),(0,r.watch)((()=>t[i]),s)})),i.attrs.onCreate&&i.emit("create",e),(i.attrs.onPointerdown||i.attrs.onPointerup)&&(e.setInteractive(),i.attrs.onPointerdown&&e.on("pointerdown",((...e)=>i.emit("pointerdown",...e))),i.attrs.onPointerup&&e.on("pointerup",((...e)=>i.emit("pointerup",...e)))),s?(0,r.onBeforeUnmount)((()=>n.lights.removeLight(e))):(0,r.onBeforeUnmount)((()=>e.destroy())),e},b=(e,t)=>(0,r.customRef)(((i,r)=>({get:()=>(i(),e),set(i){e&&i||(e=i?i[t]:null,r())}}))),S=e=>b(e,"object"),w=e=>b(e,"scene")},5:t=>{t.exports=e}},i={};function r(e){if(i[e])return i[e].exports;var s=i[e]={exports:{}};return t[e](s,s.exports,r),s.exports}return r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(289)})()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Vue")):"function"==typeof define&&define.amd?define(["Vue"],t):"object"==typeof exports?exports.Phavuer=t(require("Vue")):e.Phavuer=t(e.Vue)}(this,(function(e){return(()=>{"use strict";var t={614:(e,t,i)=>{i.r(t),i.d(t,{Circle:()=>d,Container:()=>l,Image:()=>c,Light:()=>x,Line:()=>p,Rectangle:()=>a,RoundRectangle:()=>h,Scene:()=>o,Sprite:()=>u,Text:()=>g,TilemapLayer:()=>y,Zone:()=>f,createPhavuerApp:()=>w,initGameObject:()=>m,refObj:()=>b,refScene:()=>v,refTo:()=>k});var s=i(5);const r=e=>{e.input?e.input.hitArea.setSize(e.width,e.height):(e._events.pointerdown||e._events.pointerup)&&e.setInteractive(),e.body&&e.body.setSize(e.width,e.height)},n={active:e=>t=>e.setActive(t),visible:e=>t=>e.setVisible(t),x:e=>t=>e.setPosition(t,e.y),y:e=>t=>e.setPosition(e.x,t),x1:e=>t=>e.x1=t,y1:e=>t=>e.y1=t,x2:e=>t=>e.x2=t,y2:e=>t=>e.y2=t,rotation:e=>t=>e.setRotation(t),origin:e=>t=>e.setOrigin(t,t),originX:e=>t=>e.setOrigin(t,e.originY),originY:e=>t=>e.setOrigin(e.originX,t),scale:e=>t=>e.setScale(t,t),scaleX:e=>t=>e.setScale(t,e.scaleY),scaleY:e=>t=>e.setScale(e.scaleX,t),width:e=>t=>{e.setSize(t,e.height),r(e)},height:e=>t=>{e.setSize(e.width,t),r(e)},radius:e=>t=>e.setRadius(t),displayWidth:e=>t=>e.setDisplaySize(t,e.displayHeight),displayHeight:e=>t=>e.setDisplaySize(e.displayWidth,t),displayOriginX:e=>t=>e.setDisplayOrigin(t,e.displayOriginY),displayOriginY:e=>t=>e.setDisplayOrigin(e.displayOriginX,t),flipX:e=>t=>e.setFlipX(t),flipY:e=>t=>e.setFlipY(t),depth:e=>t=>e.setDepth(t),alpha:e=>t=>e.setAlpha(t),blendMode:e=>t=>e.setBlendMode(t),pipeline:e=>t=>e.setPipeline(t),intensity:e=>t=>e.setIntensity(t),tint:e=>t=>e.setTint(t),text:e=>t=>e.setText(t),texture:e=>t=>e.setTexture(t),frame:e=>t=>e.setFrame(t),color:e=>t=>e.setColor(t),fillColor:e=>t=>e.setFillStyle(t,e.fillAlpha),fillAlpha:e=>t=>e.setFillStyle(e.fillColor,t),lineWidth:e=>(t,i)=>{e.setLineWidth?e.setLineWidth(t,i):e.setStrokeStyle(...t?[t,e.strokeColor,e.strokeAlpha]:[])},strokeColor:e=>t=>e.setStrokeStyle(e.lineWidth,t,e.strokeAlpha),strokeAlpha:e=>t=>e.setStrokeStyle(e.lineWidth,e.strokeColor,t),style:e=>t=>e.setStyle(t),lineSpacing:e=>t=>e.setLineSpacing(t),padding:e=>t=>e.setPadding(t),collision:e=>t=>e.setCollision(t),tween:e=>t=>{e.tween&&e.tween.seek(0).stop(),t&&(e.tween=e.scene.add.tween(Object.assign({},t,{targets:e})))}},o={props:{name:{type:String,require:!0},autoStart:{type:Boolean,default:!0}},setup(e,t){const i=(0,s.ref)(!0),r=class extends Phaser.Scene{init(e){i.value=!0,t.emit("init",this,e)}create(e){t.emit("create",this,e)}update(e,i){t.emit("update",this,e,i)}preload(){t.emit("preload",this)}},n=(0,s.inject)("game").scene.add(e.name,r,e.autoStart);return n.events.on("shutdown",(()=>i.value=!1)),(0,s.provide)("scene",n),{scene:n,show:i}},render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div",null,[r.show?(0,s.renderSlot)(e.$slots,"default",{key:0}):(0,s.createCommentVNode)("v-if",!0)])}},l={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Container{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0);return m(n,e,t),(0,s.provide)("container",n),{object:n}},props:["tween","visible","width","height","rotation","x","y","depth","alpha"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div",null,[(0,s.renderSlot)(e.$slots,"default")])}},a={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Rectangle{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0,e.width,e.height);return m(n,e,t),{object:n}},props:["tween","visible","x","y","rotation","width","height","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},h={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Graphics{constructor(e,t,i,s,r,n){super(e,t,i,s,r),this._originX=0,this._originY=0,this._width=s||0,this._height=r||0,this._radius=n||0,this._fillColor=null,this._fillAlpha=1,this._lineWidth=0,this._strokeColor=null,this._strokeAlpha=1,this.setRenderFlag(!0)}preUpdate(...e){this.renderFlag&&this.render(),t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}setRenderFlag(e){this.renderFlag=e}render(){this.setRenderFlag(!1);const e=this.originX*-this.width,t=this.originY*-this.height,i="number"==typeof this.radius?Math.min(this.radius,this.width.half,this.height.half):this.radius;this.clear(),null!==this.fillColor&&(this.fillStyle(this.fillColor,this.fillAlpha),this.fillRoundedRect(e,t,this.width,this.height,i)),this.lineWidth&&null!==this.strokeColor&&(this.lineStyle(this.lineWidth,this.strokeColor,this.strokeAlpha),this.strokeRoundedRect(e,t,this.width,this.height,i))}get originX(){return this._originX}set originX(e){this._originX=e,this.setRenderFlag(!0)}get originY(){return this._originY}set originY(e){this._originY=e,this.setRenderFlag(!0)}setOrigin(e,t){return this.originX=e,this.originY=void 0===t?e:t,this}get radius(){return this._radius}set radius(e){return this._radius=e}setRadius(e){return this.radius=e,this}get width(){return this._width}set width(e){this._width=e,this.fixSize(),this.setRenderFlag(!0)}get height(){return this._height}set height(e){this._height=e,this.fixSize(),this.setRenderFlag(!0)}setSize(e,t){return void 0!==e&&(this.width=e),void 0!==t&&(this.height=t),this}fixSize(){this.input&&this.input.hitArea.setSize(this.width,this.height),this.body&&this.body.setSize(this.width,this.height)}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this.setRenderFlag(!0)}get fillAlpha(){return this._fillAlpha}set fillAlpha(e){this._fillAlpha=e,this.setRenderFlag(!0)}setFillStyle(e,t){return void 0!==e&&(this.fillColor=e),void 0!==t&&(this.fillAlpha=t),this}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this.setRenderFlag(!0)}get strokeColor(){return this._strokeColor}set strokeColor(e){this._strokeColor=e,this.setRenderFlag(!0)}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(e){this._strokeAlpha=e,this.setRenderFlag(!0)}setStrokeStyle(e,t,i){return void 0!==e&&(this.lineWidth=e),void 0!==t&&(this.strokeColor=t),void 0!==i&&(this.strokeAlpha=i),this}}const n=new r(i,e.x||0,e.y||0,e.width,e.height,e.radius);return m(n,e,t),{object:n}},props:["tween","visible","x","y","rotation","width","height","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha","radius"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},d={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Arc{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0,e.radius);return m(n,e,t),{object:n}},props:["tween","visible","x","y","rotation","radius","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","fillColor","fillAlpha","lineWidth","strokeColor","strokeAlpha"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},p={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Line{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0,e.x1,e.y1,e.x2,e.y2);return m(n,e,t),{object:n}},props:["tween","visible","x","y","x1","y1","x2","y2","rotation","width","height","origin","originX","originY","displayOriginX","displayOriginY","scale","scaleX","scaleY","depth","alpha","lineWidth","strokeColor","strokeAlpha"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},c={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Image{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0,e.texture);return m(n,e,t),{object:n}},props:["tween","visible","x","y","rotation","origin","originX","originY","scale","scaleX","scaleY","depth","alpha","blendMode","pipeline","texture","frame","tint","flipX","flipY"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},u={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Sprite{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0,e.texture);return m(n,e,t),{object:n}},props:["tween","visible","x","y","rotation","origin","originX","originY","scale","scaleX","scaleY","depth","alpha","blendMode","pipeline","texture","frame","tint","flipX","flipY"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},g={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Text{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0,e.text);return m(n,e,t),{object:n}},props:["tween","visible","text","rotation","x","y","origin","originX","originY","scale","scaleX","scaleY","depth","alpha","style","lineSpacing","padding"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},y={props:["tween","visible","x","y","width","height","depth","pipeline","tilemap","layerIndex","tileset","collision"],setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.Tilemaps.TilemapLayer{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.tilemap,e.layerIndex,e.tileset,e.x||0,e.y||0);return m(n,e,t),{object:n}},render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},f={setup(e,t){const i=(0,s.inject)("scene");class r extends Phaser.GameObjects.Zone{preUpdate(...e){t.attrs.onPreUpdate&&t.emit("preUpdate",this,...e)}}const n=new r(i,e.x||0,e.y||0,e.width,e.height);return m(n,e,t),{object:n}},props:["tween","active","x","y","width","height","origin","originX","originY"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},x={setup(e,t){(0,s.inject)("scene");const i=new Phaser.GameObjects.Light(e.x||0,e.y||0);return m(i,e,t),{object:i}},props:["tween","visible","x","y","radius","color","intensity"],render:function(e,t,i,r,n,o){return(0,s.openBlock)(),(0,s.createBlock)("div")}},w=(e,t)=>{const i=(0,s.createApp)(t);i.provide("game",e),i.provide("scene",null),i.provide("container",null);const r=window.document.createElement("div");return document.body.appendChild(r),i.mount(r)},m=(e,t,i)=>{const r=e.constructor===Phaser.GameObjects.Light,o=(0,s.inject)("scene");if(r)o.lights.active||o.lights.enable(),o.lights.lights.push(e);else{o.add.existing(e);const t=(0,s.inject)("container");t&&t.add([e])}return Object.keys(t).forEach((i=>{if(!n[i])return;const r=n[i](e);r(t[i]),(0,s.watch)((()=>t[i]),r,{deep:!0})})),i.attrs.onCreate&&i.emit("create",e),(i.attrs.onPointerdown||i.attrs.onPointerup)&&(e.setInteractive(),i.attrs.onPointerdown&&e.on("pointerdown",((...e)=>i.emit("pointerdown",...e))),i.attrs.onPointerup&&e.on("pointerup",((...e)=>i.emit("pointerup",...e)))),(0,s.onBeforeUnmount)((()=>{e.tween&&e.tween.stop()})),r?(0,s.onBeforeUnmount)((()=>o.lights.removeLight(e))):(0,s.onBeforeUnmount)((()=>e.destroy())),e},k=(e,t)=>(0,s.customRef)(((i,s)=>({get:()=>(i(),e),set(i){e&&i||(e=i?i[t]:null,s())}}))),b=e=>k(e,"object"),v=e=>k(e,"scene")},5:t=>{t.exports=e}},i={};function s(e){if(i[e])return i[e].exports;var r=i[e]={exports:{}};return t[e](r,r.exports,s),r.exports}return s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s(614)})()})); |
{ | ||
"name": "phavuer", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "Reactive template engine based on Vue 3 for Phaser 3", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -248,2 +248,5 @@ # Phavuer | ||
- Almost all props names are following the property names of its GameObject | ||
- A Tween for the object can be defined with `:tween` | ||
- `targets` of the options will be set automatically | ||
- The Tween will be removed automatically before the object destroyed | ||
@@ -250,0 +253,0 @@ Currently Phavuer has following base components: |
import { createApp, inject, watch, onBeforeUnmount, customRef } from 'vue' | ||
import components from './components' | ||
import setters from './setters' | ||
import Scene from './components/Scene' | ||
import Container from './components/Container' | ||
import Rectangle from './components/Rectangle' | ||
import RoundRectangle from './components/RoundRectangle' | ||
import Circle from './components/Circle' | ||
import Line from './components/Line' | ||
import Image from './components/Image' | ||
import Sprite from './components/Sprite' | ||
import Text from './components/Text' | ||
import TilemapLayer from './components/TilemapLayer' | ||
import Zone from './components/Zone' | ||
import Light from './components/Light' | ||
export const Scene = components.Scene | ||
export const Container = components.Container | ||
export const Image = components.Image | ||
export const Sprite = components.Sprite | ||
export const Text = components.Text | ||
export const Rectangle = components.Rectangle | ||
export const Circle = components.Circle | ||
export const Line = components.Line | ||
export const TilemapLayer = components.TilemapLayer | ||
export const Zone = components.Zone | ||
export const RoundRectangle = components.RoundRectangle | ||
export const Light = components.Light | ||
export const createPhavuerApp = (game, component) => { | ||
const createPhavuerApp = (game, component) => { | ||
const app = createApp(component) | ||
@@ -29,3 +27,3 @@ app.provide('game', game) | ||
export const initGameObject = (object, props, context) => { | ||
const initGameObject = (object, props, context) => { | ||
const isLight = object.constructor === Phaser.GameObjects.Light | ||
@@ -49,3 +47,3 @@ const scene = inject('scene') | ||
setter(props[key]) | ||
watch(() => props[key], setter) | ||
watch(() => props[key], setter, { deep: true }) | ||
}) | ||
@@ -61,2 +59,5 @@ // Set event | ||
// Destroy when unmounted | ||
onBeforeUnmount(() => { | ||
if (object.tween) object.tween.stop() | ||
}) | ||
if (isLight) { | ||
@@ -70,3 +71,3 @@ onBeforeUnmount(() => scene.lights.removeLight(object)) | ||
export const refTo = (value, key) => { | ||
const refTo = (value, key) => { | ||
return customRef((track, trigger) => { | ||
@@ -86,3 +87,23 @@ return { | ||
} | ||
export const refObj = value => refTo(value, 'object') | ||
export const refScene = value => refTo(value, 'scene') | ||
const refObj = value => refTo(value, 'object') | ||
const refScene = value => refTo(value, 'scene') | ||
export { | ||
createPhavuerApp, | ||
initGameObject, | ||
refTo, | ||
refObj, | ||
refScene, | ||
Scene, | ||
Container, | ||
Rectangle, | ||
RoundRectangle, | ||
Circle, | ||
Line, | ||
Image, | ||
Sprite, | ||
Text, | ||
TilemapLayer, | ||
Zone, | ||
Light | ||
} |
@@ -64,3 +64,8 @@ const fixSize = object => { | ||
padding: object => v => object.setPadding(v), | ||
collision: object => v => object.setCollision(v) | ||
collision: object => v => object.setCollision(v), | ||
tween: object => data => { | ||
if (object.tween) object.tween.seek(0).stop() | ||
if (!data) return | ||
object.tween = object.scene.add.tween(Object.assign({}, data, { targets: object })) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80734
293
21