一些用到的动作语句
cc.MoveTo._create = cc.MoveTo.create; cc.moveTo = cc.MoveTo.create = function(duration, posOrX, y){ if (undefined === y){ return cc.MoveTo._create(duration, posOrX); }else{ return cc.MoveTo._create(duration, cc.p(posOrX, y)); } }; cc.MoveBy._create = cc.MoveBy.create; cc.moveBy = cc.MoveBy.create = function(duration, posOrX, y){ if (undefined === y){ return cc.MoveBy._create(duration, posOrX); }else{ return cc.MoveBy._create(duration, cc.p(posOrX, y)); } }; cc.JumpTo._create = cc.JumpTo.create; cc.jumpTo = cc.JumpTo.create = function(duration, position, y, height, jumps){ if (undefined === jumps){ jumps = height; height = y; return cc.JumpTo._create(duration, position, height, jumps); }else{ return cc.JumpTo._create(duration, cc.p(position, y), height, jumps); } }; cc.JumpBy._create = cc.JumpBy.create; cc.jumpBy = cc.JumpBy.create = function(duration, position, y, height, jumps){ if (undefined === jumps){ jumps = height; height = y; return cc.JumpBy._create(duration, position, height, jumps); }else{ return cc.JumpBy._create(duration, cc.p(position, y), height, jumps); } };
在循环加入的图片使用action时,this.sprite1.stopAllActions(); 用的不够熟练,加入for语句后,图片跳转过快,得不到想要的效果,寻求一种可以解决问题的新方法。。。。。。。。
音乐播放 cc.audioEngine.playMusic(res.bg_mp3) a为小写
帧动画的加载使用,定义数组var allFrame=[];for(var i=0;i<5=5;i++){var sf=new cc.SpriteFrame(“res/walk0”+i+”.png”,cc.rect(0,0,78,123));allFrame.push(sf);}
var animation=new cc.Animation(allFrame,0.03);
var animate=new cc.Animate(animation);
var act=new cc.RepeatForever(animate);
var sp=new cc.Sprite();注意不能使用Node,最好不要使用空精灵,所以var sp=new cc.Sprite(“res/walk.png”);
触摸监听的使用
字母的小写eventManager
cc.eventManager.addListener({event:cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouch:false,吞食事件,推迟动作
ontowuchbegan ended moved 定义一下
},this)
touchbegan里面一定要加return true;否则后面的moved,ended事件不好使/////
cocostudio的使用 注意加载不了csb的文件,cocostudio打包时的页面有解释,注意看
建立cocostudio项目 调用语句var LoginJS=ccs.load(“res/MainScene.json”);this.addChild(LoginJS.node);加载文件
加载plist文件,resource.ls文件中引入.png ,plist资源 使用particlesystem加载资源文件
添加粒子效果,this.spark = new cc.ParticleSystem(res.spark_plist);