COCOS创建的js,在VSCODE中编辑问题?

JavaScript025

COCOS创建的js,在VSCODE中编辑问题?,第1张

要先用cocos编辑器执行安装cocos的提示,安装好了里面会生成cocos.d.ts的文件,就会有提示了。

安装 Cocos Creator API 适配插件

根据网上的代码,利用Polygon绘制覆盖物,方法如下

function createSectorArea(point2, radius, sDegree, eDegree, strokeColour, strokeWeight, Strokepacity, fillColour, fillOpacity, opts){

var points = []

var step = ((eDegree - sDegree) / 50) || 50

points.push(point2)

for (var i = sDegreei <eDegree + 0.0001i += step) {

points.push(EOffsetBearing(point2, radius, i))

}

points.push(point2)

var polygon = new BMap.Polygon(

points , {strokeColor:strokeColour, strokeWeight:strokeWeight, strokeOpacity:Strokepacity, fillColor: fillColour, fillOpacity:fillOpacity})

return polygon

}

function EOffsetBearing(point3, dist, bearing) {

var latConv = map.getDistance(point3, new BMap.Point(point3.lng + 0.01, point3.lat)) * 50

var lngConv = map.getDistance(point3, new BMap.Point(point3.lng, point3.lat + 0.01)) * 50

var lat = dist * Math.cos(bearing * Math.PI / 180) / latConv

var lng = dist * Math.sin(bearing * Math.PI / 180) / lngConv

return new BMap.Point(point3.lng + lng, point3.lat + lat)

}