![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
cocos
程Sin
这个作者很懒,什么都没留下…
展开
-
获取三角形外接圆的圆心坐标、半径
//获取外接圆圆心坐标、半径 get_outer_circle(A, B, C){ let xa = A.x; let ya = A.y; //圆心 let posCenter = this.circleCenter(A,B,C); let x = posCenter.x; let y = posCenter.y; // 半径 let...原创 2021-12-21 16:40:35 · 796 阅读 · 0 评论 -
creator 绘制框
//windous 鼠标拖动绘制框const { ccclass, property } = cc._decorator;@ccclassexport default class drawNode extends cc.Component { graphics : cc.Graphics = null; touchStartPos : cc.Vec2 = null; touchEndPos : cc.Vec2 = null; onLo...原创 2021-11-26 17:01:40 · 567 阅读 · 0 评论 -
Creator 视频显示在普通的精灵上
importVideoModelfrom"../../app/course/sequenceTask/models/VideoModel";const{ccclass,property,requireComponent}=cc._decorator;@ccclass@requireComponent(cc.Sprite)exportdefaultclassCanvasVideoextendscc.Component{@property(cc...原创 2021-03-19 13:38:22 · 267 阅读 · 0 评论 -
TS 同时 缩放并且变透明动作
const{ccclass,property}=cc._decorator;@ccclassexportdefaultclassScaleOpcaityextendscc.Component{//同时缩放并且变透明@property({type:cc.Float,displayName:"一个阶段多少秒"})time:number=0.4;@property({type:cc.Float,di...原创 2021-03-19 11:40:55 · 254 阅读 · 0 评论 -
TS 一直旋转脚本
const{ccclass,property}=cc._decorator;@ccclassexportdefaultclass RotateForeverextendscc.Component{@property({type:cc.Integer,displayName:"速度1圈多少秒"})time:number=20;onLoad(){cc.tween(this.node)...原创 2021-03-19 11:39:45 · 217 阅读 · 0 评论 -
数字前面加0,生成01,02, 001, 002
getNum_0X(num,len=2){if(String(num).length>=len)returnnum;return(Array(len).join("0")+num).slice(-len);}原创 2021-03-19 11:36:37 · 362 阅读 · 0 评论 -
获取二维数组内XY下标周围的元素
getRoundItem(itemVt,x,y){letvt=[]if(itemVt[y+1]&&itemVt[y+1][x]){vt.push(itemVt[y+1][x])}if(itemVt[y-1]&&itemVt[y-1][x]){vt.push(itemVt[y-1][x])}...原创 2021-03-19 11:30:05 · 209 阅读 · 0 评论 -
矫正地图位置到屏幕正中心
//游戏层this.panelGame{letmaxX=-10000;letminX=10000;//遍历地图内元素的X坐标for(letiinroadVt){letroad =roadVt[i]maxX=Math.max(maxX,road.x+road.width*road.anchorX)minX=Math.min(minX,road.x-road.width*road.anchorX)}this.setGam...原创 2021-03-19 11:25:11 · 81 阅读 · 0 评论 -
45度角地图坐标计算 和 层级计算
//2个方块x的距离xdis=38//2个方块y的距离ydis= -19//传入 XY 下标 获取坐标 45度角地图 getPositonByXY(_x:number,_y:number){returncc.v2(_x*this.xdis+_y*this.xdis,_y*this.ydis-_x*this.ydis)}//传入 XY 下标 获取层级 Y越大层级越高X...原创 2021-03-19 11:18:22 · 798 阅读 · 0 评论