COCOS2D 学习笔记
2014-04-22 22:50
435 查看
cc.Node.scheduleUpdate:function ()
* schedules the "update" method.
* It will use the order number 0. This method will be called every frame.
* Scheduled methods with a lower order value will be called before the ones that have a higher order value
不断地执行 Update方法
与之对应的是
schedules the "update" callback function with a custom priority.
unschedules the "update" method.
=============================================================
向量的运用
今天,一个 错误,浪费了几个小时的时间。
在cocos2D.js里面。一定要注意令到main.js在最后加载,否则在其后面的文件都无法访问, prompt referenceError
入下例,如果loading.js放在最后,则加载loading场景的时候,会出错。因为loading文件下定义的类都无法访问
开启精灵的debug mode , 在main.js的 applicationDidFinishLaunching添加如下代码
//Here to enable the sprite debug draw mode
//0: not enable sprite debug draw
//1: draw bounding box
//2: draw texture box
cc.SPRITE_DEBUG_DRAW = 1;
//Here to enable the sprite debug draw mode //0: not enable sprite debug draw //1: draw bounding box //2: draw texture box cc.SPRITE_DEBUG_DRAW =
1; //load resources// cc.LoaderScene.preload(g_resources, function () {// RL00001 the default loading are there
* schedules the "update" method.
* It will use the order number 0. This method will be called every frame.
* Scheduled methods with a lower order value will be called before the ones that have a higher order value
不断地执行 Update方法
与之对应的是
scheduleUpdateWithPriority:function (priority)
schedules the "update" callback function with a custom priority.
unscheduleUpdate:function ()
unschedules the "update" method.
=============================================================
向量的运用
// Determine the length of how far you're shooting var offset = cc.pSub(realDest, projectile.getPosition()); //求出offset,这是一个向量差值,比如realDest=(1,1),projectilePos=(3,4),求出结果应该是一个(2,3)的向量 var length = cc.pLength(offset);//Calculates distance between point an origin , 简单2维理解就是求出距离 var velocity = 480.0; //如在这里设置一个速度变量 var realMoveDuration = length / velocity;//简单的计算一个速度
今天,一个 错误,浪费了几个小时的时间。
在cocos2D.js里面。一定要注意令到main.js在最后加载,否则在其后面的文件都无法访问, prompt referenceError
入下例,如果loading.js放在最后,则加载loading场景的时候,会出错。因为loading文件下定义的类都无法访问
tag:'gameCanvas', // 2 engineDir:'./Platform/HTML5/cocos2d/', //Please make sure main.js is the last loading item otherwise the js behind that will not take effective appFiles:[ './Src/Loading.js', './Src/resource.js', './Src/MainLayer.js', './Src/config/GameConfig.js', './main.js', // './Src/Loading.js' ]
开启精灵的debug mode , 在main.js的 applicationDidFinishLaunching添加如下代码
//Here to enable the sprite debug draw mode
//0: not enable sprite debug draw
//1: draw bounding box
//2: draw texture box
cc.SPRITE_DEBUG_DRAW = 1;
//Here to enable the sprite debug draw mode //0: not enable sprite debug draw //1: draw bounding box //2: draw texture box cc.SPRITE_DEBUG_DRAW =
1; //load resources// cc.LoaderScene.preload(g_resources, function () {// RL00001 the default loading are there
相关文章推荐
- cocos2d-x学习笔记16:记录存储1:CCUserDefault 推荐
- 【Cocos2d-X开发学习笔记】第28期:游戏中音乐和音效的使用
- Cocos2d-x学习笔记一 创建场景
- Cocos2d-x学习笔记(8)
- Cocos2d-js 热更新学习笔记
- cocos2d-x学习笔记-CCNode
- Cocos2d-X 学习笔记 10 解决汉字乱码,win32工程中使用iconv配置方法
- 我的Cocos2d-x学习笔记(一)Windows下程序如何开始运行
- cocos2d-x-3.0学习笔记之如何创建开关菜单
- Cocos2D-X2.2.3学习笔记12(瞬间动作)
- 【Cocos2d-X开发学习笔记】第10期:渲染框架之几何图形的绘制
- cocos2D-x 3.x学习笔记【一】 创建新项目
- cocos2d-x学习笔记-CCAction(动作)
- Cocos2d-x学习笔记(五)实例——场景切换
- cocos2d-x 学习笔记(3)cocos2d-x 创建基本控件 及小动画
- cocos2d-html5学习笔记(七)--Action
- cocos2D-x 3.x学习笔记【二】 事件机制入门
- cocos2d-x学习笔记(二)Eclipse+cdt实现cocos2dx跨平台解决方案(转)
- 我的Cocos2d-x学习笔记(八)利用CCSpriteBatchNode进行优化
- Cocos2d - x学习笔记 [1] 导演、舞台、精灵、层