- 博客(23)
- 收藏
- 关注
原创 animation动画事件
动画事件回调let anim= this.logoNode.getComponent(cc.Animation);anim.play("logoStart");//anim.on("finished", (event, date) => { //事件结束后根据播放动画的名字回调 if (date.name == "logoStart") { anim.play("logoIdle"); };}, this);//注册后自动销毁的事件anim.once(
2020-08-01 16:51:39
341
原创 creator节点的事件吞噬
//是否吞噬事件 this.node._touchListener.setSwallowTouches(false);
2020-07-25 07:15:06
423
原创 微信坐标转换creator坐标
//创建更多游戏按钮 createMoreGameButton() { if (typeof (tt) == "undefined") { return }; let sysInfo = tt.getSystemInfoSync() if (sysInfo.platform == "ios") return; let node = cc.find("Canvas/top/moreGamesButton"); l...
2020-06-22 17:48:52
489
原创 函数注释规范
/*方法说明 *@method 方法名 *@for 所属类名 *@param{参数类型}参数名 参数说明 *@return {返回值类型} 返回值说明*/
2020-06-21 09:27:14
333
原创 圆等分生成坐标点
圆等分生成坐标点 /** * 以某点为圆心,生成圆周上等分点的坐标 * * @param {number} r 半径 * @param {cc.Vec2} pos 圆心坐标 * @param {number} count 等分点数量 * @param {number} [randomScope=80] 等分点的随机波动范围 * @returns {cc.Vec2[]} 返回等分点坐标 */ getCirclePoints(r, pos, count, randomScope) {
2020-06-20 16:57:57
2886
1
原创 往移动目标处移动
往移动目标处移动cc.vec().normalize();归一化就是要把需要处理的数据经过处理后 (通过某种算法)限制在你需要的一定范围内。首先归一化是为了后面数据处理的方便,其次是保证程序运行时收敛加快。归一化的具体作用是归纳统一样本的统计 分布性。归一化在0-1之间是统计的概率分布,归一化在某个区间上是统计的坐标分布。归一化有同一、统一和合一的意思。cc.vec().fuzzyEquals(cc.vec(),“范围”);cc.vec().mul(); 向量缩放cc.vec().add ; 向量
2020-06-19 18:19:54
172
原创 对象池小问题
对象池小问题在不需要的时候放入对象池 this.NodePool.put(node)不要在创建完成时放入对象池,否则会出现第一次无法回收的bug//创建eggUI createEggUI() { let node = null; if (this.eggUINodePool.size() > 0) { //节点池有就用节点池 node = this.eggUINodePool.get();
2020-06-15 11:41:31
142
原创 帧事件
在动画编辑器添加帧事件 函数名在调用动画的的地方 //logo 动画 playLogoAnim() { let logoAnim = cc.find("UI_ROOT/top/logo").getComponent(cc.Animation); logoAnim.play("logo_start"); logoAnim.playeLogoAnim = () => { logoAnim.play("logoAnim
2020-06-14 15:46:13
471
原创 小游戏本地图片绝对路径
小游戏本地图片路径Texture是保存在GPU缓冲中的一张纹理。是由一张图片创建获得的,记录了图片的各种信息。SpriteFrame是Texture+Rect,根据一张纹理材质来剪切获得。SpriteFrame是Texture+Rect,过程是这样的,Texture是通过指定图片得到的,然后,指定用这个Texture指定具体的Rect就是SpriteFrame//只有cc.Texture2D 才能获取到路径cc.loder.loadRes(resPath,cc.Texture2D,(err,r
2020-06-10 09:46:38
745
原创 头条录屏相关功能
头条录屏相关功能//初始化录屏功能 iniTape() { //录屏的保存路径 this.tapePath = null; this.tapeStartTime = 0; this.tapeState = "unstart"; this.tapeMaxTime = 90; this.recorder = tt.getGameRecorderManager(); }, //手动触发录屏
2020-06-06 17:44:59
1018
原创 向量线性插值
相机线性插值cc.misc.lerp(“目标位置”,“当前位置”,“比例”) lateUpdate(dt) { if (this.gameState== State.normal) { return; }; this.mainCamera.y = cc.misc.lerp(this.playerNode.y, this.mainCamera.y,0.1);; },...
2020-06-05 15:37:36
1510
原创 分帧创建预制体
分帧创建预制体 for (let i = 0; i < 10; i++) { this.scheduleOnce(() => { let node = cc.instantiate(this.handBookItem) node.parent = this.contentArr[this.mapIndex]; node.getComponent("handBoo
2020-06-05 11:43:42
217
原创 loading预加载
loading预加载cc.Class({ extends: cc.Component, properties: { progressLabel: cc.Label, tipsLabelNode: cc.Node, }, //预加载资源 preLoadResDir() { cc.loader.loadResDir("sound", (completedCount, totalCount, item) => {
2020-06-05 11:29:17
220
原创 tapUI制作
tapUI制作创建几个选项卡, 添加 toggle组件,选中的效果要作为节点的子节点每个tab,都会传入一个值,用for循环遍历,如果传的值等于 循环的那个,就让 tab对应的栏显示start(){},内的函数只会在游戏开始后执行一次 //选项切换 onToggleButtonClick(e, cutomData) { this.soundControl.playSoundEffect("buttonClick"); let index = parseI
2020-06-03 11:27:00
228
原创 通用tips动画
通用tips动画 tipsNodeAnim() { cc.tween(this.node) .to(0.3, { y: 30, opacity: 255 }, { easing: "sineOut" }) .delay(1) .to(0.3, { y: 120, opacity: 0 }, { easing: "sineIn" }) .call(() => {
2020-06-03 11:22:58
225
原创 金币数字滚动增加
金币数字滚动增加 //星星动态更新 updateStarLabel: function (num) { let timeCount = 10; let star = userData.star; let starLabel = this.homeUI_js.starLabel; let callback = function () { timeCount--; let Pnum =
2020-06-03 11:19:48
535
原创 金币飞往目标位置
金币飞往目标位置//创建获得星星效果 createStarEffect(cNode, count, goldNum) { //创建的节点,个数,金币数量 //在哪个位置进行创建世界坐标 let icon = cc.find("Canvas/homeUI/top/starGroup/starIcon"); //创建节点所在的世界坐标 let cWpos = cNode.parent.convertToWorldSpac
2020-06-03 11:18:31
472
原创 小游戏存档管理
小游戏存档管理import userData from "userData";export default { //合并存档 mergeJSON(n, o) { let oType = Object.prototype.toString.call(o); let nType = Object.prototype.toString.call(n); if (nType == '[object Object]' && oType
2020-06-03 11:16:37
520
原创 var let const 的区别
var let const 的区别var 是局部变量或者全局变量,在执行时会提升层级let 是块级变量,只有在定义时才能进行访问const为严格变量,在定时时且声明,只能进行访问如果用for循环里定义一个var ,因为var 执行会提升层级,所有var 永远指最后一个对象。关键点是:1.理解作用域链。2.var和let的作用域。3.变量提升。详细讲解一下:铺垫知识:1.var声明变量是函数作用域,而let声明变量是语句块作用域;2.var提升到函数定义顶部,此处是全局作用域顶部;let
2020-06-03 11:14:14
217
原创 cocos creator 广告控制脚本
cocos creator 广告控制脚本广告控制const State = { fail: 0, succes: 1,};cc.Class({ extends: cc.Component, properties: { }, //打开右上角3个点转发 openShare() { if (typeof (wx) !== "undefined") { //显示当前页面右上角的转发按钮
2020-06-03 11:10:54
603
原创 cocos creator 音频控制
cocos creator 音频控制音频控制脚本import userData from "userData";import resPath from "../config/resPath";cc.Class({ extends: cc.Component, properties: { }, //播放背景音乐 playBgSound() { let soundState = userData.soundState; if (
2020-06-03 11:05:33
694
原创 cocos creator 跳转其他小游戏
cocos creator 跳转其他小游戏微信小游戏 appid 要填写在 game.json里才能跳转成功"navigateToMiniProgramAppIdList": [ "appid0", "appid1" ]为icon添加按钮点击事件 //icon 被点击 onGameIconClick(e, cutomData) { let appid = this.setAppid(cutomData); if
2020-06-03 11:01:54
686
原创 cocos creator 动态加载资源
cocos creator 动态加载资源引入文件路径import resPath from "resPath";加载整个文件夹 //动态加载某个文件下的所有资源,并使用 setSpriteFrame(sprite, name) { let texName = resPath[name]; cc.loader.loadResDir(texName, cc.SpriteFrame, (error, object) => { i
2020-06-03 10:55:39
376
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人