学习贪吃蛇JS项目实战笔记2
2015-12-08 21:15
671 查看
一些用到的动作语句
在循环加入的图片使用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);
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);
相关文章推荐
- html+css+javascript 基础知识(一)
- javascript如何写热点图
- json
- 贪吃蛇游戏实战学习JS
- js实时显示系统时间
- 轻松学习JavaScript十二:JavaScript基于面向对象之创建对象(二)
- js的浮点运算问题
- JSP语法的练习
- Gson->Gson创建json字符串,与解析json字符串
- JSP表格的表头固定不动
- JSP九大内置对象
- js中的open()函数相关的全部知识点
- JavaScript 系列笔记(一)数据类型
- js中innerText,innerHTML的用法
- JavaScript 判断 DOM 何时加载完毕
- JS getAttribute和setAttribute(取得和设置属性)的使用介绍
- js小知识
- [Javascript Data Structures] 二分查找 Binary Search
- JSP指令
- Fiddler进行模拟Post提交json数据,总为null解决方式