bemuse icon indicating copy to clipboard operation
bemuse copied to clipboard

Refactor scintillator…

Open dtinth opened this issue 9 years ago • 1 comments

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 }
      ]
    }
  }, [
  ])
])

dtinth avatar Oct 24 '16 08:10 dtinth

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 })
      })
    })
  })
}

dtinth avatar Dec 08 '16 16:12 dtinth