Skip to content

Instantly share code, notes, and snippets.

@fabiobiondi
Last active January 2, 2016 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiobiondi/7f000d189397794839dd to your computer and use it in GitHub Desktop.
Save fabiobiondi/7f000d189397794839dd to your computer and use it in GitHub Desktop.
EaselJS Custom Display Object in ES6 - v.0.0.1
import MyButton from './MyButton.js';
const stage = new createjs.Stage("demo");
const btn = new MyButton('red');
stage.addChild(btn);
btn.x = 100;
btn.y = 100;
stage.update();
// MyButton.js
export default class MyButton {
constructor(color) {
this.radius = 40;
this.color = color || 'grey';
return this.draw();
}
draw() {
const circle = new createjs.Shape();
circle.graphics.beginFill(this.color).drawCircle(0, 0, this.radius);
return circle;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment