Quantcast
Channel: Cocos中文社区 - 最新帖子
Viewing all articles
Browse latest Browse all 494966

Uncaught TypeError: Cannot read property 'LineCap' of undefined

$
0
0

估计是你的节点上没有添加cc.Graphics组件,this.ctx=this.getComponent("cc.Graphics")的时候得到的是undefined,下一行this.ctx.lineCap就会报这个错误,无法读取undefined的属性LineCap。你加这样一行试试:

this.ctx = this.getComponent("cc.Graphics");
if (!this.ctx) {
    this.ctx = this.addComponent("cc.Graphics");
}
this.ctx.lineCap = cc.Graphics.LineCap.BUTT;

Viewing all articles
Browse latest Browse all 494966

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>