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方法

与之相应的是

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 学习笔记的更多相关文章

  1. cocos2d学习笔记

    doxygen工具 生成cocos2d的api文档 位图字体编辑工具 Glyph Designer http://www.71squared.com/glyphdesigner  收费的 CCLabl ...

  2. cocos2dx游戏开发——微信打飞机学习笔记(三)——WelcomeScene的搭建

    一.场景与层的关系: cocos2dx的框架可以说主要由导演,场景,层,精灵来构成: 1.其中导演,意如其名,就是操控整个游戏的一个单例,管理着整个游戏. 2.场景就像电影的一幕剧情,所以说,懂得如何 ...

  3. android cocos2d-x for Android安装和学习笔记(请用adt-bundle21.1或以上导入)

    引用:http://weimingtom.iteye.com/blog/1483566 (20121108)注意:这篇文章用cdt编译ndk工程的内容已过时(现在可以用adt-bundle,避免配置繁 ...

  4. [Cocos2d-x for WP8学习笔记] HelloWorld结构分析

    先来看一下目录结构: Assets:游戏资源文件,图片音频等,Resource文件夹也有类似功能 include:用于放置游戏头文件 Shaders:渲染器着色器文件(大雾) cocos2dorig. ...

  5. cocos2d-x实战 C++卷 学习笔记--第4章 字符串 __String类

    前言: <cocos2d-x实战C++卷>学习笔记.(cocos2d-x 是3.0版本) 介绍 cocos2d-x 通用的字符串类  __String . 使用cocos2d::__Str ...

  6. Cocos2d-x学习笔记(17)(TestCpp源代码分析-1)

    TestCpp源代码基于Cocos2d-x2.1.3版本号,部分资源来自红孩儿的游戏编程之路CSDN博客地址http://blog.csdn.net/honghaier/article/details ...

  7. 《Cocos2d-x游戏开发实战精解》学习笔记4--实战一个简单的钢琴

    上一节学习了使用Cocos2d-x播放音乐的方法,但是那种方法一般只适合于播放较大的音乐,而一般比较短小的音乐(如游戏中的打斗.按键音效等)则要通过playEffect来播放.本节使用该方法以及之前学 ...

  8. 《Cocos2d-x游戏开发实战精解》学习笔记3--在Cocos2d-x中播放声音

    <Cocos2d-x游戏开发实战精解>学习笔记1--在Cocos2d中显示图像 <Cocos2d-x游戏开发实战精解>学习笔记2--在Cocos2d-x中显示一行文字 之前的内 ...

  9. cocos2d-html5学习笔记(六)--alpha2中cc.Sequence.create中的bug

    cocos2d-html5学习笔记(六)--alpha2中cc.Sequence.create中的bug http://blog.csdn.net/allenice1/article/details/ ...

随机推荐

  1. EF--ModelFirst

    EF框架有三种基本的方式:DB First,Model First,Code First.这里简单的说一下Model First,适合没有基础的同学照着做,学习基础的东西. 1.建立一个类库项目,这个 ...

  2. MySQL的DML和DQL 增删改查

    DML和DQL   增删改查 SELECT * FROM grade --新增 insert -- 向年级表中新增3条数据INSERT INTO grade(gradeID,gradeName) VA ...

  3. 诡异之--map clear 之后可能导致size != 0的操作

    map<char, int>mp; charMp[; charMp['b'] ++; cout<<charMp['a']<<endl; cout<<ch ...

  4. [转]如何借助 TLS/SSL 确保套接字连接的安全(使用 C#/VB/C++ 和 XAML 的 Windows 应用商店应用)

    本文转自:http://msdn.microsoft.com/zh-cn/library/windows/apps/jj150597.aspx 本主题将展示在使用 StreamSocket 功能时,如 ...

  5. 附加数据库错误代码 - 5120【MSSQL】

    解决方法 数据库所在的文件夹右击打开属性 - 安全 - 给予Authenticated Users用户完全控制权限.然后再附加一次即可成功.

  6. Unity学习-地形的设置(五)

    添加地形游戏对象 [Hierarchy-Create-Terrain] 为了看的看清楚,在添加一个平行光 [Hierarchy-Create-Direction light] 导入地形包 [Asset ...

  7. android ormlite 清空表

    delete from TableName; //清空数据 update sqlite_sequence SET seq = where name ='TableName';//自增长ID为0 Sam ...

  8. 【译】x86程序员手册00 - 翻译起因

    从上一次学习MIT的操作系统课程又过去了一年.上次学习并没有坚持下去.想来虽有种种原因,其还在自身无法坚持罢了.故此次再鼓起勇气重新学习,发现课程都已由2014改版为2016了.但大部分内容并没有改变 ...

  9. 【技术累积】【点】【java】【30】代理模式

    基础 代理模式是Java常见的设计模式之一.所谓代理模式是指客户端并不直接调用实际的对象,而是通过调用代理,来间接的调用实际的对象. 什么是代理 参考现实生活中的代理 比如某个品牌的某个省的代理商,作 ...

  10. C# 获取表中最大值

    ; if (db.LPicture.Any()) { // LPicture Newmode = db.LPicture.Where(n => ).FirstOrDefault(); start ...