creator 遇到的问题--更新中.

  1. layout  父节点透明子节点不透明  creator 2.0 已经移除了 cascadeOpacity 的相关方法
    解决办法--> 给layout中的sprite设置一张透明的图片。 完美解决
     
  2. creator 代码中的require的文件不能加 .js
         require("gameData.js")   要改为  require("gameData"), 否则微信小程序里会报错,can not find module  gameData
     
  3. cc.Label组件设置string没有及时更改
       this.btn_pause.node.getChildByName("lb_text").string = this.status ? "继续" : "暂停";
       这样写的结果导致按钮上的文字并没有及时更改,正确的方式是
          var lb_text = this.btn_pause.node.getChildByName("lb_text");
          lb_text.getComponent(cc.Label).string = this.status ? "继续" : "暂停";
     
  4. sprite 赋值 resources 目录下的方法 :两种
    // 通过cc.rul.row
    var cocos = this.node.getChildByName("cocos");
    cocos.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(cc.url.raw("resources/helloworld/snow.png"));
    // 通过cc.loader.loadRes
    var myImage = cc.find("Canvas/myImage").getComponent(cc.Sprite);
    cc.loader.loadRes("helloworld/table.png", cc.SpriteFrame, function(err, spFrame) {
        myImage.spriteFrame = spFrame;
    })
    var myImage2 = cc.find("Canvas/myImage2").getComponent(cc.Sprite);
    cc.loader.loadRes("plists/cards.plist", cc.SpriteAtlas, function(err, atlas) {
        // 方法一  通过数组加载
        // myImage2.spriteFrame = atlas.getSpriteFrames()[0];
        // 方法二  通过名字加载
        myImage2.spriteFrame = atlas.getSpriteFrame("bug_orange_1");
    });

    //声音加载

    cc.audioEngine.playMusic(this.bg_muisc, true);
    // 动态加载
    cc.loader.loadRes("voices/audio/niu.mp3", cc.AudioClip, function(err, voice) {
        cc.audioEngine.playMusic(voice, true);
    });

     

  5. 动态资源加载 放到 assets/resources 目录下
     
  6. cc  的理解。 cc 是全局对象, 在游戏登陆的时候初始化全局变量可以赋值给cc.game cc.user 这样就可以全局使用了。
    即使切换场景了,cc.x 复制的东西还是存在的
     
  7.  反转node    水平反转,设置scaleX = -1,  垂直反转 scaleY = -1;
     
  8. 设置按钮的隐藏,只能用   self.btn_fight.node.active = true;  
                                不能用  self.btn_fight.getComponent(cc.Node).active = true;  
     
  9. 全局 消息监听和发送,  cc.director.on() , cc.director.off(), cc.director.emit();
     
  10. console.log("-----------changeCock-cock/animations/ji" + info.id + "/ji" + info.id + ".atlas");
    cc.loader.loadRes("cock/animations/ji" + info.id + "/ji" + info.id, sp.SkeletonData, function(err, spine) {

    通过 cc.loader.loadRes , 第一个param  不应该加 后缀,  否则会显示不成功
     
  11. cc.director 可以执行 once 注册事件,回调会在第一时间被触发后删除自身。
    也可以通过cc.director dispatchEvent 通过对象派发事件。
     
  12. 设置背景随文字长度变化,: 9宫格。Node. 添加cc.Spirte 设置背景图片,sprite types设置成Sliced. 再添加一个Layout 
  13. let widget = bg.addComponent(cc.Widget);
                            widget.alignMode = 1;
                            widget.isAlignBottom = true;
                            widget.isAlignLeft = true;
                            widget.isAlignRight = true;
                            widget.isAlignTop = true;
                            widget.target = this.node;
  14. cc.BlockInputEvents 添加可以使 node 吞噬触摸
    //  node.addComponent(cc.BlockInputEvents);
     
  15. cc.EventTarget
    // 使用这个可以在多个没有依赖关系的,A,B,C,D上添加同一个监听事件fire,在消息分发emit(EventA)后,ABCD四处地方都可以响应这个事件

    ```js
    eventTarget.on('fire', function () {
            cc.log("fire in the hole");
    }, A(|| B || C || D));
    ```

  16.  node  on 监听,
    nodeA->B->C
    在ABC 同时监听fire事件,在C消息分发emit("fire")后,会依次上传B,然后到A,在BC监听消息回调不会触发。
    如果想让事件阻止向上传递,event.stopPropagation()
     
  17. 设置是否在左下角显示 FPS
    cc.debug.setDisplayStats(CC_DEBUG);
     
  18. Animation 提供了一系列可注册的事件:
    - play : 开始播放时
    - stop : 停止播放时
    - pause : 暂停播放时
    - resume : 恢复播放时
    - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
    - finished : 动画播放完成时 */

  19. ts  共用单例类

    export class SingleBase extends cc.EventTarget {
        public static getInstance<T>(this: new () => T): T {
            if (!(<any>this).instance) {
                (<any>this).instance = new this();
                (<any>this).instance.init();
            }
            return (<any>this).instance;
        }
    
        public static deleteInstance() {
            if ((<any>this).instance) {
                (<any>this).instance.clear();
                delete (<any>this).instance;
            }
        }
    
        public init(name: any, ...args) {
            return this;
        }
    
        public clear(): void {
        }
    }
    

     

  20. 4

  21. 5

  22. 6

  23. 7

  24. 8

  25. 9

  26. 0

  27. -

 

 

 

   

 

 

       

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值