JS_0044:随机生成0到x,x到y 的随机数,float插值,坐标插值 生成uuid 生成随机数
1,
Math.floor(Math.random() *X); //随机0到x的数 Math.floor(Math.random() *(Y-X)) + X; //随机x到y之间的数
2,
this.posX = pc.math.lerp(this.posX,this.endPos.x, time); //float进行lerp this.startPos.lerp(this.startPos,this.endPos,time);//坐标lerp
// 随机生成uuid function getUUID() { var d = new Date().getTime(); // uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' var uuid = 'xxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid; }; // console.log(getUUID()); //生成随机数的方法 function randomStr(len) { len = len || 32; // ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678 var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; var maxPos = chars.length; var pwd = ''; for (i = 0; i < len; i++) { pwd += chars.charAt(Math.floor(Math.random() * maxPos)); } return pwd; };
琥珀君的博客