<>引擎版本

CocosCreator v2.0.9

<>是这些模块(属性、方法)

* cc.macro
* cc.misc
* cc.Intersection <>代码演示
第一部分
start () { let n1 = cc.macro.RAD; let n2 = cc.macro.DEG; let n3 =
cc.macro.ONE; let n4 = cc.macro.ZERO; console.log(n1); console.log(n2);
console.log(n3); console.log(n4); }

0.01745329251994329是一度等于多少弧度,57.29577951308232是一弧度等于多少度。

第二部分
start () { let deg = 45; // 角度转弧度 let rad = cc.misc.degreesToRadians(deg);
console.log(rad); // 弧度转角度 let deg2 = cc.misc.radiansToDegrees(rad);
console.log(deg2); }

省去了计算公式。

第三部分
start () { let num1 = 200; let num2 = 220; let k = 0.5; // 插值(比例计算) let n =
cc.misc.lerp(num1, num2, k); console.log(n); }

还有两个限制数值边界的API,很简单不做演示。

第四部分:cc.Intersection辅助类
start () { // 演示一个常用的API 点是否在多边形中 let point1 = cc.v2(0, 0); let point2 =
cc.v2(300, 0); // 用正方形举例,四个点 let array = [cc.v2(-100, 100), cc.v2(100, 100),
cc.v2(100, -100), cc.v2(-100, -100)]; let bool1 =
cc.Intersection.pointInPolygon(point1, array); let bool2 =
cc.Intersection.pointInPolygon(point2, array); console.log(bool1);
console.log(bool2); }


O(∩_∩)O~~

友情链接
ioDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信