Cocos2.X和3.X的截图功能
Cocos creator 2.X和3.X的截图功能
Cocos creator 2.X和3.X的截图功能
python3.0读取excel导出ts文件
官网下载python-3.10.6
nodejs拷贝文件,跟python一样方便
protobuf用在creator3.x上,花了我2天的时间,最后用这个https://github.com/cocos-creator/example-3d/protobuf 解决了,太难了我。其他各式各样的方法,都用不了。我去,真坑。还要自己改写里面的东西,嗯。。。
BaseView适用于creator3.x的自动绑定ui控件。场景中新建一个Label,命名为Label.abc
,然后代码可直接使用this.Label.abc.string = 'abc'
,代码要继承extends BaseView
不是默认的extends Component
1)opaque - [oʊ'peɪk] 不透明的
transparent - [træns'perənt] 透明的
unlit - [ʌn'lɪt] 无灯光的
美术资源技巧
1)Q版植物素材-地图,场景,背景
1)代码红色报错Type 'null' is not assignable to type,解决:null后面加一个!,
比如public startMenu: Node = null;
vscode隐藏.meta文件,搜索files ex
,添加**/*.meta
,新建ts模板,更改文件D:/CocosDashboard/resources/.editors/Creator/3.4.2/resources/resources/3d/engine/editor/assets/default_file_content/ts
creator插件开发 https://forum.cocos.org/t/muzzik-ts/98678
控制UI浪费人生,于是整了个新的MVVM方案 https://forum.cocos.org/t/topic/78821
Cocos Creator 3D 粒子系统初战(一) 不要钱的酷炫火焰拿走不谢!
https://mp.weixin.qq.com/s/zH8DdL1l-mH1xSdRAXlCHg
creator 3d是不得不学的东西了。大势所趋。
gltf 导出插件
gltf 是一种新型并且迅速发展的资源格式,也是 Cocos Creator 3D 支持的主要标准格式,所以在 Cocos Creator 3D 使用的资源最好是 gltf,这样可以得到最大的支持力度。
前言
汉字的临摹是语文类教育产品中非常容易用到的功能,尤其是小学一到三年级,恰好我就在一个在线教育类的公司做cocos游戏课件的研发。
android安卓代码添加图片按钮
https://forum.cocos.org/t/topic/86508
Step 1
适配的UI加上widget
//修改引擎resources\cocos2d-x\cocos\platform\android\java\src\org\cocos2dx\lib\Cocos2dxWebView.java文件Cocos2dxWebView函数,加两行
this.clearCache(true);
this.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
lib/utils.js修改isStandardBrowserEnv.js,增加
if(typeof cc !== 'undefined'){
return false;
}
即可解决js charAt undefined, urlParsingNode.pathname.charAt(0)的问题
creator里面没有折线图,可以参考这个
// 折线图
const { ccclass, property } = cc._decorator;
@ccclass
export default class LineChartComponent extends cc.Graphics {
@property(cc.Color)
lineColor: cc.Color = null;
@property(cc.Color)
circleColor: cc.Color = null;
@property(cc.Color)
xyColor: cc.Color = null;
@property
height = 200;
@property
width = 600;
@property
stepLeve = 7;
public paint = null;
onLoad() {
this.width += Math.floor(this.width / this.stepLeve);
}
onDestroy() {
}
start() {
this.paint = this.node.addComponent(cc.Graphics);
}
randChart() {
let list = [];
for (let i = 0; i < this.stepLeve; i++) {
list.push(Math.random() * 100);
}
this.setLineChart(list, null);
}
setLineChart(listY, listX) {
let color = this.lineColor;
// 计算数据
let max = Math.max.apply(null, listY);
let min = Math.min.apply(null, listY);
let yd = this.height / (max - min);
let xd = this.width / listY.length;
// 画横轴
this.paint.lineWidth = 5;
this.paint.strokeColor = new cc.Color(66, 66, 66, 66);
this.paint.moveTo(0, 0);
for (let i = 0; i <= this.stepLeve; i++) {
this.paint.moveTo(0, i * this.height / this.stepLeve);
this.paint.lineTo(this.width, i * this.height / this.stepLeve);
this.putLabel(-20, i * this.height / this.stepLeve - 15, Math.floor((i * (max - min) / this.stepLeve) + min), 25)
}
this.paint.stroke();
// 画数据线
this.paint.lineWidth = 5;
this.paint.strokeColor = color;
this.paint.moveTo(1, (listY[0] - min) * yd);
for (let i = 1; i < listY.length; i++) {
this.paint.lineTo(i * xd, (listY[i] - min) * yd);
}
this.paint.stroke();
// 画 刻度,点,字
this.paint.lineWidth = 4;
this.paint.strokeColor = new cc.Color(66, 66, 66, 66);
for (let i = 0; i < listY.length; i++) {
this.paint.moveTo(i * xd, 0);
this.paint.lineTo(i * xd, -10);
this.paint.stroke();
this.putPoint(i * xd, (listY[i] - min) * yd, 7)
if (listX && listX[i]) {
this.putLabel(i * xd, -40, listX[i], 25);
}
else {
this.putLabel(i * xd, -40, i, 25)
}
}
}
// xy字
putLabel(x, y, str, size) {
let textNode = new cc.Node();
let text = textNode.addComponent(cc.Label);
this.node.addChild(textNode);
text.string = str;
textNode.x = x
textNode.y = y;
textNode.height = size;
text.fontSize = textNode.height - 3;
textNode.color = this.xyColor;
}
// 画实心点
putPoint(x, y, r) {
this.paint.fillColor = this.circleColor;
this.paint.circle(x, y, r);
this.paint.fill();
}
// update (dt) {}
}
直接工具做到编译器里,这个方向不错。
window.devicePixelRatio = 3;
cc.macro.ENABLE_WEBGL_ANTIALIAS = true;
cc.view.enableRetina(true);
cc.view.resizeWithBrowserSize(true);
Editbox是creator的老问题,各个版本都有各种各样的bug,处理creator的Editbox顶的太高问题,挡住都看不到内容了,新的creator2.2.1-2.4.3都有顶太高的问题,不能选择黏贴问题。
解决方案如下: