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. applicationContext.xml配置AOP切面编程

    Computer.java package com.wh.aop2; public class Computer { public void play01(){ System.out.println( ...

  2. C语言标准库头文件

    <assert.h><complex.h><ctype.h><errno.h><fenv.h><float.h><intt ...

  3. 笔记《精通css》第4章 背景图像,平铺方式,背景定位,圆角框,投影,不透明

    第4章  背景图像,平铺方式,背景定位,圆角框,投影,不透明 1.背景图像 background-image:url() 2.平铺方式 background-repeat:repeat-x repea ...

  4. LinearLayout中间布局填充出现的问题

    线性布局如何中间填充,会挤掉他下面的布局,所以中间填充使用layout_weight属性.

  5. php中的抽象方法和抽象类

    1.什么是抽象方法?    我们在类里面定义的没有方法提的方法就是抽象方法.所谓的没有方法体指的是,在声明的时候没有大括号以及其中的内容,而是直接在声明时在方法名后加上分号结束,另外在声明抽象方法时方 ...

  6. python中struct.pack()函数和struct.unpack()函数

    python中的struct主要是用来处理C结构数据的,读入时先转换为Python的字符串类型,然后再转换为Python的结构化类型,比如元组(tuple)啥的~.一般输入的渠道来源于文件或者网络的二 ...

  7. 批量注释LOG

    sed -i "s/LOG/\/\/ LOG/g" `grep LOG\(TRACE\) -rl .`

  8. Python开发工具搭建-Pycharm

    PyCharm2017. 3.X专业版 安装使用. 注册码激活 本文以 Windows系统 为例: 1.开发工具获取及下载 Anaconda(Python 的集成工具 ) 下载地址: https:// ...

  9. (转)Java任务调度框架Quartz入门教程指南(四)Quartz任务调度框架之触发器精讲SimpleTrigger和CronTrigger、最详细的Cron表达式范例

    http://blog.csdn.net/zixiao217/article/details/53075009 Quartz的主要接口类是Schedule.Job.Trigger,而触发器Trigge ...

  10. Discuz! G变量的使用方法

    1,G变量的使用方法: 例如:$_G['style'][boardlogo] 风格变量篇 $_G['style'] => Array (官方模板区 cr180整理 $_G['style'][st ...