import * as _constraint from './constraint' import * as autoConstraint from './auto-constraint' import Event from 'eventemitter3' import store from './store' export const constraints = _constraint export { fix, fixX, fixY } from './common' export default function constraint(event: Event) { event.on('beforeCreate', ({ PIXI }) => { for (const key in constraints) { PIXI.Container.prototype[key] = function (...args: any) { return constraints[key](this, ...args) } } for (const key in autoConstraint) { PIXI.Container.prototype[key] = function (...args: any) { return autoConstraint[key](this, ...args) } } }) event.on('created', ({ game }) => { store.game = game }) }