Skip to content

Instantly share code, notes, and snippets.

@fabiobiondi
Last active January 3, 2016 16:23
Show Gist options
  • Save fabiobiondi/ecbad86280755d28856e to your computer and use it in GitHub Desktop.
Save fabiobiondi/ecbad86280755d28856e to your computer and use it in GitHub Desktop.
EaselJS Custom Display Object in ES6 - v.0.0.2 - DOESN'T WORK (to delete in feb 2016)
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();
class MyButton extends createjs.Container{
constructor(color) {
super();
this.radius = 40;
this.color = color || 'grey';
}
// NOTE: draw is never invoked! :(
draw() {
super.draw();
// or:
this.Container_draw();
const circle = new createjs.Shape();
circle.graphics.beginFill(this.color).drawCircle(0, 0, this.radius);
}
}
// export default MyButton;
export default createjs.promote(MyButton, "Container")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment