常规node属性
node.x -> node.position.x node.y -> node.postion.y node.color -> node.getComponent(Sprite).color node.opacity -> node.getComponent(UIOpacity).opacity node.width -> node.getComponent(UITransform).width node.height -> node.getComponent(UITransform).height node.anchorX -> node.getComponent(UITransform).anchorX node.anchorY -> node.getComponent(UITransform).anchorY
removeFromParent不能传参了
原removeFromParent(true)和removeFromParent(false), 现在不能传参了
removeFromParent(true)和removeFromParent(false) -> removeFromParent()
计时器Scheduler的enableFroTarget
Scheduler.enableForTarget的对象必须继承自接口ISchedulable,继承ISchedulable接口的有System、CCObject。
cc.director.getScheduler().enableForTarget(this); -> Scheduler.enableForTarget(this);
macro不能自动导入,只能鼠标移到macro上然后点击修复
sheduler.schedule(()=>{}, this, 1, macro.REPEAT_FOREVER);
![](https://img2020.cnblogs.com/blog/1062174/202109/1062174-20210922151406074-998673796.png)
SpriteFrame
纹理、原始大小等接口都变了
spriteFrame.getTexture() -> spriteFrame.texture spriteFrame.getOriginalSize() -> spriteFrame.originalSize let newSp = new cc.SpriteFrame(texture, cc.rect(0, 0, texture.width, texture.height)); -> let newSp = new SpriteFrame(); newSp.setRect(cc.rect(j * width, i * height, width, height)); newSp.texture = texture; newSp.rect = rect(j * width, i * height, width, height);
鼠标事件getLocation
EventTouch e.getLocation -> e.getUILocation
按钮吞噬事件
(this.node as any)._touchListener.setSwallowTouches(false) -> this.topBg.eventProcessor.touchListener.setSwallowTouches(false)
调试面板
![](https://img2020.cnblogs.com/blog/1062174/202109/1062174-20210922152813952-1539853804.png)
Framerate 帧率,一般为60,表示每秒钟刷新60次
Draw call 通知GPU渲染的过程称为一次Draw Call
Frame time 每帧时间,1秒/60次 = 16.67毫秒Instance Count 实例数量?
Triangle 三角面数量?
Game Logic 游戏逻辑耗时
Physics 物理引擎耗时
Renderer 渲染耗时
GFX Texture Mem 纹理缓存 一张512x512的32位图占用内存 8位=1字节,32位=4字节, 512x512x4 = 1048576字节, 1024字节=1KB, 1024KB=1M, 1048576/1024/1024 = 1M
GFX Buffer Mem ?
获取屏幕尺寸
cc.WinSize -> view.getFrameSize()
Camera的Visiblity属性
如果是新建的node,node默认Layer是default,而Camera没有勾选可见default的话,那么节点不会显示。
![](https://img2020.cnblogs.com/blog/1062174/202109/1062174-20210925153244177-742989002.png)
EventTarget
原来2.x的on、off、emit这些接口没有了,3.x变成了addEventListener之类的....
保留cc的用法
3.x版本cc.Node改成了Node,没有了前缀'cc'。
import { _decorator, Component, Node } from 'cc'; const { ccclass, property } = _decorator; @ccclass('MainScene') export class MainScene extends Component { start () { let node:Node = new Node(); } }
导致代码提示的时候,眼神不好可能会选错,例如下面有2个Animation的提示。
![](https://img2020.cnblogs.com/blog/1062174/202109/1062174-20210928114333887-1505862840.png)
使用 import * as cc from "cc"; 可以继续使用cc.Node来访问
import * as cc from "cc"; const { ccclass, property } = cc._decorator; @ccclass('MainScene') export class MainScene extends cc.Component { start() { let node: cc.Node = new cc.Node(); } }