├── .gitattributes ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── ROADMAP.MD ├── SVG Demo ├── GizmoTool.js ├── img.jpg ├── index.html └── svg.js ├── assets ├── Box2D.meta ├── Box2D │ ├── Scripts.meta │ └── Scripts │ │ ├── Base.meta │ │ ├── Base │ │ ├── Body.js │ │ ├── Body.js.meta │ │ ├── Engine.js │ │ ├── Engine.js.meta │ │ ├── Physics.js │ │ └── Physics.js.meta │ │ ├── CombinComponent.meta │ │ ├── CombinComponent │ │ ├── Bridge.js │ │ ├── Bridge.js.meta │ │ ├── TopDownCar.js │ │ ├── TopDownCar.js.meta │ │ ├── Wheel.js │ │ └── Wheel.js.meta │ │ ├── Contact.meta │ │ ├── Contact │ │ ├── Category.js │ │ ├── Category.js.meta │ │ ├── Contact.js │ │ └── Contact.js.meta │ │ ├── Effector.meta │ │ ├── Effector │ │ ├── AreaEffector.js │ │ ├── AreaEffector.js.meta │ │ ├── BouyancyEffctor.js │ │ ├── BouyancyEffctor.js.meta │ │ ├── ConstantForce.js │ │ ├── ConstantForce.js.meta │ │ ├── PlatformEffctor.js │ │ ├── PlatformEffctor.js.meta │ │ ├── PointEffector.js │ │ ├── PointEffector.js.meta │ │ ├── SurfaceEffctor.js │ │ └── SurfaceEffctor.js.meta │ │ ├── Joint.meta │ │ ├── Joint │ │ ├── DistanceJoint.js │ │ ├── DistanceJoint.js.meta │ │ ├── FrictionJoint.js │ │ ├── FrictionJoint.js.meta │ │ ├── GearJoint.js │ │ ├── GearJoint.js.meta │ │ ├── Joint.js │ │ ├── Joint.js.meta │ │ ├── LineJoint.js │ │ ├── LineJoint.js.meta │ │ ├── MouseJoint.js │ │ ├── MouseJoint.js.meta │ │ ├── PrismaticJoint.js │ │ ├── PrismaticJoint.js.meta │ │ ├── PulleyJoint.js │ │ ├── PulleyJoint.js.meta │ │ ├── RevoluteJoint.js │ │ ├── RevoluteJoint.js.meta │ │ ├── RopeJoint.js │ │ ├── RopeJoint.js.meta │ │ ├── WeldJoint.js │ │ └── WeldJoint.js.meta │ │ ├── Shape.meta │ │ ├── Shape │ │ ├── BoxShape.js │ │ ├── BoxShape.js.meta │ │ ├── CircleShape.js │ │ ├── CircleShape.js.meta │ │ ├── EdgeShape.js │ │ ├── EdgeShape.js.meta │ │ ├── PolygonShape.js │ │ ├── PolygonShape.js.meta │ │ ├── Shape.js │ │ └── Shape.js.meta │ │ ├── Utils.meta │ │ └── Utils │ │ ├── Expand.js │ │ └── Expand.js.meta ├── Demo.meta ├── Demo │ ├── DemoScene.fire │ ├── DemoScene.fire.meta │ ├── Destroy.js │ ├── Destroy.js.meta │ ├── NewScript.js │ ├── NewScript.js.meta │ ├── Texture.meta │ └── Texture │ │ ├── RedMonster.png │ │ ├── RedMonster.png.meta │ │ ├── button_empty.png │ │ ├── button_empty.png.meta │ │ ├── restart.png │ │ └── restart.png.meta ├── Test.js ├── Test.js.meta ├── test.fire └── test.fire.meta ├── node_modules └── box2dweb-commonjs │ ├── Box2dWeb-2.1.a.3.js │ ├── Box2dWeb-2.1.a.4.js │ ├── MIT-LICENSE │ ├── README.md │ └── package.json └── packages ├── Box2D ├── README.MD ├── gizmos │ ├── BoxShapeGizmo.js │ ├── CircleShapeGizmo.js │ ├── DistanceJoint.js │ ├── EdgeShapeGizmo.js │ ├── GizmoTool.js │ ├── PolygonShapeGizmo.js │ └── polygon-collider-gizmo.js ├── i18n │ ├── en.js │ └── zh.js ├── inspector │ └── circleShape.js ├── main.js ├── package.json ├── panel │ ├── Box2D.js │ └── panel.js └── res │ └── inspector │ └── circleShape.gif ├── ui-kit-preview-extra-master ├── README.md ├── main.js ├── package.json └── panel │ ├── asset-preview.js │ ├── asset-preview.tmpl │ ├── node-preview.js │ ├── node-preview.tmpl │ └── panel.js └── ui-kit-preview-master ├── .gitignore ├── README.md ├── main.js ├── package.json └── panel ├── box-container-preview.js ├── box-container-preview.tmpl ├── button-preview.js ├── button-preview.tmpl ├── checkbox-preview.js ├── checkbox-preview.tmpl ├── color-picker-preview.js ├── color-picker-preview.tmpl ├── color-preview.js ├── color-preview.tmpl ├── hint-preview.js ├── hint-preview.tmpl ├── icon-preview.js ├── icon-preview.tmpl ├── input-preview.js ├── input-preview.tmpl ├── layout-preview.js ├── layout-preview.tmpl ├── loader-preview.js ├── loader-preview.tmpl ├── markdown-preview.js ├── markdown-preview.tmpl ├── num-input-preview.js ├── num-input-preview.tmpl ├── panel.js ├── progress-preview.js ├── progress-preview.tmpl ├── prop-preview.js ├── prop-preview.tmpl ├── section-preview.js ├── section-preview.tmpl ├── select-preview.js ├── select-preview.tmpl ├── settings.js ├── settings.tmpl ├── shadow-preview.js ├── shadow-preview.tmpl ├── slider-preview.js ├── slider-preview.tmpl ├── text-area-preview.js └── text-area-preview.tmpl /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /library 2 | /local 3 | /temp 4 | /settings 5 | /build 6 | /creator.d.ts 7 | /project.json -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // 将设置放入此文件中以覆盖默认值和用户设置。 2 | { 3 | "files.exclude": { 4 | "**/.git": true, 5 | "**/.svn": true, 6 | "**/.hg": true, 7 | "**/.DS_Store": true, 8 | "**/*.meta": true, 9 | "library": true, 10 | "local": true, 11 | ".vscode": true, 12 | "setting": true, 13 | "temp": true, 14 | "project.json": true, 15 | "creator.d.ts": true, 16 | ".gitattributes": true 17 | } 18 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cocos Creator Box2D 物理引擎组件 2 | 3 | >Creator仿Unity3D物理引擎组件。 4 | 5 | ## 项目结构 6 | 7 | ``` 8 | assets 9 | |--Box2D (物理引擎组件) 10 | | |--Prefab (预设体) 11 | | |--Scripts(组件脚本) 12 | | | |--Base(核心脚本) 13 | | | |--Contact(碰撞器) 14 | | | |--Editor(编辑器相关) 15 | | | |--Effector(效应器) 16 | | | |--Joint(节点定义) 17 | | | |--Shape(形状定义) 18 | | | |--Utils(工具相关) 19 | | |--Texture(组件默认贴图) 20 | |--Demo(范例) 21 | | |--Texture(贴图资源) 22 | |--scripts(公共脚本) 23 | node_modules 24 | |--box2dweb-commonjs (Box2D核心脚本) 25 | packages 26 | |--Box2D (Box2D插件脚本) 27 | ``` 28 | 29 | ### 详细说明 Box2D 30 | 31 | - [Body](assets/cases/01_graphics/01_sprite) 32 | - [Shape](assets/cases/01_graphics/02_particle) 33 | - [BoxShape](assets/cases/01_graphics/02_particle/simple_particle.md) 34 | - [Joint](assets/cases/01_graphics/02_particle) 35 | - [MouseJoint](assets/cases/01_graphics/02_particle/simple_particle.md) 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ROADMAP.MD: -------------------------------------------------------------------------------- 1 | #项目排期(按优先级排序) 2 | 3 | * 尝试在属性面板以及Gizmo里使用Paper, 尝试在属性面板里使用Canvas,Webgl 4 | * 为Joint添加DebugDraw 5 | * 修改碰撞监听函数为Creator新版自带的EventHandle 6 | * `BUG`获取Shape时,现在可以获取多个Shape了,但EdgeShape还不能正常获得 7 | * 一个Node身上只能有一个Body组件,这样可以避免许多问题,U3D也是这样做的。(而且Body应该放在最上,U3D如果上层还有Collider,会出错,我们直接无视上层Shape) 8 | * 调整BoxShape的Gizmo为拖动顶点时,会根据当前长度动态改变当前位置(类似U3D的那种) 9 | * 模仿Uniyt3D的物理材质这一属性,可以将物理属性导出为资源,供多个刚体共同引用 10 | * (大更新)将直接从Shape处获取属性改为跟Node的Transform相关,这样就可以在Node Scale后,Shape仍然正确(像U3D,Go缩放后,Colliser也缩放,但Collider的Radius仍然没变) 11 | * 继上:缩放Node也会缩放Edeg跟Polygon的顶点以及Circle的半径等 12 | * `BUG`由于获取Shape只是获取它的offer,所以如果Shape在子物体身上又没offer,位置会不对 13 | * `优化`添加Shape时,模式大小应该跟Node对应上,如果默认Node size为0,则赋予Shape大小默认值 14 | * 添加贝塞尔多曲线编辑Edge 15 | * 将Distance Joint 跟 Spring Joint 改为 弹簧 与 绳子 节点 16 | * 添加刚体可以锁定X/Y轴的功能 17 | * 添加Shaper的Gizmo着色处理,静态动态物体的颜色不同。 18 | * 优化Engine只能放在场景层级最顶端,否则会出现Body先加载,导致找不到Engine的缺陷 19 | * 实现Spring Joint,以及优化各种Joint的接口 20 | * 将Effector里的Area,Constant,Point,Surface修复下 21 | * 将合并组件里的Wheel实现 22 | * 初次添加Engine组件时,Engine的Category从JSON配置文件里读取并初始化,而不是一个空的数组 23 | * Body的Category Target Mask实现 24 | * 为所有组件添加必要API 25 | * 为所有可用组件添加编辑器菜单,并完善i18n文件 26 | * 编写初步文档以及API 27 | * 编写Demo 28 | ------------- 29 | >发布0.9beta 30 | 31 | * 实现Engine的instance功能,场景中只能有一个Engine 32 | * 实现Bouyancy,Platform 33 | * 实现组合组件里的TopDwonCar 34 | * 为PackagePanel添加检测升级按钮,实现在菜单中检测插件版本,并升级到最新版 35 | * 完善文档以及API 36 | * 完善Demo 37 | ------------- 38 | >发布1.0 39 | 40 | * 同上,待属性面板支持修改后,将Engine的Category的运行方式由notify(每输入一次字符都会通知一次很饭)修改为按按钮发送修改事件。 41 | * 添加凹多边形支持 42 | * 添加根据图片纹理自动生成多边形顶点 43 | ------------- 44 | ``` javascript 45 | Node.prototype.getWorldOrientedBounds = function (size, out_bl, out_tl, out_tr, out_br) { 46 | size = size || this.getContentSize(); 47 | var width = size.width; 48 | var height = size.height; 49 | 50 | out_bl = out_bl || new cc.Vec2(); 51 | out_tl = out_tl || new cc.Vec2(); 52 | out_tr = out_tr || new cc.Vec2(); 53 | out_br = out_br || new cc.Vec2(); 54 | 55 | var rect = new cc.Rect(0, 0, width, height); 56 | var mat = this.getNodeToWorldTransform(); 57 | cc.engine.obbApplyAffineTransform(mat, rect, out_bl, out_tl, out_tr, out_br); 58 | 59 | return [out_bl, out_tl, out_tr, out_br]; 60 | }; 61 | ``` -------------------------------------------------------------------------------- /SVG Demo/GizmoTool.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | class Shape { 4 | 5 | constructor(parent) { 6 | this.parent = parent; 7 | this.children = new Array(); 8 | this.isRoot = false; 9 | this._position = [0, 0]; 10 | this._angle = 0; 11 | this._scale = 1; 12 | this._visible = true; 13 | 14 | if (parent.root !== undefined) { 15 | this.root = parent.root.group(); 16 | parent.children.push(this); 17 | } 18 | else { 19 | this.isRoot = true; 20 | this.root = parent.group(); 21 | } 22 | } 23 | 24 | position(x, y) { 25 | this._position = [x, y]; 26 | this.root.move(x, y); 27 | return this; 28 | } 29 | 30 | rotate(angle) { 31 | this._angle = angle; 32 | this.root.rotate(angle); 33 | return this; 34 | } 35 | 36 | scale(s) { 37 | this._scale = s; 38 | this.root.scale(s); 39 | return this; 40 | } 41 | 42 | color(lineColor, fillColor) { 43 | this.shape.stroke(lineColor === null ? 'none' : { color: lineColor }); 44 | this.shape.fill(fillColor === null ? 'none' : { color: fillColor }); 45 | return this; 46 | } 47 | 48 | lineStytle(lineWidth) { 49 | this.shape.attr({ 50 | 'stroke-width': lineWidth, 51 | }); 52 | return this; 53 | } 54 | 55 | cursorStytle(cursorType, pointerArea) { 56 | this.shape.attr({ 57 | 'cursor': cursorType, 58 | 'pointer-events': pointerArea, 59 | }); 60 | return this; 61 | } 62 | 63 | visible(v) { 64 | this._visible = v; 65 | if (v) 66 | this.shape.show(); 67 | else 68 | this.shape.hide(); 69 | return this; 70 | } 71 | 72 | _resize(anchor) { 73 | if (!this.isRoot) 74 | this.shape.center(this.parent.shape.cx(), this.parent.shape.cy()); 75 | else 76 | this.shape.center(0, 0); 77 | 78 | this.children.forEach(function (child) { 79 | child.shape.center(child.parent.shape.cx(), child.parent.shape.cy()); 80 | }, this); 81 | } 82 | 83 | onClick(callback) { 84 | this.shape.on('click', callback.bind(this)); 85 | return this; 86 | } 87 | 88 | onMousedown(callback) { 89 | this.shape.on('mousedown', callback.bind(this)); 90 | return this; 91 | } 92 | 93 | onMouseup(callback) { 94 | this.shape.on('mouseup', callback.bind(this)); 95 | return this; 96 | } 97 | 98 | onMousemove(callback) { 99 | this.shape.on('mousemove', callback.bind(this)); 100 | return this; 101 | } 102 | 103 | onMouseover(callback) { 104 | this.shape.on('mouseover', callback.bind(this)); 105 | return this; 106 | } 107 | 108 | onMouseout(callback) { 109 | this.shape.on('mouseout', callback.bind(this)); 110 | return this; 111 | } 112 | } 113 | 114 | class Circle extends Shape { 115 | 116 | constructor(parent) { 117 | super(parent); 118 | 119 | this._radius = 100; 120 | this.shape = this.root.circle(this._radius); 121 | } 122 | 123 | radius(radius) { 124 | this._radius = radius; 125 | this.shape.radius(radius); 126 | this._resize(); 127 | return this; 128 | } 129 | } 130 | 131 | class Rect extends Shape { 132 | 133 | constructor(parent) { 134 | super(parent); 135 | 136 | this._size = [100, 100]; 137 | this.shape = this.root.rect(this._size[0], this._size[1]); 138 | } 139 | 140 | size(w, h) { 141 | this._size = [w, h]; 142 | this.shape.width(w); 143 | this.shape.height(h); 144 | this._resize(); 145 | return this; 146 | } 147 | } 148 | 149 | class Polygon extends Shape { 150 | 151 | constructor(parent, close) { 152 | super(parent); 153 | 154 | this._vertexes = '0,0 -50,50 50,50'; 155 | this.shape = close ? this.root.polygon(this._vertexes) : this.root.polyline(this._vertexes).fill('none').stroke({ width: 1 }); 156 | } 157 | 158 | // 多边形的中心点为了方便起见,就设置为第一个点的位置 159 | _resize(anchor) { 160 | //if (!this.isRoot) 161 | // this.shape.center(this.parent.shape.cx(), this.parent.shape.cy()); 162 | //else 163 | // this.shape.center(0, 0); 164 | 165 | this.children.forEach(function (child) { 166 | child.shape.center(child.parent.shape.cx(), child.parent.shape.cy()); 167 | }, this); 168 | } 169 | 170 | vertexes(vs) { 171 | let _v = ''; 172 | vs.forEach(function (v) { 173 | _v += v.x + ',' + v.y + ' '; 174 | }, this); 175 | this._vertexes = _v; 176 | this.shape.plot(_v); 177 | this._resize(); 178 | return this; 179 | } 180 | } 181 | 182 | class Path extends Shape { 183 | 184 | constructor(parent) { 185 | super(parent); 186 | 187 | this._path = 'M100,200L300,400'; 188 | this.shape = this.root.path(this._path); 189 | } 190 | 191 | path(v) { 192 | this._path = v; 193 | this.shape.plot(v); 194 | this._resize(); 195 | return this; 196 | } 197 | } 198 | 199 | class Line extends Shape { 200 | 201 | constructor(parent) { 202 | super(parent); 203 | 204 | this._start = [0, 0]; 205 | this._end = [100, 100], 206 | this.shape = this.root.line(0, 0, 100, 100); 207 | } 208 | 209 | // 跟多边形一样,线段的中心点就是第一个点的位置,而不去矫正 210 | _resize(anchor) { 211 | //if (!this.isRoot) 212 | // this.shape.center(this.parent.shape.cx(), this.parent.shape.cy()); 213 | //else 214 | // this.shape.center(0, 0); 215 | 216 | this.children.forEach(function (child) { 217 | child.shape.center(child.parent.shape.cx(), child.parent.shape.cy()); 218 | }, this); 219 | } 220 | 221 | line(start, end) { 222 | this._start = start; 223 | this._end = end; 224 | this.shape.plot(start.x, start.y, end.x, end.y); 225 | this._resize(); 226 | return this; 227 | } 228 | 229 | } -------------------------------------------------------------------------------- /SVG Demo/img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeason1997/EasyBox2D/14765757cb001b14e130042070b6a37fedb84542/SVG Demo/img.jpg -------------------------------------------------------------------------------- /SVG Demo/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 |
7 | 8 | -------------------------------------------------------------------------------- /SVG Demo/svg.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var draw = SVG('drawing') 4 | 5 | var group = draw.group() 6 | 7 | //var rect = group.rect(200, 200).attr({ fill: '#f06' }); 8 | 9 | //var link = group.link('http://svgjs.com') 10 | //link.show('replace') 11 | //var rect = link.rect(100, 100) 12 | 13 | //var polyline = group.polyline([[0,0], [100,50], [50,100]]).fill('none').stroke({ width: 1 }) 14 | //polyline.animate(3000).plot([[0,0], [100,50], [50,100], [150,50], [200,50], [250,100], [300,50], [350,50]]) 15 | //polyline.move(200, 200) 16 | 17 | //var polygon = draw.polygon('0,0 100,50 50,100').fill('none').stroke({ width: 1 }) 18 | //polygon.move(300, 0) 19 | 20 | //var path = draw.path() 21 | //path.plot('M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100') 22 | 23 | //draw.rect(100,100).animate(3000).fill('#f03').move(100,100) 24 | //var rect = draw.rect(100, 100) 25 | var rect = new Rect(group) 26 | .color(null, 'rgba(200, 100, 100, 1)') 27 | .position(100, 100); 28 | 29 | var child = new Rect(rect) 30 | .color(null, 'rgba(100, 100, 100, 0.5)') 31 | .position(50, 50) 32 | .size(40, 80); 33 | 34 | 35 | 36 | //var cir1 = new Circle(group).color('rgba(0,128,255,1)', 'rgba(0,128,255,0.2)').stytle(5, 'stroke', 'move') -------------------------------------------------------------------------------- /assets/Box2D.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "1c0b7c3d-85b1-4361-91a5-b42ddcf61af6", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "6af45f09-fe68-4916-8e7a-d2f2f82a61c8", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Base.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "92647be2-1f78-4a29-b2ed-bba384c7e687", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Base/Body.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "159bdf75-29dc-45c5-8cb4-335b5d2f2b58", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Base/Engine.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "da2291bd-2206-4f32-9bb7-99070882a727", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Base/Physics.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/3/10 4 | * Author : Jeason1997 5 | * FileName : Physics.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | /**************** Global ********************/ 10 | 11 | // Editor Mode 12 | window.CC_EDITOR = (cc.engine !== undefined); 13 | 14 | // PTM_RATIO Defined 15 | window.PTM_RATIO = 32; 16 | 17 | // Physics Defined 18 | window.Physics = { 19 | 20 | }; 21 | 22 | /********************************************/ 23 | 24 | 25 | 26 | 27 | 28 | /**************** Box2D ********************/ 29 | 30 | // Box2D Defined 31 | var Box2D = require('box2dweb-commonjs'); 32 | window.b2AABB = Box2D.b2AABB; 33 | window.b2World = Box2D.b2World; 34 | window.b2AABB = Box2D.b2AABB; 35 | window.b2Body = Box2D.b2Body; 36 | window.b2BodyDef = Box2D.b2BodyDef; 37 | window.b2CircleShape = Box2D.b2CircleShape; 38 | window.b2Fixture = Box2D.b2Fixture; 39 | window.b2FixtureDef = Box2D.b2FixtureDef; 40 | window.b2Vec2 = Box2D.b2Vec2; 41 | window.b2DebugDraw = Box2D.b2DebugDraw; 42 | window.b2MassData = Box2D.b2MassData; 43 | window.b2PolygonShape = Box2D.b2PolygonShape; 44 | window.b2PrismaticJointDef = Box2D.b2PrismaticJointDef; 45 | window.b2RevoluteJointDef = Box2D.b2RevoluteJointDef; 46 | window.b2DistanceJointDef = Box2D.b2DistanceJointDef; 47 | window.b2Transform = Box2D.b2Transform; 48 | window.b2ContactListener = Box2D.b2ContactListener; 49 | window.b2MouseJointDef = Box2D.b2MouseJointDef; 50 | window.b2FilterData = Box2D.b2FilterData; 51 | window.b2EdgeShape = Box2D.b2EdgeShape; 52 | window.b2LineJointDef = Box2D.b2LineJointDef; 53 | window.b2WeldJointDef = Box2D.b2WeldJointDef; 54 | window.b2GearJointDef = Box2D.b2GearJointDef; 55 | window.b2PrismaticJointDef = Box2D.b2PrismaticJointDef; 56 | window.b2FrictionJointDef = Box2D.b2FrictionJointDef; 57 | window.b2PulleyJointDef = Box2D.b2PulleyJointDef; 58 | //window.b2RopeJointDef = Box2D.b2RopeJointDef; 59 | 60 | /********************************************/ 61 | 62 | 63 | 64 | 65 | 66 | /**************** Physics *******************/ 67 | 68 | ////////////////// Enum ////////////////////// 69 | require('Category'); 70 | 71 | 72 | ////////////////// Class ///////////////////// 73 | window.Physics.Ray = cc.Class({ 74 | 75 | // constructor1: start, end 76 | // constructor2: start, direction, distant 77 | ctor: function () { 78 | // constructor1 79 | if (arguments[2] === undefined) { 80 | this.start = arguments[0]; 81 | this.end = arguments[1]; 82 | 83 | //this.direction = ; 84 | //this.distance = ; 85 | } 86 | // constructor2 87 | else { 88 | this.start = arguments[0]; 89 | this.direction = arguments[1]; 90 | this.distant = arguments[2]; 91 | 92 | //this.end = ; 93 | } 94 | }, 95 | 96 | properties: { 97 | start: b2Vec2(0, 0), 98 | end: b2Vec2(0, 0), 99 | direction: b2Vec2(0, 0), 100 | distant: 0, 101 | }, 102 | }); 103 | 104 | 105 | //////////////// Function //////////////////// 106 | window.Physics.RayCast = function(point1, point2, callback) { 107 | var p1 = new b2Vec2(point1.x / PTM_RATIO, point1.y / PTM_RATIO); 108 | var p2 = new b2Vec2(point2.x / PTM_RATIO, point2.y / PTM_RATIO); 109 | Engine.instance.world.RayCast(callback, p1, p2); 110 | 111 | // Debugdraw 112 | if (Engine.instance.physicsDebugger.openDebug && Engine.instance.physicsDebugger.drawRay) { 113 | Engine.instance.physicsDebugger.getDebugDraw().GetSprite().drawSegment(point1, point2); 114 | } 115 | }; 116 | 117 | /********************************************/ -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Base/Physics.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "579bccb9-f5ea-449d-9d86-f5c96fd6baf0", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/CombinComponent.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "11e284fd-3f72-4809-9dcb-4f2797f98d80", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/CombinComponent/Bridge.js: -------------------------------------------------------------------------------- 1 | cc.Class({ 2 | extends: cc.Component, 3 | 4 | properties: { 5 | texture: { 6 | default: null, 7 | }, 8 | endXPosition: { 9 | default: 500, 10 | notify: function () { 11 | this.createBridge(); 12 | }, 13 | }, 14 | block: { 15 | default: new cc.Vec2(50, 20), 16 | notify: function () { 17 | this.createBridge(); 18 | }, 19 | }, 20 | interval: { 21 | default: 0, 22 | notify: function () { 23 | this.createBridge(); 24 | }, 25 | }, 26 | allowBlockCollsion: { 27 | default: false, 28 | }, 29 | friction: { 30 | default: 0.3, 31 | }, 32 | elastic: { 33 | default: 15, 34 | }, 35 | breakForce: { 36 | default: -1, 37 | }, 38 | }, 39 | 40 | // use this for initialization 41 | createBridge: function () { 42 | var blockCount = this.endXPosition / (this.block.x + this.interval); 43 | 44 | this.node.removeAllChildren(); 45 | for (var i = 0; i < blockCount; ++i) { 46 | var block = new cc.Node(); 47 | block.name = 'Block_' + i; 48 | block.width = this.block.x; 49 | block.height = this.block.y; 50 | block.x = this.endXPosition / blockCount * i + this.block.x / 2; 51 | block.parent = this.node; 52 | 53 | var shape = block.addComponent(Box2D_BoxShape); 54 | 55 | var body = block.addComponent(Box2D_Body); 56 | 57 | var joint = block.addComponent(RevoluteJoint); 58 | // 第一个Body的节点连接GroundBody 59 | if (i > 0) 60 | { 61 | joint.targetBody = this.node.children[i - 1].getComponent(Box2D_Body); 62 | joint.enableLimit = true; 63 | joint.lowerAngle = -this.elastic; 64 | joint.upperAngle = this.elastic; 65 | joint.autoConfigureTargetdAnchor = false; 66 | joint.localAnchor = new cc.Vec2(-(this.block.x + this.interval) / 2, 0); 67 | joint.targetAnchor = new cc.Vec2((this.block.x + this.interval) / 2, 0) 68 | joint.enableCollison = this.allowBlockCollsion; 69 | joint.breakForce = this.breakForce; 70 | } 71 | // 最后一个Body加多一个节点来连接GroundBody 72 | if (i >= blockCount - 1) { 73 | block.addComponent(RevoluteJoint); 74 | } 75 | 76 | } 77 | 78 | }, 79 | }); 80 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/CombinComponent/Bridge.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "0c99f624-52a2-4b64-b709-05d9e061cab9", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/CombinComponent/TopDownCar.js: -------------------------------------------------------------------------------- 1 | cc.Class({ 2 | extends: cc.Component, 3 | 4 | properties: { 5 | // foo: { 6 | // default: null, 7 | // url: cc.Texture2D, // optional, default is typeof default 8 | // serializable: true, // optional, default is true 9 | // visible: true, // optional, default is true 10 | // displayName: 'Foo', // optional 11 | // readonly: false, // optional, default is false 12 | // }, 13 | // ... 14 | }, 15 | 16 | // use this for initialization 17 | onLoad: function () { 18 | 19 | }, 20 | 21 | // called every frame, uncomment this function to activate update callback 22 | // update: function (dt) { 23 | 24 | // }, 25 | }); 26 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/CombinComponent/TopDownCar.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "7c56ec69-9dd1-4ee6-9de5-c59c0cda7a09", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/CombinComponent/Wheel.js: -------------------------------------------------------------------------------- 1 | cc.Class({ 2 | extends: cc.Component, 3 | 4 | properties: { 5 | // foo: { 6 | // default: null, 7 | // url: cc.Texture2D, // optional, default is typeof default 8 | // serializable: true, // optional, default is true 9 | // visible: true, // optional, default is true 10 | // displayName: 'Foo', // optional 11 | // readonly: false, // optional, default is false 12 | // }, 13 | // ... 14 | }, 15 | 16 | // use this for initialization 17 | onLoad: function () { 18 | 19 | }, 20 | 21 | // called every frame, uncomment this function to activate update callback 22 | // update: function (dt) { 23 | 24 | // }, 25 | }); 26 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/CombinComponent/Wheel.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "fdeab064-4cf0-4ca4-bad3-bb47d7fe8021", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Contact.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "fbfa28da-5b25-41c8-a70f-b212d28ac0eb", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Contact/Category.js: -------------------------------------------------------------------------------- 1 | window.Physics.Category = cc.Enum({ 2 | A: 1, 3 | B: 2, 4 | C: 4, 5 | D: 8, 6 | E: 16, 7 | F: 32, 8 | AA: 64, 9 | BB: 128, 10 | CC: 256, 11 | DD: 512, 12 | EE: 1024, 13 | FF222: 2048, 14 | AAA: 4096, 15 | }); 16 | 17 | window.Physics.CollsionTarget = cc.Class({ 18 | name: 'CollsionTarget', 19 | ctor: function () {}, 20 | properties: { 21 | A: false, 22 | B: false, 23 | C: false, 24 | D: false, 25 | E: false, 26 | F: false, 27 | AA: false, 28 | BB: false, 29 | CC: false, 30 | DD: false, 31 | EE: false, 32 | FF222: false, 33 | AAA: false, 34 | }, 35 | clone: function () { return new Physics.CollsionTarget(); }, 36 | }); -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Contact/Category.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "d4687e0c-6450-422f-a274-de1b525d2146", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Contact/Contact.js: -------------------------------------------------------------------------------- 1 | window.ContactType = cc.Enum({ 2 | BEGIN_CONTACT: 0, 3 | PRE_CONTACT: 1, 4 | POST_CONTACT: 2, 5 | END_CONTACT: 3, 6 | }); 7 | 8 | window.Contact = cc.Class({ 9 | 10 | name: 'Contact', 11 | 12 | // constructor: contact 13 | ctor: function () { 14 | this.contact = arguments[0]; 15 | }, 16 | 17 | properties: { 18 | targetBody: null, 19 | impulse: null, 20 | oldManifold: null, 21 | }, 22 | 23 | setEnabled: function (e) { 24 | this.contact.SetEnabled(e); 25 | }, 26 | }); 27 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Contact/Contact.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "21b67669-60c4-4ab9-9df2-2ff9ab0c411f", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "a3df2bdf-33ab-4cdb-9266-cd0df55d7438", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/AreaEffector.js: -------------------------------------------------------------------------------- 1 | var body; 2 | 3 | cc.Class({ 4 | extends: cc.Component, 5 | 6 | editor: { 7 | requireComponent: Body, 8 | }, 9 | 10 | properties: { 11 | forceAngle: 0, 12 | forceMagnitude: 10, 13 | }, 14 | 15 | // use this for initialization 16 | onLoad: function () { 17 | body = this.getComponent('Body'); 18 | body.bodyType = BodyType.STATIC; 19 | 20 | var callback = new CallbackEvent(); 21 | callback.target = this; 22 | callback.componentName = this.__classname__; 23 | callback.functionName = 'onTargetEnter'; 24 | body.onPreSolve = callback; 25 | 26 | }, 27 | 28 | onTargetEnter: function (contact) { 29 | // 关闭碰撞反应 30 | contact.setEnabled(false); 31 | 32 | var targetBody = contact.targetBody; 33 | var radian = this.forceAngle / 360 * 2 * Math.PI; 34 | var force = cc.pRotateByAngle(new cc.Vec2(0, 1), cc.Vec2.ZERO, -radian); 35 | force.x *= this.forceMagnitude; 36 | force.y *= this.forceMagnitude; 37 | targetBody.addForce(force); 38 | }, 39 | }); -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/AreaEffector.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "e4af354f-69a1-4c8f-89a7-520efe07d0ba", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/BouyancyEffctor.js: -------------------------------------------------------------------------------- 1 | cc.Class({ 2 | extends: cc.Component, 3 | 4 | properties: { 5 | // foo: { 6 | // default: null, 7 | // url: cc.Texture2D, // optional, default is typeof default 8 | // serializable: true, // optional, default is true 9 | // visible: true, // optional, default is true 10 | // displayName: 'Foo', // optional 11 | // readonly: false, // optional, default is false 12 | // }, 13 | // ... 14 | }, 15 | 16 | // use this for initialization 17 | onLoad: function () { 18 | 19 | }, 20 | 21 | // called every frame, uncomment this function to activate update callback 22 | // update: function (dt) { 23 | 24 | // }, 25 | }); 26 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/BouyancyEffctor.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "ff1b6d94-ba33-4ada-95e7-01fccab46eca", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/ConstantForce.js: -------------------------------------------------------------------------------- 1 | var body; 2 | 3 | cc.Class({ 4 | extends: cc.Component, 5 | 6 | editor: { 7 | requireComponent: Body, 8 | }, 9 | 10 | properties: { 11 | _force: new cc.Vec2(0, 0), 12 | force: { 13 | set: function (value) { 14 | this._force = value; 15 | }, 16 | get: function () { 17 | if (this.relativeForce && !CC_EDITOR) { 18 | var angle = this.node.convertToWorldRotation(); 19 | var radian = angle / 360 * 2 * Math.PI; 20 | return cc.pRotateByAngle(this._force, cc.Vec2.ZERO, -radian); 21 | } 22 | return this._force; 23 | }, 24 | }, 25 | relativeForce: false, 26 | torque: 0, 27 | }, 28 | 29 | // use this for initialization 30 | onLoad: function () { 31 | body = this.getComponent('Box2D_Body'); 32 | }, 33 | 34 | // called every frame, uncomment this function to activate update callback 35 | update: function (dt) { 36 | // 待优化,调节到与Engine的Setp同步 37 | body.addForce(this.force); 38 | body.addTorque(this.torque); 39 | }, 40 | }); 41 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/ConstantForce.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "5eea7034-1b38-473f-88b7-af762ecca3ea", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/PlatformEffctor.js: -------------------------------------------------------------------------------- 1 | cc.Class({ 2 | extends: cc.Component, 3 | 4 | properties: { 5 | // foo: { 6 | // default: null, 7 | // url: cc.Texture2D, // optional, default is typeof default 8 | // serializable: true, // optional, default is true 9 | // visible: true, // optional, default is true 10 | // displayName: 'Foo', // optional 11 | // readonly: false, // optional, default is false 12 | // }, 13 | // ... 14 | }, 15 | 16 | // use this for initialization 17 | onLoad: function () { 18 | 19 | }, 20 | 21 | // called every frame, uncomment this function to activate update callback 22 | // update: function (dt) { 23 | 24 | // }, 25 | }); 26 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/PlatformEffctor.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "9d24a9a4-2990-4803-b845-5d168a4ffc0a", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/PointEffector.js: -------------------------------------------------------------------------------- 1 | var body; 2 | 3 | cc.Class({ 4 | extends: cc.Component, 5 | 6 | editor: { 7 | requireComponent: Body, 8 | }, 9 | 10 | properties: { 11 | forceMagnitude: 10, 12 | }, 13 | 14 | // use this for initialization 15 | onLoad: function () { 16 | body = this.getComponent('Body'); 17 | body.bodyType = BodyType.STATIC; 18 | 19 | var callback = new CallbackEvent(); 20 | callback.target = this; 21 | callback.componentName = this.__classname__; 22 | callback.functionName = 'onTargetEnter'; 23 | body.onPreSolve = callback; 24 | }, 25 | 26 | onTargetEnter: function (contact) { 27 | contact.setEnabled(false); 28 | 29 | var targetBody = contact.targetBody; 30 | var p = new cc.Vec2(body.body.GetPosition()); 31 | var force = p.sub(targetBody.body.GetPosition()); 32 | 33 | force.x *= this.forceMagnitude; 34 | force.y *= this.forceMagnitude; 35 | targetBody.addForce(force); 36 | }, 37 | }); 38 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/PointEffector.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "c9e1158b-d330-4383-a935-6de11c4808cf", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/SurfaceEffctor.js: -------------------------------------------------------------------------------- 1 | var body; 2 | 3 | cc.Class({ 4 | extends: cc.Component, 5 | 6 | editor: { 7 | requireComponent: Body, 8 | }, 9 | 10 | properties: { 11 | speed: 0, 12 | }, 13 | 14 | onLoad: function () { 15 | body = this.getComponent('Body'); 16 | var callback = new CallbackEvent(); 17 | callback.target = this; 18 | callback.componentName = this.__classname__; 19 | callback.functionName = 'onTargetEnter'; 20 | body.onPreSolve = callback; 21 | }, 22 | 23 | onTargetEnter: function (contact) { 24 | var targetBody = contact.targetBody; 25 | var angle = this.node.convertToWorldRotation(); 26 | var radian = angle / 360 * 2 * Math.PI; 27 | var force = cc.pRotateByAngle(new cc.Vec2(1, 0), cc.Vec2.ZERO, -radian); 28 | force.x *= this.speed; 29 | force.y *= this.speed; 30 | targetBody.addForce(force); 31 | }, 32 | }); 33 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Effector/SurfaceEffctor.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "8283dc1f-e92a-46f2-80f3-777bf411d6d9", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "da3cd9b5-c4de-4684-b7c0-5b5eb8787591", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/DistanceJoint.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Box2D_DistanceJoint.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | window.DistanceJoint = cc.Class({ 10 | 11 | extends: Joint, 12 | 13 | properties: { 14 | autoConfigureLength: { 15 | default: false, 16 | }, 17 | jointLength: { 18 | default: 1, 19 | notify: function () { 20 | }, 21 | }, 22 | frequencyHz: { 23 | default: 4, 24 | notify: function () { 25 | }, 26 | }, 27 | dampingRation: { 28 | default: 0.5, 29 | notify: function () { 30 | }, 31 | }, 32 | }, 33 | 34 | start: function () { 35 | this.initJoint(); 36 | 37 | var jointDef = new b2DistanceJointDef(); 38 | jointDef.bodyA = this.localBody; 39 | jointDef.bodyB = this.targetBody; 40 | jointDef.localAnchorA = new b2Vec2(this.localAnchor.x / PTM_RATIO, this.localAnchor.y / PTM_RATIO); 41 | jointDef.localAnchorB = new b2Vec2(this.targetAnchor.x / PTM_RATIO, this.targetAnchor.y / PTM_RATIO); 42 | if (this.autoConfigureLength) { 43 | this.jointLength = cc.pDistance(this.localBody.GetPosition(), 44 | this.targetBody.GetPosition()); 45 | } 46 | jointDef.length = this.jointLength; 47 | jointDef.dampingRation = this.dampingRation; 48 | jointDef.frequencyHz = this.frequencyHz; 49 | jointDef.collideConnected = this.enableCollision; 50 | this.joint = Engine.instance.world.CreateJoint(jointDef); 51 | }, 52 | }); 53 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/DistanceJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "2e703b98-f726-4eb3-972a-45f0ea7dfe4c", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/FrictionJoint.js: -------------------------------------------------------------------------------- 1 | window.FrictionJoint = cc.Class({ 2 | 3 | extends: Joint, 4 | 5 | properties: { 6 | maxForce: { 7 | default: 0, 8 | }, 9 | maxTorque: { 10 | default: 0, 11 | }, 12 | }, 13 | 14 | // use this for initialization 15 | start: function () { 16 | this.initJoint(); 17 | 18 | var jointDef = new b2FrictionJointDef(); 19 | jointDef.bodyA = this.localBody; 20 | jointDef.bodyB = this.targetBody; 21 | jointDef.localAnchorA = this.localAnchor; 22 | jointDef.localAnchorB = this.targetAnchor; 23 | jointDef.collideConnected = this.enableCollision; 24 | jointDef.maxTorque = this.maxTorque; 25 | jointDef.maxForce = this.maxForce; 26 | 27 | this.joint = Engine.instance.world.CreateJoint(jointDef); 28 | }, 29 | }); 30 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/FrictionJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "2ea052fc-22a6-44e0-8d9e-623f4c9bfb45", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/GearJoint.js: -------------------------------------------------------------------------------- 1 | require('RevoluteJoint'); 2 | require('PrismaticJoint'); 3 | 4 | var GearJointType = cc.Enum({ 5 | REVOLUTE: 0, 6 | PRISMATIC: 1, 7 | }); 8 | 9 | window.GearJoint = cc.Class({ 10 | 11 | extends: cc.Component, 12 | 13 | properties: { 14 | joint1_Type: { 15 | default: GearJointType.REVOLUTE, 16 | type: GearJointType, 17 | }, 18 | revoluteJoint1: { 19 | default: null, 20 | type: RevoluteJoint, 21 | }, 22 | prismaticJoint1: { 23 | default: null, 24 | type: PrismaticJoint, 25 | }, 26 | joint2_Type: { 27 | default: GearJointType.REVOLUTE, 28 | type: GearJointType, 29 | }, 30 | revoluteJoint2: { 31 | default: null, 32 | type: RevoluteJoint, 33 | }, 34 | prismaticJoint2: { 35 | default: null, 36 | type: PrismaticJoint, 37 | }, 38 | ratio: { 39 | default: 1, 40 | }, 41 | joint: { 42 | default: null, 43 | visible: false, 44 | }, 45 | }, 46 | 47 | start: function () { 48 | // 延迟一帧执行:由于GearJoint需要引用到其他joint,为了防止 49 | // 其他joint的Node顺序在该Node之下导致引用的时候,joint 50 | // 还未生成,所以GearJonit的创建函数必须比其他任何Jonit都慢 51 | this.scheduleOnce(function() { 52 | this.createJoint(); 53 | }, 1 / 60); 54 | }, 55 | 56 | createJoint: function () { 57 | var jointDef = new b2GearJointDef(); 58 | jointDef.bodyA = Box2D_Engine.instance.world.GetGroundBody(); 59 | if (this.joint1_Type === GearJointType.REVOLUTE) { 60 | jointDef.joint1 = this.revoluteJoint1.joint; 61 | } 62 | else { 63 | jointDef.joint1 = this.prismaticJoint1.joint; 64 | } 65 | if (this.joint2_Type === GearJointType.REVOLUTE) { 66 | jointDef.joint2 = this.revoluteJoint2.joint; 67 | } 68 | else { 69 | jointDef.joint2 = this.prismaticJoint2.joint; 70 | } 71 | jointDef.ratio = this.ratio; 72 | jointDef.collideConnected = this.enableCollision; 73 | 74 | this.joint = Engine.instance.world.CreateJoint(jointDef); 75 | }, 76 | }); 77 | 78 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/GearJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "14e21021-6f39-4bb2-8f7e-122c8d44f50c", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/Joint.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Joint.js 6 | * Describe : The base class of joints. 7 | *************************************************/ 8 | 9 | require('Body'); 10 | 11 | window.Joint = cc.Class({ 12 | 13 | extends: cc.Component, 14 | 15 | editor: { 16 | requireComponent: Body, 17 | }, 18 | 19 | properties: { 20 | enableCollision: { 21 | default: false, 22 | notify: function () { 23 | }, 24 | }, 25 | localBody: { 26 | default: null, 27 | visible: false, 28 | }, 29 | localAnchor: cc.v2(0, 0), 30 | targetBody: { 31 | default: null, 32 | type: Body, 33 | }, 34 | targetAnchor: cc.v2(0, 0), 35 | breakForce: { 36 | default: -1, 37 | notify: function () { 38 | if (!CC_EDITOR) { 39 | if (this.breakForce > 0) { 40 | this.getComponent(Box2D_Body).addContactEvent(ContactType.POST_CONTACT, 41 | this.onPostContact.bind(this)); 42 | } else { 43 | this.getComponent(Box2D_Body).removeContactEvent(ContactType.POST_CONTACT, 44 | this.onPostContact); 45 | } 46 | } 47 | }, 48 | }, 49 | joint: { 50 | default: null, 51 | visible: false, 52 | }, 53 | }, 54 | 55 | initJoint: function () { 56 | this.localBody = this.getComponent(Body).body; 57 | if (!this.targetBody) { 58 | this.targetBody = Engine.instance.world.GetGroundBody(); 59 | } else { 60 | this.targetBody = this.targetBody.body; 61 | } 62 | if (this.localBody === this.targetBody) { 63 | Logger.error('LocalBody and targetBody should not be same.'); 64 | } 65 | 66 | if (this.breakForce > 0) { 67 | this.getComponent(Body).addContactEvent(ContactType.POST_CONTACT, 68 | this.onPostContact.bind(this)); 69 | } 70 | }, 71 | 72 | onPostContact: function (contact) { 73 | if (contact.impulse.normalImpulses[0] >= this.breakForce) { 74 | this.destroy(); 75 | } 76 | }, 77 | 78 | onDestroy: function () { 79 | Engine.instance.world.DestroyJoint(this.joint); 80 | this.getComponent(Body).removeContactEvent(ContactType.POST_CONTACT, 81 | this.onPostContact); 82 | }, 83 | }); 84 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/Joint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "3bf5e232-322b-4dee-9861-3551f6b974a4", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/LineJoint.js: -------------------------------------------------------------------------------- 1 | require('Joint'); 2 | 3 | window.LineJoint = cc.Class({ 4 | 5 | extends: Joint, 6 | 7 | properties: { 8 | autoConfigureAxisA: { 9 | default: false, 10 | }, 11 | localAxisA: { 12 | default: new cc.Vec2(0, 0), 13 | }, 14 | enableLimit: { 15 | default: false, 16 | }, 17 | lowerTranslation: { 18 | default: 0, 19 | }, 20 | upperTranslation: { 21 | default: 0, 22 | }, 23 | enableMotor: { 24 | default: false, 25 | }, 26 | motorSpeed: { 27 | default: 0, 28 | }, 29 | maxMotorForce: { 30 | default: 0, 31 | }, 32 | }, 33 | 34 | start: function () { 35 | this.initJoint(); 36 | 37 | var jointDef = new b2LineJointDef(); 38 | jointDef.bodyA = this.localBody; 39 | jointDef.bodyB = this.targetBody; 40 | jointDef.localAnchorA = this.localAnchor; 41 | jointDef.localAnchorB = this.targetAnchor; 42 | if (this.autoConfigureAxisA) { 43 | // 44 | } 45 | else { 46 | jointDef.localAxisA = this.localAxisA; 47 | } 48 | jointDef.collideConnected = this.enableCollision; 49 | jointDef.enableLimit = this.enableLimit; 50 | jointDef.enableMotor = this.enableMotor; 51 | jointDef.lowerTranslation = this.lowerTranslation; 52 | jointDef.upperTranslation = this.upperTranslation; 53 | jointDef.maxMotorForce = this.maxMotorForce; 54 | jointDef.motorSpeed = this.motorSpeed; 55 | 56 | this.joint = Engine.instance.world.CreateJoint(jointDef); 57 | }, 58 | }); 59 | 60 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/LineJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "31ff9709-9296-4ea1-9671-e773b665ab23", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/MouseJoint.js: -------------------------------------------------------------------------------- 1 | require('Body'); 2 | 3 | window.MouseJoint = cc.Class({ 4 | 5 | extends: cc.Component, 6 | 7 | editor: { 8 | requireComponent: Body, 9 | }, 10 | 11 | properties: { 12 | localBody: { 13 | default: null, 14 | visible: false, 15 | }, 16 | dragForce: 500, 17 | dampingRatio: 0.7, 18 | frequencyHz: 5, 19 | joint: { 20 | default: null, 21 | visible: false, 22 | }, 23 | }, 24 | 25 | // use this for initialization 26 | start: function () { 27 | var self = this; 28 | 29 | this.localBody = this.getComponent(Body).body; 30 | 31 | // this.node.on('touchstart', this.mouseDown, this); 32 | this.node.on('mousedown', this.mouseDown, this); 33 | 34 | cc.eventManager.addListener({ 35 | event: cc.EventListener.TOUCH_ONE_BY_ONE, 36 | onTouchBegan: function (touch, event) { 37 | // If return false, it will capture the next event - onTouchMoved && onTouchEnded 38 | return true; 39 | }, 40 | onTouchMoved: function (touch, event) { 41 | if (self.joint) { 42 | var p = new b2Vec2(touch.getLocationX() / PTM_RATIO, touch.getLocationY() / PTM_RATIO); 43 | self.joint.SetTarget(p); 44 | } 45 | }, 46 | onTouchEnded: function (touch, event) { 47 | if (self.joint) { 48 | Engine.instance.world.DestroyJoint(self.joint); 49 | self.joint = null; 50 | } 51 | } 52 | }, this.node); 53 | }, 54 | 55 | mouseDown: function (event) { 56 | if (this.joint) { 57 | Engine.instance.world.DestroyJoint(this.joint); 58 | this.joint = null; 59 | } 60 | 61 | // 待修复,用touch取代mouse 62 | // var touch = event.touch; 63 | var touch = event; 64 | 65 | var md = new b2MouseJointDef(); 66 | md.bodyA = Engine.instance.world.GetGroundBody(); 67 | md.bodyB = this.localBody; 68 | md.target.Set(touch.getLocationX() / PTM_RATIO, touch.getLocationY() / PTM_RATIO); 69 | md.dampingRatio = this.dampingRatio; 70 | md.frequencyHz = this.frequencyHz; 71 | md.collideConnected = this.enableCollision; 72 | md.maxForce = this.dragForce * this.localBody.GetMass(); 73 | this.joint = Engine.instance.world.CreateJoint(md); 74 | //this.localBody.SetAwake(true); 75 | }, 76 | 77 | onDestroy: function () { 78 | Engine.instance.world.DestroyJoint(this.joint); 79 | }, 80 | }); 81 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/MouseJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "a18cc0f7-1ca6-442d-9030-01840463ef0a", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/PrismaticJoint.js: -------------------------------------------------------------------------------- 1 | require('Joint'); 2 | 3 | window.PrismaticJoint = cc.Class({ 4 | extends: Joint, 5 | 6 | properties: { 7 | autoConfigureAxisA: { 8 | default: false, 9 | }, 10 | localAxisA: { 11 | default: new cc.Vec2(0, 0), 12 | }, 13 | enableLimit: { 14 | default: false, 15 | }, 16 | lowerTranslation: { 17 | default: 0, 18 | }, 19 | upperTranslation: { 20 | default: 0, 21 | }, 22 | enableMotor: { 23 | default: false, 24 | }, 25 | motorSpeed: { 26 | default: 0, 27 | }, 28 | maxMotorForce: { 29 | default: 0, 30 | }, 31 | referenceAngle: { 32 | default: 0, 33 | }, 34 | }, 35 | 36 | start: function () { 37 | this.initJoint(); 38 | 39 | var jointDef = new b2PrismaticJointDef(); 40 | jointDef.bodyA = this.localBody; 41 | jointDef.bodyB = this.targetBody; 42 | jointDef.localAnchorA = this.localAnchor; 43 | jointDef.localAnchorB = this.targetAnchor; 44 | if (this.autoConfigureAxisA) { 45 | // 46 | } 47 | else { 48 | jointDef.localAxisA = this.localAxisA; 49 | } 50 | jointDef.collideConnected = this.enableCollision; 51 | jointDef.enableLimit = this.enableLimit; 52 | jointDef.enableMotor = this.enableMotor; 53 | jointDef.lowerTranslation = this.lowerTranslation; 54 | jointDef.upperTranslation = this.upperTranslation; 55 | jointDef.maxMotorForce = this.maxMotorForce; 56 | jointDef.motorSpeed = this.motorSpeed; 57 | jointDef.referenceAngle = this.referenceAngle / 360 * (2 * Math.PI); 58 | 59 | this.joint = Engine.instance.world.CreateJoint(jointDef); 60 | }, 61 | }); 62 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/PrismaticJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "cce0d81d-0678-46ff-8519-890e027110fb", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/PulleyJoint.js: -------------------------------------------------------------------------------- 1 | require('Joint'); 2 | 3 | window.PulleyJoint = cc.Class({ 4 | 5 | extends: Joint, 6 | 7 | properties: { 8 | groundAnchorA: { 9 | default: null, 10 | type: cc.Node, 11 | }, 12 | groundAnchorB: { 13 | default: null, 14 | type: cc.Node, 15 | }, 16 | autoConfigureLength: { 17 | default: false, 18 | }, 19 | lengthA: { 20 | default: 0, 21 | }, 22 | lengthB: { 23 | default: 0, 24 | }, 25 | maxLengthA: { 26 | default: 0, 27 | }, 28 | maxLengthB: { 29 | default: 0, 30 | }, 31 | ratio: { 32 | default: 1, 33 | }, 34 | }, 35 | 36 | // use this for initialization 37 | start: function () { 38 | this.initJoint(); 39 | 40 | var jointDef = new b2PulleyJointDef(); 41 | jointDef.bodyA = this.localBody; 42 | jointDef.bodyB = this.targetBody; 43 | jointDef.localAnchorA = this.localAnchor; 44 | jointDef.localAnchorB = this.targetAnchor; 45 | jointDef.collideConnected = this.enableCollision; 46 | jointDef.groundAnchorA = new b2Vec2(this.groundAnchorA.position.x / PTM_RATIO, 47 | this.groundAnchorA.position.y / PTM_RATIO); 48 | jointDef.groundAnchorB = new b2Vec2(this.groundAnchorB.position.x / PTM_RATIO, 49 | this.groundAnchorB.position.y / PTM_RATIO); 50 | jointDef.lengthA = this.lengthA; 51 | jointDef.lengthB = this.lengthB; 52 | jointDef.maxLengthA = this.maxLengthA; 53 | jointDef.maxLengthB = this.maxLengthB; 54 | jointDef.ratio = this.ratio; 55 | this.joint = Engine.instance.world.CreateJoint(jointDef); 56 | }, 57 | }); 58 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/PulleyJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "ee537d85-fdb2-459c-9de9-1f2ddc517c08", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/RevoluteJoint.js: -------------------------------------------------------------------------------- 1 | require('Joint'); 2 | 3 | window.RevoluteJoint = cc.Class({ 4 | 5 | extends: Joint, 6 | 7 | properties: { 8 | autoConfigureTargetdAnchor: { 9 | default: true, 10 | }, 11 | enableLimit: { 12 | default: false, 13 | }, 14 | lowerAngle: { 15 | default: 0, 16 | }, 17 | upperAngle: { 18 | default: 0, 19 | }, 20 | referenceAngle: { 21 | default: 0, 22 | }, 23 | enableMotor: { 24 | default: false, 25 | }, 26 | motorSpeed: { 27 | default: 0, 28 | }, 29 | maxMotorTorque: { 30 | default: 0, 31 | }, 32 | breakTorque: { 33 | default: -1, 34 | }, 35 | _canvas: null, 36 | }, 37 | 38 | start: function () { 39 | this.initJoint(); 40 | 41 | var jointDef = new b2RevoluteJointDef(); 42 | jointDef.bodyA = this.localBody; 43 | jointDef.bodyB = this.targetBody; 44 | jointDef.localAnchorA = new b2Vec2(this.localAnchor.x / PTM_RATIO, this.localAnchor.y / PTM_RATIO); 45 | if (this.autoConfigureTargetdAnchor) { 46 | var pos_1 = this.localBody.GetPosition(); 47 | var pos_2 = this.targetBody.GetPosition(); 48 | jointDef.localAnchorB = new b2Vec2(pos_1.x - pos_2.x, pos_1.y - pos_2.y); 49 | } 50 | else { 51 | jointDef.localAnchorB = new b2Vec2(this.targetAnchor.x / PTM_RATIO, this.targetAnchor.y / PTM_RATIO); 52 | } 53 | jointDef.collideConnected = this.enableCollision; 54 | jointDef.enableLimit = this.enableLimit; 55 | jointDef.enableMotor = this.enableMotor; 56 | jointDef.lowerAngle = this.lowerAngle / 360 * (2 * Math.PI); 57 | jointDef.upperAngle = this.upperAngle / 360 * (2 * Math.PI); 58 | jointDef.referenceAngle = this.referenceAngle / 360 * (2 * Math.PI); 59 | jointDef.maxMotorTorque = this.maxMotorTorque; 60 | jointDef.motorSpeed = this.motorSpeed; 61 | 62 | this.joint = Engine.instance.world.CreateJoint(jointDef); 63 | }, 64 | }); 65 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/RevoluteJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "0e757254-3a6e-49a1-9217-d98c50239407", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/RopeJoint.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Box2D_DistanceJoint.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | window.RopeJoint = cc.Class({ 10 | 11 | extends: Joint, 12 | 13 | properties: { 14 | autoConfigureLength: { 15 | default: false, 16 | }, 17 | jointLength: { 18 | default: 1, 19 | notify: function () { 20 | }, 21 | }, 22 | frequencyHz: { 23 | default: 4, 24 | notify: function () { 25 | }, 26 | }, 27 | dampingRation: { 28 | default: 0.5, 29 | notify: function () { 30 | }, 31 | }, 32 | }, 33 | 34 | start: function () { 35 | this.initJoint(); 36 | 37 | var jointDef = new b2RopeJointDef(); 38 | jointDef.bodyA = this.localBody; 39 | jointDef.bodyB = this.targetBody; 40 | jointDef.localAnchorA = this.localAnchor; 41 | jointDef.localAnchorB = this.targetAnchor; 42 | if (this.autoConfigureLength) { 43 | this.jointLength = cc.pDistance(this.localBody.GetPosition(), 44 | this.targetBody.GetPosition()); 45 | } 46 | jointDef.length = this.jointLength; 47 | jointDef.dampingRation = this.dampingRation; 48 | jointDef.frequencyHz = this.frequencyHz; 49 | jointDef.collideConnected = this.enableCollision; 50 | this.joint = Engine.instance.world.CreateJoint(jointDef); 51 | }, 52 | }); 53 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/RopeJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "bb7803dc-51c1-4f7e-931e-59ba188d258b", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/WeldJoint.js: -------------------------------------------------------------------------------- 1 | require('Joint'); 2 | 3 | window.WeldJoint = cc.Class({ 4 | 5 | extends: Joint, 6 | 7 | properties: { 8 | autoConfigureTargetdAnchor: { 9 | default: false, 10 | }, 11 | referenceAngle: { 12 | default: 0 13 | }, 14 | }, 15 | 16 | start: function () { 17 | this.initJoint(); 18 | 19 | var jointDef = new b2WeldJointDef(); 20 | jointDef.bodyA = this.localBody; 21 | jointDef.bodyB = this.targetBody; 22 | jointDef.localAnchorA = this.localAnchor; 23 | if (this.autoConfigureTargetdAnchor) { 24 | var pos_1 = this.localBody.GetPosition(); 25 | var pos_2 = this.targetBody.GetPosition(); 26 | jointDef.localAnchorB = new b2Vec2(pos_1.x - pos_2.x, pos_1.y - pos_2.y); 27 | } 28 | else { 29 | jointDef.localAnchorB = this.targetAnchor; 30 | } 31 | jointDef.collideConnected = this.enableCollision; 32 | jointDef.referenceAngle = this.referenceAngle / 360 * (2 * Math.PI); 33 | 34 | this.joint = Box2D_Engine.instance.world.CreateJoint(jointDef); 35 | }, 36 | }); 37 | 38 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Joint/WeldJoint.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "c1e8cae3-240e-4b20-9090-653c8a1e5a9a", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "005d3ecb-076c-425d-9573-26f4cd5a2366", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/BoxShape.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Box2D_BoxShape.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | require('Shape'); 10 | 11 | window.BoxShape = cc.Class({ 12 | 13 | extends: Shape, 14 | 15 | editor: { 16 | menu: 'i18n:Box2D.Shape.BoxShape.menu', 17 | }, 18 | 19 | properties: { 20 | shapeType: { 21 | default: ShapeType.BOX, 22 | type: ShapeType, 23 | readonly: true, 24 | visible: false, 25 | }, 26 | 27 | _size: cc.Vec2.ONE, 28 | size: { 29 | get: function() { 30 | return this._size; 31 | }, 32 | set: function (value) { 33 | this._size = value; 34 | this._size.x = value.x < 0 ? 0 : value.x; 35 | this._size.y = value.y < 0 ? 0 : value.y; 36 | } 37 | }, 38 | 39 | _offset: cc.Vec2.ZERO, 40 | offset: { 41 | get: function() { 42 | return this._offset; 43 | }, 44 | set: function (value) { 45 | this._offset = value; 46 | } 47 | }, 48 | }, 49 | 50 | getShape: function() { 51 | 52 | var scale = this.node.convertToWorldScale(); 53 | 54 | var shape = new b2PolygonShape(); 55 | shape.SetAsOrientedBox(this.size.x / 2 / PTM_RATIO, this.size.y / 2 / PTM_RATIO, 56 | new b2Vec2(this.offset.x / PTM_RATIO, this.offset.y / PTM_RATIO), 0); 57 | 58 | return shape; 59 | }, 60 | }); -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/BoxShape.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "24cf35b8-fc68-4fc0-b544-7f0cf604a24d", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/CircleShape.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Box2D_CircleShape.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | require('Shape'); 10 | 11 | window.CircleShape = cc.Class({ 12 | 13 | extends: Shape, 14 | 15 | editor: { 16 | menu: 'i18n:Box2D.Shape.CircleShape.menu', 17 | //inspector: 'packages://box2d/inspector/circleShape.js', 18 | }, 19 | 20 | properties: { 21 | 22 | shapeType: { 23 | default: ShapeType.CIRCLE, 24 | type: ShapeType, 25 | readonly: true, 26 | }, 27 | 28 | _radius: 50, 29 | radius: { 30 | get: function () { 31 | return this._radius; 32 | }, 33 | set: function (value) { 34 | this._radius = value < 0 ? 0 : value; 35 | } 36 | }, 37 | 38 | _offset: cc.Vec2.ZERO, 39 | offset: { 40 | get: function() { 41 | return this._offset; 42 | }, 43 | set: function (value) { 44 | this._offset = value; 45 | } 46 | }, 47 | }, 48 | 49 | getShape: function() { 50 | 51 | var scale = this.node.convertToWorldScale(); 52 | var shape = new b2CircleShape(this.radius / PTM_RATIO); 53 | shape.SetLocalPosition(new b2Vec2(this.offset.x / PTM_RATIO, this.offset.y / PTM_RATIO)); 54 | 55 | return shape; 56 | }, 57 | }); -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/CircleShape.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "608f0cab-2cd1-43dc-acdb-58c1ca697a60", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/EdgeShape.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Box2D_EdgeShape.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | require('Shape'); 10 | 11 | window.EdgeShape = cc.Class({ 12 | 13 | extends: Shape, 14 | 15 | editor: { 16 | menu: 'i18n:Box2D.Shape.Box2D_EdgeShape.menu', 17 | }, 18 | 19 | properties: { 20 | shapeType: { 21 | default: ShapeType.EDGE, 22 | type: ShapeType, 23 | readonly: true, 24 | visible: false, 25 | }, 26 | 27 | vertexes: { 28 | default: [], 29 | type: [cc.Vec2], 30 | visible: true, 31 | }, 32 | 33 | _offset: cc.Vec2.ZERO, 34 | offset: { 35 | get: function() { 36 | return this._offset; 37 | }, 38 | set: function (value) { 39 | this._offset = value; 40 | } 41 | }, 42 | }, 43 | 44 | getShape: function () { 45 | 46 | var vets = new Array(this.vertexes.length); 47 | 48 | for (var i = 0; i < this.vertexes.length; ++i) { 49 | var v = new b2Vec2((this.vertexes[i].x + this.offset.x) / PTM_RATIO, 50 | (this.vertexes[i].y + this.offset.y) / PTM_RATIO); 51 | vets[i] = v; 52 | } 53 | 54 | var shapes = new Array(vets.length - 1); 55 | for (i = 0; i < vets.length - 1; ++i) { 56 | var shape = new b2PolygonShape(); 57 | shape.SetAsEdge(vets[i], vets[i + 1]); 58 | shapes[i] = shape; 59 | } 60 | return shapes; 61 | }, 62 | }); 63 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/EdgeShape.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "e97f9d05-3ec2-4172-95d3-f943af055b6a", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/PolygonShape.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Box2D_EdgeShape.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | require('Shape'); 10 | 11 | window.PolygonShape = cc.Class({ 12 | 13 | extends: Shape, 14 | 15 | editor: { 16 | menu: 'i18n:Box2D.Shape.Box2D_PolygonShape.menu', 17 | }, 18 | 19 | properties: { 20 | 21 | shapeType: { 22 | default: ShapeType.POLYGON, 23 | type: ShapeType, 24 | readonly: true, 25 | visible: false, 26 | }, 27 | 28 | vertexes: { 29 | default: [], 30 | type: [cc.Vec2], 31 | visible: true, 32 | }, 33 | 34 | _offset: cc.Vec2.ZERO, 35 | offset: { 36 | get: function() { 37 | return this._offset; 38 | }, 39 | set: function (value) { 40 | this._offset = value; 41 | } 42 | }, 43 | }, 44 | 45 | getShape: function () { 46 | 47 | var vets = new Array(this.vertexes.length); 48 | 49 | for (var i = 0; i < this.vertexes.length; ++i) { 50 | var v = new b2Vec2((this.vertexes[i].x + this.offset.x) / PTM_RATIO, 51 | (this.vertexes[i].y + this.offset.y) / PTM_RATIO); 52 | vets[i] = v; 53 | } 54 | 55 | var shape = new b2PolygonShape(); 56 | shape.SetAsVector(vets, vets.length); 57 | return shape; 58 | }, 59 | }); 60 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/PolygonShape.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "223ccda7-27cd-4845-aa36-fa09b49980b8", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/Shape.js: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * Create : 2016/1/30 3 | * Update : 2016/1/30 4 | * Author : Jeason1997 5 | * FileName : Box2D_Shape.js 6 | * Describe : 7 | *************************************************/ 8 | 9 | require('Physics'); 10 | require('Body'); 11 | 12 | window.ShapeType = cc.Enum({ 13 | BOX: 0, 14 | CIRCLE: 1, 15 | POLYGON: 2, 16 | EDGE: 3, 17 | }); 18 | 19 | /** 20 | * @class Box2D_Shape 21 | * @extends cc.Component 22 | */ 23 | window.Shape = cc.Class({ 24 | 25 | extends: cc.Component, 26 | 27 | properties: { 28 | 29 | editing: { 30 | default: false, 31 | editorOnly: true, 32 | serializable: false, 33 | }, 34 | 35 | body: { 36 | default: null, 37 | type: Body, 38 | visible: false, 39 | }, 40 | }, 41 | 42 | getShape: function () { 43 | }, 44 | }); 45 | -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Shape/Shape.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "ce69be49-329c-46d6-b16c-1d1835487285", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Utils.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "c5aa9e89-8803-4a7a-9d53-08f0e3682a75", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Utils/Expand.js: -------------------------------------------------------------------------------- 1 | // Expand the cc.Node function 2 | cc.Node.prototype.convertToWorldRotation = function (rotation) { 3 | var rot = rotation ? rotation : this.rotation; 4 | var parent = this.parent; 5 | while(parent.parent){ 6 | rot += parent.rotation; 7 | parent = parent.parent; 8 | } 9 | return rot; 10 | }; 11 | 12 | cc.Node.prototype.convertToNodeRotation = function (rotation) { 13 | rotation -= this.rotation; 14 | var parent = this.parent; 15 | while(parent.parent){ 16 | rotation -= parent.rotation; 17 | parent = parent.parent; 18 | } 19 | return rotation; 20 | }; 21 | 22 | cc.Node.prototype.convertToWorldPosition = function (position) { 23 | var pos = position ? position : this.position; 24 | var parent = this.parent; 25 | while (parent.parent) { 26 | pos.x += parent.position.x; 27 | pos.y += parent.position.y; 28 | parent = parent.parent; 29 | } 30 | return pos; 31 | }; 32 | 33 | cc.Node.prototype.convertToNodePosition = function (position) { 34 | position -= this.position; 35 | var parent = this.parent; 36 | while(parent.parent){ 37 | position.x -= parent.position.x; 38 | position.y -= parent.position.y; 39 | parent = parent.parent; 40 | } 41 | return position; 42 | }; 43 | 44 | cc.Node.prototype.convertToWorldScale = function () { 45 | var scaleX = this.scaleX; 46 | var scaleY = this.scaleY; 47 | var parent = this.parent; 48 | while (parent.parent) { 49 | scaleX *= parent.scaleX; 50 | scaleY *= parent.scaleY; 51 | parent = parent.parent; 52 | } 53 | return new cc.Vec2(scaleX, scaleY); 54 | }; -------------------------------------------------------------------------------- /assets/Box2D/Scripts/Utils/Expand.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "92ff382e-5065-4b6e-bb1d-71571ab5d496", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Demo.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "9f3a0336-e0bf-4d2f-b1d3-32d915ea990c", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Demo/DemoScene.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "72729584-e887-4af5-b77e-6596b9350081", 4 | "asyncLoadAssets": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Demo/Destroy.js: -------------------------------------------------------------------------------- 1 | cc.Class({ 2 | extends: cc.Component, 3 | 4 | editor: { 5 | executeInEditMode: true, 6 | }, 7 | 8 | onLoad: function () { 9 | 10 | 11 | if (CC_EDITOR) 12 | { 13 | Editor.assetdb.queryUuidByUrl( 'db://assets/Box2D/Prefab/Line.prefab', function (uuid) { 14 | cc.AssetLibrary.loadAsset(uuid, function (err, res) { 15 | if (err) { 16 | cc.error(err); 17 | } 18 | else { 19 | cc.log('Load Success : ' + res); 20 | var child = cc.instantiate(res); 21 | child.name = 'P'; 22 | this.node.addChild(child); 23 | } 24 | }.bind(this)); 25 | }.bind(this)); 26 | 27 | 28 | } 29 | 30 | 31 | 32 | 33 | }, 34 | 35 | }); 36 | -------------------------------------------------------------------------------- /assets/Demo/Destroy.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "ca1a9668-a68d-43a9-a424-5b7b483729e5", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Demo/NewScript.js: -------------------------------------------------------------------------------- 1 | var ClickEvent = cc.Class({ 2 | name: 'ClickEvent', 3 | properties: { 4 | prefabs: { 5 | default: [], 6 | type: [cc.Prefab], 7 | } 8 | }, 9 | }); 10 | 11 | cc.Class({ 12 | extends: cc.Component, 13 | 14 | editor: { 15 | executeInEditMode: false, 16 | }, 17 | 18 | properties: { 19 | p1: new cc.Vec2(0, 0), 20 | p2: new cc.Vec2(100, 100), 21 | prefabs: { 22 | default: [], 23 | type: [ClickEvent], 24 | } 25 | }, 26 | 27 | onLoad: function () { 28 | this.draw = new cc.DrawNode(); 29 | cc.Canvas.instance.node.parent._sgNode.addChild(this.draw); 30 | }, 31 | 32 | update: function(dt) { 33 | Physics.RayCast(this.p1, this.p2, this.back.bind(this)); 34 | }, 35 | 36 | back: function(fixture, point, normal, fraction) { 37 | this.draw.clear(); 38 | this.draw.drawDot(new cc.Vec2(point.x * PTM_RATIO, point.y * PTM_RATIO), 39 | 5, new cc.Color(0, 255, 0, 150)); 40 | }, 41 | }); 42 | -------------------------------------------------------------------------------- /assets/Demo/NewScript.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "cd948ac8-a15f-411a-b91c-5a771328dceb", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Demo/Texture.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "2b4a7f7b-af1f-49ce-9e98-d71fad8a11b1", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Demo/Texture/RedMonster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeason1997/EasyBox2D/14765757cb001b14e130042070b6a37fedb84542/assets/Demo/Texture/RedMonster.png -------------------------------------------------------------------------------- /assets/Demo/Texture/RedMonster.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "fab56a16-d34f-49a7-b2d4-2812895543eb", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "RedMonster": { 9 | "ver": "1.0.3", 10 | "uuid": "993767db-2752-4b8b-9cc1-16fd133db4e9", 11 | "rawTextureUuid": "fab56a16-d34f-49a7-b2d4-2812895543eb", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": 0, 16 | "offsetY": 0, 17 | "trimX": 0, 18 | "trimY": 0, 19 | "width": 68, 20 | "height": 75, 21 | "rawWidth": 68, 22 | "rawHeight": 75, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /assets/Demo/Texture/button_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeason1997/EasyBox2D/14765757cb001b14e130042070b6a37fedb84542/assets/Demo/Texture/button_empty.png -------------------------------------------------------------------------------- /assets/Demo/Texture/button_empty.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "0c8710c4-2672-46cf-847d-646cc8151424", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "button_empty": { 9 | "ver": "1.0.3", 10 | "uuid": "bc91ea2b-e596-4ff5-a206-86a911f922bf", 11 | "rawTextureUuid": "0c8710c4-2672-46cf-847d-646cc8151424", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": 0, 16 | "offsetY": 0, 17 | "trimX": 0, 18 | "trimY": 0, 19 | "width": 442, 20 | "height": 141, 21 | "rawWidth": 442, 22 | "rawHeight": 141, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /assets/Demo/Texture/restart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeason1997/EasyBox2D/14765757cb001b14e130042070b6a37fedb84542/assets/Demo/Texture/restart.png -------------------------------------------------------------------------------- /assets/Demo/Texture/restart.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "e49cc86d-c4c9-491c-a459-d2a455901e46", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "restart": { 9 | "ver": "1.0.3", 10 | "uuid": "d1f6a5ae-d144-406c-b454-4c01e63e7974", 11 | "rawTextureUuid": "e49cc86d-c4c9-491c-a459-d2a455901e46", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": 0, 16 | "offsetY": 0, 17 | "trimX": 0, 18 | "trimY": 0, 19 | "width": 94, 20 | "height": 94, 21 | "rawWidth": 94, 22 | "rawHeight": 94, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /assets/Test.js: -------------------------------------------------------------------------------- 1 | cc.Class({ 2 | extends: cc.Component, 3 | 4 | properties: { 5 | radius: 50, 6 | fun: { 7 | default: [], 8 | type: cc.Component.EventHandler, 9 | }, 10 | }, 11 | 12 | // use this for initialization 13 | onLoad: function () { 14 | var eventHandler = new cc.Component.EventHandler(); 15 | eventHandler.target = this; 16 | eventHandler.component = "Test"; 17 | eventHandler.handler = "操你妈"; 18 | 19 | 20 | this.fun.push(eventHandler); 21 | }, 22 | 23 | 操你妈: function(){ 24 | cc.log('中文'); 25 | }, 26 | 27 | hahah: function(str) { 28 | cc.log(str); 29 | }, 30 | 31 | fuck: function() { 32 | cc.log('this is a fuck'); 33 | }, 34 | 35 | test: function () { 36 | cc.Component.EventHandler.emitEvents(this.fun, "我操你妈"); 37 | }, 38 | }); 39 | -------------------------------------------------------------------------------- /assets/Test.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "1c921cd5-bba4-42ab-8568-7ee40befcced", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/test.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "bda179a6-bfea-4181-8145-de1a59168d63", 4 | "asyncLoadAssets": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /node_modules/box2dweb-commonjs/MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Konstantin Raev (bestander@gmail.com) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /node_modules/box2dweb-commonjs/README.md: -------------------------------------------------------------------------------- 1 | box2dweb-commonjs 2 | ================= 3 | [![web component logo](https://component.jit.su/component-badge.svg)](https://github.com/component/component) 4 | 5 | CommonJS version of Box2dWeb both for npm and component(1) 6 | The patch to support Node.js was prepared by [Christoph Schulz](http://code.google.com/p/box2dweb/issues/detail?id=22) 7 | 8 | Usage 9 | ------------ 10 | 11 | Both in component(1) or node.js just 12 | ```javascript 13 | var box2d = require('box2dweb-commonjs'); 14 | var world = new box2d.b2World(....) 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /node_modules/box2dweb-commonjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "box2dweb-commonjs", 3 | "repo": "bestander/box2dweb-commonjs", 4 | "description": "Box2dweb as a Common JS module", 5 | "version": "2.1.0", 6 | "keywords": [ 7 | "game", 8 | "box2d" 9 | ], 10 | "author": { 11 | "name": "Konstantin Raev", 12 | "email": "bestander@gmail.com" 13 | }, 14 | "main": "./Box2dWeb-2.1.a.3.js", 15 | "engines": [ 16 | "node" 17 | ], 18 | "license": "MIT", 19 | "readme": "box2dweb-commonjs\n=================\n[![web component logo](https://component.jit.su/component-badge.svg)](https://github.com/component/component)\n\nCommonJS version of Box2dWeb both for npm and component(1) \nThe patch to support Node.js was prepared by [Christoph Schulz](http://code.google.com/p/box2dweb/issues/detail?id=22)\n\nUsage\n------------\n\nBoth in component(1) or node.js just\n```javascript\nvar box2d = require('box2dweb-commonjs');\nvar world = new box2d.b2World(....)\n```\n\n", 20 | "_id": "box2dweb-commonjs@2.1.0", 21 | "dist": { 22 | "shasum": "8a0168a8b6615fd935f9a25aade6b174b24cab34", 23 | "tarball": "http://registry.npmjs.org/box2dweb-commonjs/-/box2dweb-commonjs-2.1.0.tgz" 24 | }, 25 | "_npmVersion": "1.1.63", 26 | "_npmUser": { 27 | "name": "bestander", 28 | "email": "bestander@gmail.com" 29 | }, 30 | "maintainers": [ 31 | { 32 | "name": "bestander", 33 | "email": "bestander@gmail.com" 34 | } 35 | ], 36 | "directories": {}, 37 | "_shasum": "8a0168a8b6615fd935f9a25aade6b174b24cab34", 38 | "_resolved": "https://registry.npmjs.org/box2dweb-commonjs/-/box2dweb-commonjs-2.1.0.tgz", 39 | "_from": "box2dweb-commonjs@latest" 40 | } 41 | -------------------------------------------------------------------------------- /packages/Box2D/README.MD: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * 1.Package name mush same as panel name, such as 'Box2D' and 'Box2D.panel'. 4 | * 2.Message name mush be foo-bar type, like 'main-panel:open', if you use 'main:open', it would be error. 5 | * 3.'dom-module id' mush be foo-bar type, like 'box2d-creator'. 6 | */ 7 | 8 |