首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

CocosCreator搓牌特效,可上下左右搓牌

前端 1.14MB 8 需要积分: 1
立即下载

资源介绍:

基于CocosCreator2.4.10(CocosCreator 2.x版本可用)
cc.Class({ name: 'cc.PeekCard', extends: cc.Component, properties: { pokerBottom: cc.Node, pokerMask: cc.Mask, bgMask: cc.Mask, bgNode: cc.Node, bgShadow: cc.Sprite, // 阴影 pokerShadow: cc.Sprite, pokerAtlas: cc.SpriteAtlas, spriteFrameList: [cc.SpriteFrame], // 遮罩 shadowSpriteFrameList: [cc.SpriteFrame], // 横竖阴影 _poker: null, //当前卡牌节点 _direction: 0, //card滑动的方向,0表示不滑动,1表示上滑,-1表示下滑, 2表示右滑,-2表示左滑。 _sensitive: 10, //灵敏度的阀值,默认为10 _canFanPai: false, // 是否达到翻牌的要求 _isTouch: true, // 是否开启触摸 _isRollback: false, // 是否回滚到了初始状态 _isDone: false, // 翻拍动作是否完成 _startPos: null, _offPos: 0 }, init: function(pukeId) { for (var i = 0; i < this.pokerMask.node.childrenCount; i++) { var node = this.pokerMask.node.children[i]; node.active = false; if (i > 0) { this.pokerMask.node.removeChild(node); } } if (this.poker) { this.poker.active = false; } this.bgNode.active = true; this._canFanPai = false; this._isDone = false; this._isTouch = true; this.pokerBottom.getChildByName('poker').getComponent(cc.Sprite).spriteFrame = this.pokerAtlas.getSpriteFrame(pukeId); var w = this.pokerBottom.width var h = this.pokerBottom.height this.nodeW = w; this.nodeH = h; this.pokerBottom.setPosition(0, h); this.pokerBottom.id = 'bottom'; var parent = this.pokerBottom.parent; this.pokerLeft = cc.instantiate(this.pokerBottom); this.pokerLeft.parent = parent; this.pokerLeft.setPosition(-w, 0); this.pokerLeft.id = 'left'; this.pokerRight = cc.instantiate(this.pokerBottom); this.pokerRight.parent = parent; this.pokerRight.getChildByName('poker').angle = -90; this.pokerRight.setPosition(w, 0); this.pokerRight.id = 'right'; this.pokerTop = cc.instantiate(this.pokerBottom); this.pokerTop.parent = parent; this.pokerTop.getChildByName('poker').angle = -90; this.pokerTop.setPosition(0, -h); this.pokerTop.id = 'top'; }, // use this for initialization onLoad: function () { this.node.on(cc.Node.EventType.TOUCH_START, this.onStart, this) this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onMove, this) this.node.on(cc.Node.EventType.TOUCH_END, this.onEnd, this) this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onCancel, this) }, onStart: function (event) { this._isRollback = false this._direction = 0;//把方向状态改为0 this._startPos = event.touch.getLocation() }, hideOthers(id) { for (var i = 0; i < this.pokerMask.node.childrenCount; i++) { var node = this.pokerMask.node.children[i]; if (node.id == id) continue; node.active = false; } }, onMove: function (event) { if (this._isTouch == false) return // 是否禁用触摸 this._isRollback = false var pos = event.touch.getLocation() var y = pos.y - this._startPos.y var x = pos.x - this._startPos.x if (this._direction == 0) { if (pos.y - this._startPos.y > this._sensitive) { //上滑 this._direction = 1; this.hideOthers('bottom'); this.poker = this.pokerBottom; this.poker.setPosition(0, -this.nodeH); } else if (pos.y - this._startPos.y < -this._sensitive) { //下滑 this._direction = -1; this.hideOthers('top'); this.poker = this.pokerTop; this.poker.setPosition(0, this.nodeH); } else if (pos.x - this._startPos.x > this._sensitive) { //右滑 this._direction = 2; this.hideOthers('left'); this.poker = this.pokerLeft; this.poker.setPosition(-this.nodeW, 0); } else if (pos.x - this._startPos.x < -this._sensitive) { //左滑 this._direction = -2; this.hideOthers('right'); this.poker = this.pokerRight; this.poker.setPosition(this.nodeW, 0); } else { this.poker = null; } } if (!this.poker) return; var mask = (Math.abs(this._direction) == 1) ? this.pokerMask.node.getPosition().y : this.pokerMask.node.getPosition().x var limit = (Math.abs(this._direction) == 1) ? 450 : 600 if (Math.abs(mask) > limit) { this._canFanPai = true this.openAnimation() // 达到指定位置,开牌 return } else this._canFanPai = false if (Math.abs(this._direction) == 1) { this.updatePosition(y) } else { this.updatePosition(x) } this._startPos = pos this.poker.active = true; }, onEnd: function (evt) { if (this._canFanPai == false) { // 结束触摸事件时,如果没触发翻牌事件,则回滚到初始状态 this._isRollback = (this.pokerMask.node.getPosition().y != 0 || this.pokerMask.node.getPosition().x != 0) // 开启回滚定时器 } }, onCancel: function (evt) { if (this._canFanPai == false) { // 结束触摸事件时,如果没触发翻牌事件,则回滚到初始状态 this._isRollback = true // 开启回滚定时器 } }, updatePosition: function (val) { if (!this.poker) return; this._offPos += val this._offPos = this._offPos < 0 ? 0 : this._offPos var mask = Math.abs(this._direction) == 1 ? this.pokerMask.node.getPosition().y : this.pokerMask.node.getPosition().x var ratio = this.getScaleRatio(mask) // 缩放比例 var opacity = this.getOpacity(mask) this.bgShadow.node.opacity = opacity this.pokerShadow.node.opacity = opacity if (Math.abs(mask) > 30) { if (Math.abs(this._direction) == 1) { this.pokerMask.spriteFrame = this.spriteFrameList[0] this.bgMask.spriteFrame = this.spriteFrameList[0] } else { this.pokerMask.spriteFrame = this.spriteFrameList[2] this.bgMask.spriteFrame = this.spriteFrameList[2] } } else { this.pokerMask.spriteFrame = this.spriteFrameList[1] this.bgMask.spriteFrame = this.spriteFrameList[1] } if (Math.abs(this._direction) == 1) { this.pokerMask.node.setScale(ratio, 1) this.pokerShadow.node.setScale(ratio, 1) if (this._direction > 0 ? this.pokerMask.node.getPosition().y < 0 : this.pokerMask.node.getPosition().y > 0) { this.pokerMask.node.y = 0 this._isRollback = false if (this._isRollback) { this.poker.active = false; } } else { this.pokerMask.node.y += val } if (this._direction > 0 && this.poker.getPosition().y < -this.nodeH) { this.poker.y = -this.nodeH } else if (this._direction < 0 && this.poker.getPosition().y > this.nodeH) { this.poker.y = this.nodeH } else { this.poker.y += val } if (this._direction > 0 ? this.bgMask.node.getPosition().y < 0 : this.bgMask.node.getPosition().y > 0) { this.bgMask.node.y = 0 } else { this.bgMask.node.y += val } if (this._direction > 0 ? this.bgNode.getPosition().y > 0 : this.bgNode.getPosition().y < 0) { this.bgNode.y = 0 } else { this.bgNode.y -= val } if (this._direction > 0 ? this.bgShadow.node.getPosition().y < 0 : this.bgShadow.node.getPosition().y > 0) { this.bgShadow.node.y = 0 } else { this.bgShadow.node.y += val * 1.6 } if (this._direction > 0 ? this.pokerShadow.node.getPosition().y < 0 : this.pokerShadow.node.getPosition().y > 0) { this.pokerShadow.node.y = 0 } else { this.pokerShadow.node.y += val } } else { this.pokerMask.node.setScale(1, ratio) this.pok

资源文件列表:

PeekCard.zip 大约有70个文件
  1. PeekCard/
  2. __MACOSX/._PeekCard 177B
  3. PeekCard/.DS_Store 6KB
  4. __MACOSX/PeekCard/._.DS_Store 120B
  5. PeekCard/project.json 146B
  6. __MACOSX/PeekCard/._project.json 177B
  7. PeekCard/assets/
  8. __MACOSX/PeekCard/._assets 177B
  9. PeekCard/.idea/
  10. __MACOSX/PeekCard/._.idea 177B
  11. PeekCard/assets/.DS_Store 6KB
  12. __MACOSX/PeekCard/assets/._.DS_Store 120B
  13. PeekCard/assets/prefabs/
  14. __MACOSX/PeekCard/assets/._prefabs 177B
  15. PeekCard/assets/resources/
  16. __MACOSX/PeekCard/assets/._resources 177B
  17. PeekCard/assets/scripts.meta 274B
  18. __MACOSX/PeekCard/assets/._scripts.meta 177B
  19. PeekCard/assets/prefabs.meta 274B
  20. __MACOSX/PeekCard/assets/._prefabs.meta 177B
  21. PeekCard/assets/resources.meta 282B
  22. __MACOSX/PeekCard/assets/._resources.meta 177B
  23. PeekCard/assets/scene.meta 274B
  24. __MACOSX/PeekCard/assets/._scene.meta 177B
  25. PeekCard/assets/migration.meta 274B
  26. PeekCard/assets/scripts/
  27. __MACOSX/PeekCard/assets/._scripts 177B
  28. PeekCard/assets/scene/
  29. __MACOSX/PeekCard/assets/._scene 177B
  30. PeekCard/assets/migration/
  31. PeekCard/.idea/inspectionProfiles/
  32. __MACOSX/PeekCard/.idea/._inspectionProfiles 177B
  33. PeekCard/.idea/codeStyles/
  34. __MACOSX/PeekCard/.idea/._codeStyles 177B
  35. PeekCard/.idea/client.iml 469B
  36. __MACOSX/PeekCard/.idea/._client.iml 177B
  37. PeekCard/.idea/workspace.xml 18.27KB
  38. __MACOSX/PeekCard/.idea/._workspace.xml 177B
  39. PeekCard/.idea/modules.xml 271B
  40. __MACOSX/PeekCard/.idea/._modules.xml 177B
  41. PeekCard/assets/prefabs/peekcard.prefab.meta 193B
  42. PeekCard/assets/prefabs/peekcard.prefab 17.79KB
  43. PeekCard/assets/resources/.DS_Store 6KB
  44. __MACOSX/PeekCard/assets/resources/._.DS_Store 120B
  45. PeekCard/assets/resources/pokers.png 1.42MB
  46. PeekCard/assets/resources/pokers.plist 27.81KB
  47. __MACOSX/PeekCard/assets/resources/._pokers.plist 176B
  48. PeekCard/assets/resources/pokers.plist.meta 35.33KB
  49. PeekCard/assets/resources/pokers.png.meta 874B
  50. PeekCard/assets/scripts/PeekCard.js.meta 225B
  51. __MACOSX/PeekCard/assets/scripts/._PeekCard.js.meta 177B
  52. PeekCard/assets/scripts/PeekCard.js 11.4KB
  53. __MACOSX/PeekCard/assets/scripts/._PeekCard.js 233B
  54. PeekCard/assets/scripts/.bzrignore 149B
  55. __MACOSX/PeekCard/assets/scripts/._.bzrignore 177B
  56. PeekCard/assets/scripts/Main.js 1.35KB
  57. __MACOSX/PeekCard/assets/scripts/._Main.js 176B
  58. PeekCard/assets/scripts/Main.js.meta 225B
  59. PeekCard/assets/scene/mainScene.fire.meta 169B
  60. __MACOSX/PeekCard/assets/scene/._mainScene.fire.meta 177B
  61. PeekCard/assets/scene/mainScene.fire 31.82KB
  62. __MACOSX/PeekCard/assets/scene/._mainScene.fire 177B
  63. PeekCard/assets/migration/use_v2.0.x_cc.Toggle_event.js.meta 225B
  64. PeekCard/assets/migration/use_v2.0.x_cc.Toggle_event.js 971B
  65. PeekCard/.idea/inspectionProfiles/Project_Default.xml 253B
  66. __MACOSX/PeekCard/.idea/inspectionProfiles/._Project_Default.xml 177B
  67. PeekCard/.idea/codeStyles/Project.xml 1.58KB
  68. __MACOSX/PeekCard/.idea/codeStyles/._Project.xml 177B
  69. PeekCard/.idea/codeStyles/codeStyleConfig.xml 146B
  70. __MACOSX/PeekCard/.idea/codeStyles/._codeStyleConfig.xml 177B
0评论
提交 加载更多评论
其他资源 Cornerstone v2.7.10
Cornerstone v2.7.10。Mac版本
Cornerstone v2.7.10 Cornerstone v2.7.10 Cornerstone v2.7.10
Camunda7.17.0的jar下载
Camunda7.17.0的jar下载
chromedriver最新版
chromedriver最新版
冰蝎2.0源码编译可运行
自用
protoc-3.5.0-win32.zip
protoc-3.5.0-win32.zipprotoc-3.5.0-win32.zipprotoc-3.5.0-win32.zipprotoc-3.5.0-win32.zipprotoc-3.5.0-win32.zip
OmniShade Pro - Mobile Optimized Shader v1.7.4
功能齐全的风格化着色器,针对移动设备进行了优化。 包含所有最新技术,但由于只计算所需内容的渐进式系统,速度非常快。
将keil的daplink的下载速度突破20M,最高可以将daplink设置到60M,解锁DAPlink全部的性能
将keil的daplink的下载速度突破20M,最高可以将daplink设置到60M,解锁DAPlink全部的性能。
基于matlab的PID参数整定
可使用matlab直观修改PID参数值