bemuse
bemuse copied to clipboard
Refactor scintillator…
This will probably happen after we migrate to PIXI v4.
Scope:
- Change file format from XML to JavaScript.
- Everything else, the same!
<skin width="123" height="456">
<group y="t*2">
<animation>
<keyframe t="0" x="10" />
<keyframe t="1" x="20" />
</animation>
<animation on="exitEvent">
<keyframe t="0" x="50" y="0" />
<keyframe t="1" x="70" y="100" />
</animation>
</group>
</skin>
export const skin = Skin({ width: 123, height: 456 }, [
Group({
y: 't*2',
animations: {
default: [
{ t: 0, x: 10 },
{ t: 1, x: 20 }
],
exitEvent: [
{ t: 0, x: 50, y: 0 },
{ t: 1, x: 70, y: 100 }
]
}
}, [
])
])
This makes it quite hard to add conditionals to code.
Let’s use an imperative builder instead.
export default (builder) => {
const { skin, group, animation, keyframe } = builder
skin({ width: 123, height: 456 }, () => {
group({ y: 't * 2' }, () => {
animation(() => {
keyframe({ t: 0, x: 10 })
keyframe({ t: 1, x: 20 })
})
animation('exitEvent', () => {
keyframe({ t: 0, x: 50, y: 0 })
keyframe({ t: 1, x: 70, y: 100 })
})
})
})
}