课程/HTML/CSS/前端开发
	
  canvas实现星星闪烁特效
  
    - 
      
        
      
      
        - 
          qweqwe13123123
          2016-12-06
        
 
        - 实在无法理解 这里的if判断 是做什么用的。
 
        - 
          
          
截图
          
          0赞 · 2采集
         
      
     
  
    - 
      
        
      
      
        - 
          qweqwe13123123
          2016-12-06
        
 
        - 在绘画完毕的函数里面获取 上一次结束的 now
在绘画中的函数里面获取 下一次开始的 now
得出 deltatime。
 
        - 
          
          
截图
          
          0赞 · 0采集
         
      
     
  
    - 
      
        
      
      
        - 
          qweqwe13123123
          2016-12-06
        
 
        - 记得把 新建的update 放到函数中 循环绘画
 
        - 
          
          
截图
          
          0赞 · 0采集
         
      
     
  
    - 
      
        
      
      
        - 
          qweqwe13123123
          2016-12-06
        
 
        - drawImage 的属性有这么多(img,sx,sy,swidth,sheight,x,y,width,height)
img 图片元素
sx 序列帧的x轴
sy 序列帧的y轴
swidth 帧的宽
sheight 帧的高
x 在画布的x轴
y 在画布的y轴
width 在画布的 宽
height 在画布的 高
 
        - 
          
          
截图
          
          0赞 · 0采集
         
      
     
  
    - 
      
        
      
      
        - 
          Laughter0
          2016-11-22
        
 
        - context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
sx:在序列帧上x的起点 sy:y坐标的起点;swidth:要绘制的宽度;
sheight:要绘制的高度 x:canvas上的xy
width:canvas的宽 height:canvas的高
 
        - 
          
          
截图
          
          0赞 · 0采集
         
      
     
  
    - 
      
        
      
      
        - 
          盛夏孤星
          2016-01-18
        
 
        - 1.context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);<br><br>
s..:是表示图片本身的<br>
x...:是表示在canvas的坐标、宽度<br>
2.window.requestAnimationFrame(gameLoop);//两帧之间刷新时间随机<br>
3.获取当前时间:var time = Date.now();
4.随机闪动就要让picNo是随机数并且要为整数:this.picNu=Math.floor(Math.random()*7);
 
        - 
          
          0赞 · 0采集
        
 
      
     
  
    - 
      
        
      
      
        - 
          慕少4432244
          2016-01-08
        
 
        - drawImage(img, 图片.sx, 图片.sy, 图片.swidth, 图片.sheight, canves.x, canvas.y, canvan.width, canvas.height);
 
        - 
          
          0赞 · 2采集
        
 
      
     
  
    - 
      
        
      
      
        - 
          随心y_
          2015-08-17
        
 
        - drawImage(img, 图片.sx, 图片.sy, 图片.swidth, 图片.sheight, canves.x, canvas.y, canvan.width, canvas.height);
 
        - 
          
          1赞 · 0采集
        
 
      
     
  
    - 
      
        
      
      
        - 
          ringch
          2015-08-10
        
 
        - drawImage(img, img.sx, img.sy, img.swidth, img.sheight, canves.x, canvas.y, canvan.width, canvas.height);
 
        - 
          
          0赞 · 0采集
        
 
      
     
  
    - 
      
        
      
      
        - 
          霜花似雪
          2015-07-17
        
 
        - drawImage(img, img.sx, img.sy, img.swidth, img.sheight, canves.x, canvas.y, canvan.width, canvas.height);
 
        - 
          
          0赞 · 0采集
        
 
      
     
  
    - 
      
        
      
      
        - 
          leonkwok
          2015-05-31
        
 
        - drawImage(img, img.sx, img.sy, img.swidth, img.sheight, canves.x, canvas.y, canvan.width, canvas.height);
 
        - 
          
          0赞 · 0采集
        
 
      
     
  
    - 
      
        
      
      
        - 
          凌云壮志兮
          2015-04-08
        
 
        - drawImage (img,实现,使用,swidth,sheight,x,y)
 
        - 
          
          0赞 · 0采集