Cocos Creator 2.x升级至Cocos Creator 3.x

1.
导入类时,批量导入

2.
导入 override...关键字时,批量导入

3、
.x .y
-->
.setPosition( block.position.x, block.position.y );

4、
this.node.scale = 0.6;
-->
this.node.setScale(0.6, 0.6);

5、
node.anchorX =
node.anchorY =
node.width =
node.height =
node.getContentSize
-->
.getComponent( UITransform )!.

6、
.opacity
-->
.getComponent( UIOpacity )!.opacity

淡出
fadeOut
-->
tween( node.getComponent( UIOpacity ) ).to( 0.1, { opacity: 0 } ).start();

淡入
fadeIn
-->
tween( node.getComponent( UIOpacity ) ).to( 0.1, { opacity: 1 } ).start();

移动到目标位置。
moveTo( 0.2, cc.v2( 5, 5 ) )
-->
tween( node ).to( 0.2, { position: new Vec3( 5, 5, 0 ) } ).start();

移动指定的距离。
moveBy( 0.2, cc.v2( 5, 5 ) )
-->
const vec3:Vec3 = this.getPosition();
tween( node ).to( 0.2, { position: new Vec3( vec3.x + 5, vec3.y + 5, vec3.z ) } ).start();

缩放大小
cc.scaleTo(0.2, 1); 
->
tween( this.node ).to( 0.2, {scale:new Vec3(1,1,1)} ).start();

7.
.on( 'touchend',
-->
.on( NodeEventType.TOUCH_END,

8、
public audioSource!: AudioSource;

this.audioSource = this.node.getComponent( AudioSource )!;

this.audioSource.playOneShot( this.audio_arr[ 1 ], 1 );

this.audioSource.clip = this.audio_arr[ 0 ];
this.audioSource.play();

this.audioSource.stop();

9、
children[i].getBoundingBox().contains(pos_start_bg3)
-->
.getComponent( UITransform )?.hitTest( pos_touch, event.windowId )

10、
获取组件的世界坐标
this.node.convertToWorldSpaceAR(children[i].getPosition())
-->
children[i].getWorldPosition();

11、
世界坐标转化为容器内的坐标
this.getComponent( UITransform )!.convertToNodeSpaceAR( targetWorldPosition );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值