问答详情
源自:2-7 大鱼绘制

大鱼在 canvas1 上没有显示

场景设置:

#canvas1{

position:absolute;

bottom:0;

left:0;

z-index:1;

}

#canvas2{

position:absolute;

bottom:0;

left:0;

z-index:0;

}

画布获取:

can1=document.getElementById("canvas1");

ctx1=can1.getContext('2d');/* 绘制 2d 场景 */

大鱼设置:

this.x =canWidth * 0.5;

this.y =canHeight * 0.5;

ctx1.drawImage(this.bigEye, -this.bigEye * 0.5, -this.bigEye * 0.5);

ctx1.drawImage(this.bigBody, -this.bigBody * 0.5, -this.bigBody * 0.5);

ctx1.drawImage(this.bigTail, -this.bigTail * 0.5 + 30, -this.bigTail * 0.5);


提问者:1307111376 2016-02-18 11:06

个回答

  • weibo_小海的星空_0
    2016-08-12 22:16:32

    可是为什么老师写的ctx1.drawImage()大鱼是能够出来的呢。

  • 1307111376
    2016-03-16 21:07:16

    ctx1.drawImage(this.bigEye, -this.bigEye * 0.5, -this.bigEye * 0.5);  

    写错了,应该是 

    ctx2.drawImage(this.bigEye, -this.bigEye.width * 0.5, -this.bigEye.height * 0.5);

  • 念墨
    2016-02-19 00:05:56

    draw()函数要在mian.js中调用