egret升级经验记录

1、StageDelegate.setDesignSize ;

直接去掉,在3.x里是直接在index.html里设置如:

data-content-width="960"
data-content-height="640"

2、_getFrameLabelForFrame

用frameLabels[i],注意判断i的范围

3、Cannot invoke an expression whose type lacks a call signature

不是函数,错把数组当函数用了

4、锚点问题

用sublime text的正则替换,并使用AnchorUtil

先替换后再把文件放入

a、先替换 anchorX = anchorY的

([\w\.]+)\.anchorX.*anchorY.*=\s([\w\.\(\)]+)
AnchorUtil.setAnchor($1,$2)
 
b、再替换单独的 anchorX  anchorY
([\w\.]+)\.anchorX.*=\s([\d\.]+)
AnchorUtil.setAnchorX($1,$2)
 
([\w\.]+)\.anchorY.*=\s([\d\.]+)
AnchorUtil.setAnchorY($1,$2)
 
([\w\.]+)\.anchor([XY]).*=\s([\w\.\(\)]+)
AnchorUtil.setAnchor$2($1,$3)
 
c、创建游戏场景前调用AnchorUtil.init();
 
5、声音问题
之前是sound.play()
但是2.5以后改成了
play(startTime?: number, loops?: number): SoundChannel;
要修改play()的参数。play返回SoundChannel,用SoundChannel修改音量和停止播放

var sound_bg: egret.Sound =RES.getRes(name);
sound_bg.type = egret.Sound.MUSIC;

var loop_cnt = loop ? 0 : 1;
sound_ch= sound_bg.play(0,loop_cnt);

sound_ch.volume = value;
sound_ch.stop();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值