基本信息
源码名称:canvas实现流星雨效果(棒棒哒)
源码大小:0.05M
文件格式:.zip
开发语言:CSS
更新时间:2018-08-24
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

/***/ function(module, exports) {

	'use strict';
	
	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i  ) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
	
	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
	
	// 坐标
	var Crood = function () {
	    function Crood() {
	        var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
	        var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
	
	        _classCallCheck(this, Crood);
	
	        this.x = x;
	        this.y = y;
	    }
	
	    _createClass(Crood, [{
	        key: 'setCrood',
	        value: function setCrood(x, y) {
	            this.x = x;
	            this.y = y;
	        }
	    }, {
	        key: 'copy',
	        value: function copy() {
	            return new Crood(this.x, this.y);
	        }
	    }]);
	
	    return Crood;
	}();
	
	// 流星
	
	
	var ShootingStar = function () {
	    function ShootingStar() {
	        var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Crood();
	        var final = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Crood();
	        var size = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
	        var speed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 200;
	        var onDistory = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
	
	        _classCallCheck(this, ShootingStar);
	
	        this.init = init; // 初始位置
	        this.final = final; // 最终位置
	        this.size = size; // 大小
	        this.speed = speed; // 速度:像素/s
	
	        // 飞行总时间
	        this.dur = Math.sqrt(Math.pow(this.final.x - this.init.x, 2)   Math.pow(this.final.y - this.init.y, 2)) * 1000 / this.speed;
	
	        this.pass = 0; // 已过去的时间
	        this.prev = this.init.copy(); // 上一帧位置
	        this.now = this.init.copy(); // 当前位置
	        this.onDistory = onDistory;
	    }
	
	    _createClass(ShootingStar, [{
	        key: 'draw',
	        value: function draw(ctx, delta) {
	            this.pass  = delta;