实例教程 HTML5 Canvas 超炫酷烟花绽放动画实现代码

2019-01-28 16:48:10丽君
  •         vx = Math.cos(this.angle) * this.speed,            vy = Math.sin(this.angle) * this.speed; this.speed *= 1 + this.acceleration; this.coordLast[2].x = this.coordLast[1].x; this.coordLast[2].y = this.coordLast[1].y; this.coordLast[1].x = this.coordLast[0].x; this.coordLast[1].y = this.coordLast[0].y; this.coordLast[0].x = this.x; this.coordLast[0].y = this.y; if(self.showTarget){ if(this.targetRadius < 8){ this.targetRadius += .25 * self.dt;   
  •             } else { this.targetRadius = 1 * self.dt;                    }   
  •         } if(this.startX >= this.targetX){ if(this.x + vx <= this.targetX){ this.x = this.targetX; this.hitX = true;                } else { this.x += vx * self.dt;   
  •             }            } else { if(this.x + vx >= this.targetX){ this.x = this.targetX; this.hitX = true;   
  •             } else { this.x += vx * self.dt;                }   
  •         } if(this.startY >= this.targetY){ if(this.y + vy <= this.targetY){ this.y = this.targetY; this.hitY = true;                } else { this.y += vy * self.dt;   
  •             }            } else { if(this.y + vy >= this.targetY){ this.y = this.targetY; this.hitY = true;   
  •             } else { this.y += vy * self.dt;                }