Skip to content

Instantly share code, notes, and snippets.

@SharpCoder
Last active November 24, 2024 23:36
Show Gist options
  • Save SharpCoder/3cc09fb195164c961f4b02e25fa37907 to your computer and use it in GitHub Desktop.
Save SharpCoder/3cc09fb195164c961f4b02e25fa37907 to your computer and use it in GitHub Desktop.
ChronoPixel API Specification v1.0

ChronoPixel API Specification

This gist outlines the specification for the ChronoPixel v1.0 scripting library. The goal is to approximate similar functionality as found in Macromedia Flash (from ye olde web). The language of choice for ChronoPixel will be LUA. Code will be interpreted at runtime while manipulation of the world will happen via javascript bindings which hook in to the ChronoPixelMX source engine.

ChronoPixel Scripting V1 Specification

Scope

Scripts are attached to keyframes. To add a new script, right-click a keyframe and select “Add Script”. Once a keyframe is executed, all associated scripts will be run.

Naming

Drawables have an instanceName property which can optionally be specified in the Properties panel. If specified, all scripts within that layer will have access to modify the instance.

API Specification

  • Network
    • fetch(url)
  • JSON
    • stringify()
    • parse()
  • Timeline
    • stop()
    • play()
    • gotoAndStop(frame)
    • gotoAndPlay(frame)
    • addEventListener(event, handler)
    • getObjectByName(name)
  • Instance of Drawable
    • props
      • x
      • y
      • sx
      • sy
      • pivotX
      • pivotY
      • rotation
      • strokeColor
      • fillColor
      • strokeWidth
      • zIndex (not currently supported)
    • name
    • addChild(drawable)
    • removeChild(drawable)
    • forEachChild(fn)
    • addEventListener(event, handler)
    • removeEventListener(event, handler)
    • copy()
    • destroy()
    • bboxHitTest(x, y)
    • polygonHitTest(x, y)
  • Global Drawable
    • create()
    • createBuilder()
  • Drawable Builder
    • moveTo(x,y)
    • lineTo(x,y)
    • arcTo(x,y,radius)
    • closePath()
    • build()
  • Layer
    • setAnimationType(tween | step)
  • Event
    • stopPropagation()
  • Storage
    • setItem(key, value)
    • getItem(key)
  • Math
    • All the math functions in JavaScript
  • Debug
    • trace(...args)

Events

  • Drawables
    • CREATE
    • ROLL_ENTER
    • ROLL_OVER
    • ROLL_OUT
    • CLICK
    • DRAG
  • Timeline
    • ENTER_FRAME
    • EXIT_FRAME
    • KEYDOWN
    • KEYUP
    • MOUSE_DOWN
    • MOUSE_UP
    • MOUSE_MOVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment