class - Extending JavaScript Classes for use on Canvas -
i working on project me gain better understanding of javascript , building applications it. making game utilizing createjs. i'd extend shape "class" adding additional methods can't seem head around issue.
i not getting runtime errors approach, think it's failing silently @ particular point.
my subclass:
shipgfx.prototype = new createjs.shape(); function shipgfx() { createjs.shape.apply( ); this.draw = function() { var g = this.graphics; g.clear(); g.setstrokestyle( 1 ); g.beginstroke( createjs.graphics.getrgb( 0x00ff00 ) ); g.beginfill( createjs.graphics.getrgb( 0x00ff00, 0.5 ) ); g.moveto( 0, 0 ); g.lineto( -5, -5 ); g.lineto( 10, 0 ); g.lineto( -5, 5 ); g.lineto( 0, 0 ); g.endfill(); } }
where it's used:
var shape = new shipgfx(); shape.draw();
so console logs no errors , can log via draw command. think issue scope of this.graphics though doesn't fail there either. matter of scope? this.graphics reference prototype instance (if understand correctly). i'd ideally use class-js have better understanding of how works can't way work.
any input great. thank you.
the reason why failing silently because little did realize draw function preexisting in createjs.shape apis. changing name "render" solved issue.
Comments
Post a Comment