## Vue Decorator
import { createDecorator, VueDecorator } from 'vue-class-component'
import { keyboards } from "../game";
export const Timeout = (time: number): VueDecorator => createDecorator((options, key) => {
const originalMethod = options.methods[key];
options.methods[key] = function wrapperMethod(...args: []) {
const newtimeout = setTimeout(()=>{
originalMethod.apply(this,args)
clearTimeout(newtimeout)
},time)
};
})
export const Interval = (time: number): VueDecorator => createDecorator((options, key) => {
const originalMethod = options.methods[key];
options.methods[key] = function wrapperMethod(...args: []) {
setInterval(() => {
originalMethod.apply(this, args)
}, time)
};
})
export const Keyboard = (value: string, action: string): VueDecorator => createDecorator((options, key) => {
const originalMethod = options.methods[key];
const direction:any = keyboards(value)
options.methods[key] = function wrapperMethod(...args: []) {
direction[action] = () => {
originalMethod.apply(this, args)
}
};
})
vue-pixijs Vue Decorator
最新推荐文章于 2024-04-22 23:18:29 发布