Cocos2d-JS 2017.1.16-代码阅读笔记
来源:互联网 发布:波士顿矩阵ppt模板 编辑:程序博客网 时间:2024/05/02 03:06
导演管理整个场景,场景Scene.永远有且只有一个存在。
层是添加到Scene上的。
导演管理动画的播放stopAnimation。如果通过变量invalid控制。
call:继承的时候改变this的指向,call里面的对象变成this。
mainLoop: function () { if (this._purgeDirectorInNextLoop) { this._purgeDirectorInNextLoop = false; this.purgeDirector(); } else if (!this.invalid) { this.drawScene(); }},
当导演管理栈长度为0时,调用:::
end: function () { this._purgeDirectorInNextLoop = true;},
当_purgeDirectorInNextLoop == true时,净化导演,清除定时器
this.getScheduler().unsheduleAll();
if ( cc.eventMananger )
cc.eventManager.setEnabled( false );
if ( this._runningScene )
this._runningScene.onExitTransitionDidStart();
this._runningScene.onExit();
this._runningScene.cleanUp();
this._runningScene = null;
this._nextScene = null;
this._scenesStack.length = 0;this.purgeCachedData();purgeCachedData: function () { cc.animationCache._clear(); cc.spriteFrameCache._clear(); cc.textureCache._clear();},
/** * Stops animation */stopAnimation: function () { this.invalid = true;},在drawScene() 里面:==》cc.renderer = cc.rendererWebGL;this.setNextScene(),绘制下一个Scene的操作。
cc.eventManager.dispatchEvent(this._eventAfterDraw);//派发时间this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);this._eventAfterDraw.setUserData(this);if (this._afterVisitScene) this._afterVisitScene();函数放到IF条件变量里面。必须得去掉括号!!!
cc.Node.prototype.onExitTransitionDidStart.call(this);// 加载资源,并进入游戏 在resource.js 中添加的地图中的资源组cc.LoaderScene.preload(g_gamePlay_resources, function () { GameManager.loadLevelData(GameManager.getLevel()); cc.director.runScene(new GamePlayScene());}, this);cc.LoaderScene.preload( g_gamePlay_resources, function () {GameManager.loadLevelData( GameManager.getLevel() );cc.director.runScene( new GamePlayScene());}, this};瓦片地图资源::var node = new cc.TMXTiledMap("res/ChooseLevel/Map/TiledMap.tmx");var objectGroup = node.getObjectGroup("point"); //获得瓦片地图中的格子地图信息var objs = objectGroup.getObjects();//在场景的构造函数添加播放音乐,达到人未到声先到的效果cc.audioEngine.playMusic("res/Sound/GamePlay/BGMusic01.mp3", true);//停止音乐cc.audioEngine.stopMusic();事件:: 通过事件来对其他层进行处理一些操作在Menu.js中// 触摸事件结束时响应
// [事件抛出]隐藏菜单层var event = new cc.EventCustom(jf.EventName.GP_REMOVE_MENU_LAYER);cc.eventManager.dispatchEvent(event); //事件管理层派发事件在GamePlay.js中监听事件::移除菜单层var onRemoveMenuLayerListener = cc.EventListener.create({ event : cc.EventListener.CUSTOM, target : this, eventName : jf.EventName.GP_REMOVE_MENU_LAYER , callback : this.onRemoveMenuLayer});cc.eventManager.addListener(onRemoveMenuLayerListener, this);ScrollView的创建::var node = new ccui.ScrollView();this.addChild( node );this.scorllView = node;node.setDirection( ccui.ScrollView.DIR_HORIZONTAL );// 水平方向node.setTouchEnabled( true ); // 吞噬触摸node.setContentSize( cc.winSize ); // 设置容器大小var nextPos = 0;var imageView = null;for ( var i = 0; i< 14; i++ ) { imageView = new ccui.ImageView( "res/ChooseLevel/Map/stage_map_" + i + ".png" ); node.addChild( imageView ); imageView.setAnchorPoint( cc.p( 0, 0.5 ) ); imageView.setPosition( nextPosX, cc.winSize.height ); nextPosX += imageView.width;}node.setInnerContainerSize( cc.size(nextPosX, cc.winSize.height ) ); //容器的大小 width, height
0 0
- Cocos2d-JS 2017.1.16-代码阅读笔记
- Cocos2d-JS 2017.1.13-代码阅读笔记
- Cocos2d-JS 2017.1.18-代码阅读笔记
- Cocos2d-JS 2017.1.19-代码阅读笔记
- Cocos2d-JS 2017.1.17-代码阅读笔记(一)
- Cocos2d-JS 2017.1.17-代码阅读笔记(二)
- cocos2d-x 代码阅读笔记
- cocos js代码阅读笔记_170510(二)
- cocos js 代码阅读笔记_170510(一)
- OpenOBEX代码阅读笔记
- 《代码大全》阅读笔记
- OpenOBEX代码阅读笔记
- larbin代码阅读笔记
- OpenOBEX代码阅读笔记
- 代码整洁阅读笔记
- live_media_代码阅读笔记
- 代码阅读笔记
- JSVM代码阅读笔记
- Androidstudio 最快的生成UML图
- 用c语言实现一个通信录
- java输出输入流
- java static
- 洛谷 P1086 花生采摘
- Cocos2d-JS 2017.1.16-代码阅读笔记
- 微信相框plus详细体验
- 沃美冲出战阵召唤出广宇神兽
- 杂记
- JZOJ 3807 【NOIP2014模拟8.25】地砖铺设
- codeforces 755E PolandBall and White-Red graph
- QCustomplot使用分享(四) QCPAbstractItem
- SpringBoot -- 服务网关APIGateway
- Nginx学习总结(7)——Nginx配置HTTPS 服务器