javascript - drawing to canvas fails on first load. Refresh and it works -
here function.
drawbuttons: function() { gamecontroller.ctx.strokestyle='pink'; gamecontroller.ctx.fillstyle='rgba(128,128,128,1)'; gamecontroller.ctx.linewidth=2; this.roundedrect(gamecontroller.ctx,105,162,160,50,10,true,true); this.roundedrect(gamecontroller.ctx,105,240,160,50,10,true,true); gamecontroller.ctx.fillstyle = 'rgba(153,051,000,1)'; gamecontroller.ctx.font = "35px ar darling"; gamecontroller.ctx.filltext("1 player",120,200); gamecontroller.ctx.filltext("2 player",120,278); }
none of gets drawn on first load of webpage. can add code show call method if wishes see that. maybe have add .onload(), know how when adding image canvas, not filltext etc. thanks.
window.onload within drawbuttons method solution.
drawbuttons: function() { window.onload = (function(){ gamecontroller.ctx.strokestyle='pink'; gamecontroller.ctx.fillstyle='rgba(128,128,128,1)'; gamecontroller.ctx.linewidth=2; nongamecontent.roundedrect(gamecontroller.ctx,105,162,160,50,10,true,true); nongamecontent.roundedrect(gamecontroller.ctx,105,240,160,50,10,true,true); gamecontroller.ctx.fillstyle = 'rgba(153,051,000,1)'; gamecontroller.ctx.font = "35px ar darling"; gamecontroller.ctx.filltext("1 player",120,200); gamecontroller.ctx.filltext("2 player",120,278); })},
Comments
Post a Comment