Skip to content

Instantly share code, notes, and snippets.

@davidtucker
Created February 9, 2012 02:23
Show Gist options
  • Save davidtucker/1776573 to your computer and use it in GitHub Desktop.
Save davidtucker/1776573 to your computer and use it in GitHub Desktop.
Sample EaselJS Component
// Sample EaselJS Component
(function (window) {
function SampleComponent () {
this.initialize();
}
SampleComponent.prototype = new Shape();
SampleComponent.MAX_ALPHA = 0.2;
SampleComponent.MIN_ALPHA = 0.8;
SampleComponent.MAX_DIAMETER = 100;
SampleComponent.MIN_DIAMETER = 20;
SampleComponent.prototype.diameter = 0;
SampleComponent.prototype.Shape_initialize = SampleComponent.prototype.initialize;
SampleComponent.prototype.initialize = function () {
this.Shape_initialize();
this.activate();
}
SampleComponent.prototype.activate = function () {
this.diameter = SampleComponent.MIN_DIAMETER;
this.diameter += ( Math.random() * ( SampleComponent.MAX_DIAMETER - SampleComponent.MIN_DIAMETER ) );
this.alpha = SampleComponent.MIN_ALPHA;
this.alpha += ( Math.random() * ( SampleComponent.MAX_ALPHA - SampleComponent.MIN_ALPHA ) );
this.graphics.clear();
this.graphics.beginFill("rgba( 255 , 255 , 255 , 1 )");
this.graphics.drawCircle(this.diameter / 2, this.diameter / 2, this.diameter / 2);
}
SampleComponent.prototype.tick = function () {
this.x += 10;
}
window.SampleComponent = SampleComponent;
}(window));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment