• 碰撞检测道具拾取 collider.zip

    creator碰撞检测的实现和道具拾取功能;碰撞检测系统;三个接口: onCollisionEnter: function (other, self) // 开始 onCollisionStay: function (other, self) // 持续 onCollisionExit: function (other, self) // 结束

    0
    242
    799KB
    2020-03-04
    31
  • cocos creator实例--使用creator简单实现连连看游戏 | 附代码LLK.zip

    cocos creator实例--使用creator简单实现连连看游戏 | 附代码。点击相同的两个动物图案,会消失一个选中框,然后就会消失掉

    0
    2158
    918KB
    2020-01-17
    42
  • cocos creator实例--游戏Bad Piggies中的一些物理特性的分析 | 附代码phys.zip

    cocos creator实例--游戏Bad Piggies中的一些物理特性的分析 | 附代码;为了学习研究creator的物理特性,只有是从刚体、碰撞、关节等组件的属性来着手。这篇文章取材于Bad Piggies游戏,主要是来分析学习creator的一些物理特性。原文地址https://blog.csdn.net/ccnu027cs/article/details/103958130

    0
    170
    769KB
    2020-01-14
    10
  • cocos creator实例--实现FlappyBird游戏的基本功能 | 附代码FlappyBird.zip

    FlappyBird是早期的早IOS上的一款非常受欢迎的像素游戏。 点击屏幕控制小鸟上下飞行;小鸟在飞行的过程中,碰撞到管子就结束游戏,飞过一根管子分数加1;

    0
    661
    1.04MB
    2020-01-13
    50
  • 新版Creator 2.1.2,终于支持 ShaderHelper 了----ShaderHelper2.zip

    新版Creator 2.1.2,终于支持 ShaderHelper 了 let ShaderProperty = cc . Class ({ name : 'ShaderProperty' , properties : { key : '' , value : '' , } }); cc . Class ({ extends : cc . Component , properties : { effect : cc . EffectAsset , //effect资源 speed : 0.01 , //控制动态Shader的time参数 props : [ ShaderProperty ], //shader参数 }, start () { if (! this . effect ) { return ; } //获取精灵组件 let sprite = this . node . getComponent ( cc . Sprite ); if (! sprite ) { return ; } //实例化一个材质对象 let material = new cc . Material (); //在材质对象上开启USE_TEXTURE定义 material . define ( 'USE_TEXTURE' , true ); //为材质设置effect,也是就绑定Shader了 material . effectAsset = this . effect ; material . name = this . effect . name ; //将材质绑定到精灵组件上,精灵可以绑定多个材质 //这里我们替换0号默认材质 sprite . setMaterial ( 0 , material ); //从精灵组件上获取材质,这步很重要,不然没效果 this . material = sprite . getMaterial ( 0 ); //初始化参数 this . time = 0 ; this . props . forEach ( item => this . material . setProperty ( item . key , item . value )); }, /** * 在update事件中更新材质参数 * 不同的Shader这里可能需要重写 */ update () { if (! this . material || ! this . speed ) { return ; } if ( this . flag ) { this . time += this . speed ; } else { this . time -= this . speed ; } if ( this . time >= 1.2 ) { this . flag = 0 ; } else if ( this . time <= - 0.2 ) { this . flag = 1 ; } //更新Shader代码中的time参数 this . material . setProperty ( 'time' , this . time ); }, });

    0
    122
    793KB
    2019-12-16
    15
  • 如何用一张图片来实现炫光方块--炫光.zip

    如何用一张图片来实现炫光方块 CocosCreator 的节点上的颜色属性对 3D 模型是不起作用的,要想修改模型颜色就要对材质操作,而材质是基于 effect 渲染的。那么怎么改变模型颜色呢?

    0
    159
    1.19MB
    2019-12-16
    10
  • 简单猴子吃香蕉游戏,做项目构建流程定制monkey.zip

    简单猴子吃香蕉游戏,做项目构建流程定制 主要介绍游戏玩法,具体实现,参考游戏源码。玩法是:游戏开始后,通过虚拟摇杆控制猴子在屏幕左右方向跳动,屏幕上随机出现香蕉,过一段时间后消失,猴子吃到香蕉得分,如果等到香蕉消失时,猴子仍旧没吃到,则游戏结束。

    0
    533
    1.66MB
    2019-12-16
    28
  • Label长文本手机上不显示处理longText.zip

    Label长文本手机上不显示处理 // Learn cc.Class: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { nodeModule: cc.Node, nodeContainer: cc.Node, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start () { }, // update (dt) {}, setLongText(longText){ // 界限值 const WORDS_COUNT = 100; let str = longText; let left = ''; do{ let index = str.indexOf('\n'); if(index == -1){ break; } left = left + str.substring(0, index); str = str.substring(index); while(str.length > 0 && str[0] == '\n'){ left = left + str[0]; str = str.substring(1); } if(left.length > WORDS_COUNT){ if(left.length >= 1&& left[left.length - 1] == '\n'){ left = left.substring(0, left.length -1); } this.addModule(left); left = ''; } }while(str.length > WORDS_COUNT); if(left != ''){ this.addModule(left); } if(str != ''){ this.addModule(str); } }, addModule(text){ cc.log('##text##', text); let node = cc.instantiate(this.nodeModule); node.active = true; node.getComponent(cc.Label).string = text; this.nodeContainer.addChild(node); }, onClick(){ this.setLongText(`

    0
    193
    185KB
    2019-12-16
    10
  • Creator数钱小游戏源码CountMoney.zip

    Creator数钱小游戏源码CountMoney.zip // Learn cc.Class: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { nodeMoney: cc.Node, nodeGuide: cc.Node, nodeStart: cc.Node, txtCount: cc.Label, txtTime: cc.Label, nodeMoneyBg: cc.Node, nodeTimerBg: cc.Node, nodeSpillMoney: cc.Node, txtTotal: cc.Label, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.node.on(cc.Node.EventType.TOUCH_START, event => { this.onTouchStart(event); }); this.node.on(cc.Node.EventType.TOUCH_MOVE, event => { this.onTouchMove(event); }); this.node.on(cc.Node.EventType.TOUCH_END, event => { this.onTouchEnd(event); }); this.nodeMoneyBg.zIndex = 10; this.nodeTimerBg.zIndex = 10; this.nodeStart.zIndex = 20; this._touchNode = null; this._count = 0; this._isPlaying = false; }, start () { }, startGame(){ this._isPlaying = true; this.nodeStart.active = false; this.txtTime.string = 10; this.txtCount.string = 0; this._count = 0; this.startTimer(); this.spillMoney(); }, startTimer(){ this.schedule(this.timeCallback, 1); }, timeCallback(){ let time = parseInt(this.txtTime.string); time--; this.txtTime.string = time; if(time <= 0){ this.unschedule(this.timeCallback); this.onTimeout(); } }, onTimeout(){ this.onGameEnd(); }, onGameEnd(){ this.nodeStart.active = true; this._isPlaying = false; this.node.stopActionByTag(0xff); this.txtTotal.string = `¥${this._count * 100}`; }, // update (dt) {}, onTouchStart(event){ if(!this._isPlaying){ return; } this._touchNode = cc.instantiate(this.nodeMoney); this._touchNode.active = true; this._touchNode.parent = this.nodeMoney.parent; this.nodeGuide.active = false; }, onTouchMove(event){ if(!this._isPlaying){ return; } let pos = event.getLocation(); pos = this._touchNode.parent.convertToNodeSpaceAR(pos); if(pos.y > this._touchNode.y){ this._touchNode.y = pos.y; } }, onTouchEnd(event){ if(!this._isPlaying){ return; } let now = event.getLocation(); let start = event.getStartLocation(); if(now.y - start.y > 10){ let seq = cc.sequence( cc.spawn( cc.moveBy(0.3, 0, cc.winSize.height), cc.scaleTo(0.3, 0.7) ), cc.removeSelf(), ); this._touchNode.runAction(seq); } this._count++; this.txtCount.string = `${this._count * 100}`; }, onClick(){ this.startGame(); }, spillMoney(){ let seq = cc.sequence( cc.delayTime(0.2), cc.callFunc( () => { let x = Math.random() * cc.winSize.width; x -= cc.winSize.width / 2; let node = cc.instantiate(this.nodeSpillMoney); node.active = true; node.parent = this.nodeSpillMoney.parent; node.runAction(cc.sequence( cc.place(x, cc.winSize.height / 2 + node.height / 2), cc.spawn(cc.moveBy(1, 0, -cc.winSize.height - node.height / 2), cc.rotateBy(1, 1080)), cc.removeSelf(), )); }), ); seq.setTag(0xff); this.node.runAction(seq.repeatForever()); }, });

    0
    359
    286KB
    2019-12-13
    13
  • Creator口红机实现lipstick_3.zip

    Creator口红机实现lipstick_3.zip // Learn cc.Class: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html var DataMgr = require('DataMgr'); var LayerMgr = require('LayerMgr'); cc.Class({ extends: cc.Component, properties: { nodePlate: cc.Node, // 板子 nodeTouch: cc.Node, // 触摸节点 nodeLipstick: cc.Node, // 口红位置 prefabLipstick: cc.Prefab, // 口红预制 nodeLipstickContainer: cc.Node, // 总共有多少口红容器 }, // LIFE-CYCLE CALLBACKS: onLoad () { let mgr = cc.director.getCollisionManager(); mgr.enabled = true; // mgr.enabledDebugDraw = true; // mgr.enabledDrawBoundingBox = true; }, start () { this.nodeTouch.getComponent('Touch').setCallback( () => { this.onTouchCallback(); }); this.reloadUI(); this.startRun(); }, // update (dt) {}, startRun(){ // 顺时针转一圈,再逆时针转一圈,如此反复 this.nodePlate.stopAllActions(); this.nodePlate.rotation = 0; let seq = cc.sequence( cc.rotateBy(4, 360).easing(cc.easeIn(1.5)), cc.rotateBy(4, -360).easing(cc.easeIn(1.5)), ); this.nodePlate.runAction(seq.repeatForever()); }, /** * @description: 点击屏幕回调 * @param {type} * @return: */ onTouchCallback(){ // 口红用完了 if(DataMgr.leftLipstick <= 0){ return; } if(this.nodeLipstick.active){ let node = cc.instantiate(this.prefabLipstick); node.x = this.nodeLipstick.x; node.y = this.nodeLipstick.y; node.parent = this.nodeLipstick.parent; node.runAction(cc.moveTo(0.5, 0, this.nodePlate.y)); node.getComponent('Lipstick').setCallback({ success: () => { this.onSuccessCallback(); }, fail: () => { this.onFailCallback(); } }); DataMgr.leftLipstick--; let js = this.nodeLipstickContainer.getComponent('LipstickContainer'); js.reload(DataMgr.leftLipstick, DataMgr.levelInfo[DataMgr.currentLevel - 1].totalLipstick); if(DataMgr.leftLipstick <= 0){ this.nodeLipstick.active = false; } else{ this.nodeLipstick.runAction(cc.sequence( cc.hide(), cc.delayTime(0.2), cc.show(), )); } } }, /** * @description: 重新加载UI * @param {type} * @return: */ reloadUI(){ // 关卡信息 let levelInfo = DataMgr.levelInfo[DataMgr.currentLevel - 1]; // 游戏开始提示 LayerMgr.showLevelStart(levelInfo.level); // 口红数量 let js = this.nodeLipstickContainer.getComponent('LipstickContainer'); js.reload(levelInfo.totalLipstick, levelInfo.totalLipstick); // 数据清理 DataMgr.leftLipstick = levelInfo.totalLipstick; DataMgr.hitLipstick = 0; // 转盘 this.nodePlate.getComponent('Plate').removeAllLipstick(); this.nodeLipstick.active = (levelInfo.totalLipstick > 0); }, /** * @description: 单个口红命中目标 * @param {type} * @return: */ onSuccessCallback(){ DataMgr.hitLipstick++; if(DataMgr.hitLipstick == DataMgr.levelInfo[DataMgr.currentLevel - 1].totalLipstick){ // 通关 if(DataMgr.currentLevel == DataMgr.levelInfo[DataMgr.levelInfo.length - 1].level){ LayerMgr.showReward(1); DataMgr.reset(); } // 闯关 else{ DataMgr.currentLevel++; this.node.runAction(cc.sequence( cc.callFunc( () => { LayerMgr.showLevelEnd(true); }), cc.delayTime(1), cc.callFunc( () => { this.reloadUI(); }), )); } } // 未全部命中 else{ } }, /** * @description: 单个口红未命中目标 * @param {type} * @return: */ onFailCallback(){ LayerMgr.showLevelEnd(false); DataMgr.reset(); }, });

    0
    308
    368KB
    2019-12-13
    16
  • 笔耕不辍

    累计1年每年原创文章数量>=20篇
  • 签到新秀

    累计签到获取,不积跬步,无以至千里,继续坚持!
  • 持续创作

    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
  • 学习力

    《原力计划【第二季】》第一期主题勋章 ,第一期活动已经结束啦,小伙伴们可以去参加第二期打卡挑战活动获取更多勋章哦。
  • 1024勋章

    #1024程序员节#活动勋章,当日发布原创博客即可获得
  • 创作能手

    授予每个自然周发布9篇以上(包括9篇)原创IT博文的用户
关注 私信
上传资源赚积分or赚钱