两个脚本的相互加载
来源:互联网 发布:c语言区间内素数 编辑:程序博客网 时间:2024/05/01 21:15
今天用了一天的时间实现两个界面的交换,实则是两个脚本的相互加载,通过特定的点击事件完成!
第一个脚本加载第二部分
currentTotal = 4;var HelloWorldLayer = cc.Layer.extend({ _mainUI:null, _a:null, _number:4, _resultLab:null, MAX:6, MIN:3, ctor:function () { this._super(); this._init(); }, //初始化 _init:function(){ this._mainUI = ccs.load(res.tite_json).node; this.addChild(this._mainUI); this._playGame(); }, //点击游戏进入 _playGame:function(){ this._a = this._getWidgetByName(this._mainUI, "playBtn" ); this._a.addTouchEventListener(this._inputHandler.bind(this), this._mainUI); this._getWidgetByName(this._mainUI, "leftBtn").addTouchEventListener(this._leftBtn.bind(this),this._mainUI); this._getWidgetByName(this._mainUI, "rigthBtn").addTouchEventListener(this._regtBtn.bind(this),this._mainUI); this._resultLab = this._getWidgetByName(this._mainUI,"Label_5"); }, _inputHandler:function(sender,type) { if (type == ccui.Widget.TOUCH_ENDED) { if (sender. name == "playBtn")this._changeScene(); } }, _changeScene:function(){ var scene =new cc.TransitionRotoZoom(1,new GameSence()); cc.director.runScene(scene); }, //函数封装 _getWidgetByName:function(par,name){ return ccui.helper.seekWidgetByName(par,name); },var HelloWorldScene = cc.Scene.extend({ onEnter:function () { this._super(); var layer = new HelloWorldLayer(); this.addChild(layer); }});第二脚本加载第一脚本部分var GameMainLayer = cc.Layer.extend({ _a:null, ctor:function () { this._super(); this._init(); }, _init:function(){ this._mainUI = ccs.load(res.game_json).node; this.addChild(this._mainUI); this._backMenu() }, //返回菜单 _backMenu:function() { this._a = this._getWidgetByName(this._mainUI, "backBtn" ); this._a.addTouchEventListener(this._inputHandler.bind(this), this._mainUI) }, //回调事件 _inputHandler:function(sender,type){ if (type == ccui.Widget.TOUCH_ENDED) { if (sender.name == "backBtn")this._changeScene(); } }, _changeScene:function(){ var scene =new cc.TransitionFadeTR(1,new HelloWorldLayer()); cc.director.runScene(scene); //加载游戏内界面 }, //函数封装 _getWidgetByName:function(par,name){ return ccui.helper.seekWidgetByName(par,name); }});var GameSence = cc.Scene.extend({ onEnter:function () { this._super(); this.addChild(new GameMainLayer()); }});便实现了两网页的神奇转换
0 0
- 两个脚本的相互加载
- 两个类的相互引用
- 两个类的相互引用
- 两个有用的脚本
- 异步的脚本加载
- c++ 中两个类的相互引用
- 两个头文件相互包含的问题
- 两个头文件相互包含的问题
- 两个类相互包含引用的问题
- 两个类相互包含引用的问题
- 两个类相互包含引用的问题
- 两个类相互包含的一些问题
- 两个类相互调用的例子
- 两个类相互调用的问题
- 两个页面之间js的相互调用
- C++两个类相互引用的问题
- 头文件两个类的相互引用
- 两个iOS 应用间的相互跳转
- java快速排序实现
- 素数判定
- input 只能输入数字
- 《编程之法》2.2寻找和为定值的两个数
- Replace RedHat 6.6`s yum with CentOS`s yum
- 两个脚本的相互加载
- 游戏界面的跳转
- 用draw9patch.bat绘制的气泡图片用在Android程序中有黑线,怎么解决?
- 最小生成树(vector)用法
- Service的使用(一)
- 服务器端用Servlet响应客户端请求,Gson请求。可以返回多个数据库中的信息
- MSP430 定时器输出PWM波形
- C++语言中位运算符在计算中的实际运用
- 2016 Multi-University Training Contest 1 1006 PowMod