zoukankan      html  css  js  c++  java
  • COCOS2D 学习笔记

    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

  • 相关阅读:
    ActionBar Fragment的一个sample activity; 及获取runningAppProcess及跳转
    优化后台推送的service,减少被杀死的几率
    64位win7安装ubunto最新14.04的过程,及出现的问题的解决
    一次非线上iowait高的情况的检查
    一个愚蠢的python逻辑语法错误
    Bellman-Ford算法解决单源最短路问题
    Floyd算法解决多源最短路径问题
    最短路问题Dijkstra算法
    最小生成树之Kruskal算法
    最优二叉搜索树
  • 原文地址:https://www.cnblogs.com/yfceshi/p/7105123.html
Copyright © 2011-2022 走看看