cocos creator 引擎从1.9.3升级到2.0.7的变化

参考文献:https://docs.cocos.com/creator/manual/zh/release-notes/upgrade-guide-v2.0.html
为了升级引擎,需要修改一些内容:
1.定时器相关修改:

1.9.3版本
//创建一个定时器
//checkNew为定时器回调函数
//每隔5s执行一次
var scheduler = cc.director.getScheduler();
scheduler.scheduleCallbackForTarget(this, checkNew, 5, false, 0, false)
//停止定时器
scheduler.unscheduleCallbackForTarget(this, checkNew)

2.0.7版本
//创建一个定时器
//this.checkNew为定时器回调函数
//每隔5s执行一次
this.schedule(this.checkNew, 5);
//停止定时器
this.unschedule(this.checkNew);

2.坐标函数修改

删除了setPositionX和setPositionY两个函数,直接设置.x .y属性

// 移除了与视图和渲染相关的 API,比如 getWinSize、getVisibleSize、setDepthTest、setClearColor、setProjection 等
比如var winSize = cc.director.getWinSize();
替换成var winSize = cc.view.getVisibleSize();

//移除了cc.rectContainsPoint,替换为rect.contains
    var poisition = event.touch.getLocation();
    var locationInNode = this.bg.convertToNodeSpace(poisition);
    var s = this.bg.getContentSize();
    var rect = cc.rect(0, 0, s.width, s.height);
   /* if (!cc.rectContainsPoint(rect, locationInNode)) {
        if (this.callBackFunc)
        {
            this.callBackFunc();
        }
        this.closeAndChangeScaleAction();
    }*/

    if (!rect.contains(locationInNode)) {
        if (this.callBackFunc)
        {
            this.callBackFunc();
        }
        this.closeAndChangeScaleAction();
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容