大鱼在 canvas1 上没有显示

来源:2-7 大鱼绘制

1307111376

2016-02-18 11:06

场景设置:

#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);


写回答 关注

3回答

  • 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中调用

    130711...

    function gameloop() 中调取了

    2016-02-19 08:48:05

    共 1 条回复 >

HTML5小游戏---爱心鱼(上)

学做HTML5游戏,轻轻松松带你上手,适合刚入手游戏开发的同学

92353 学习 · 550 问题

查看课程

相似问题