Merge branch 'master' of https://github.com/Leo501/CocosCreatorTutorial
@@ -1,14 +1,6 @@
|
||||
# 模拟球弹跳
|
||||
|
||||
* 定义两个变量,一个speed,一个accelerate。
|
||||
* 设置 ball 与 ground 为BoxCollider。检测下落碰撞,设置speed为defaultSpeed
|
||||
* 在update中设置代码
|
||||
~~~
|
||||
/**
|
||||
* 球运动计算
|
||||
*/
|
||||
drop() {
|
||||
this.node.y += this.speed;
|
||||
this.speed += this.accelerate;
|
||||
}
|
||||
~~~
|
||||
|
||||
|
||||
### 参考
|
||||
* http://gaozhongwuli.com/top/481764.html
|
||||
|
||||
407
BassFalling/assets/Scene/Sphere.fire
Normal file
@@ -0,0 +1,407 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.SceneAsset",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_rawFiles": null,
|
||||
"scene": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Scene",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_id": "c55dacfa-c727-4c84-858a-44fbdc7ec7d9",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0,
|
||||
"autoReleaseAssets": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Canvas",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 11
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "d4cUSAIHNEPpB8HhNrgn4i",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 480,
|
||||
"y": 320
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "background",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "d2Z0KoB+lEXrW9qf3paETF",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 27,
|
||||
"g": 38,
|
||||
"b": 46,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"isAlignOnce": true,
|
||||
"_target": null,
|
||||
"_alignFlags": 45,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 200,
|
||||
"_originalHeight": 150
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "410fb916-8721-4663-bab8-34397391ace7"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "ground",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "2c3YyW0hpAz79/x9nJ6Rtx",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 1
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 400,
|
||||
"height": 10
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": -150
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 2
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "sphere",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 8
|
||||
},
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "2aymuN3yNC+pxa9iNjvBDH",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 100
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "d7ad8rXjqJDiK+ZGh6avzpG",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_enabled": true,
|
||||
"accelerate": 500,
|
||||
"hight": 340,
|
||||
"direction": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Canvas",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_designResolution": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_fitWidth": false,
|
||||
"_fitHeight": true
|
||||
}
|
||||
]
|
||||
7
BassFalling/assets/Scene/Sphere.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "c55dacfa-c727-4c84-858a-44fbdc7ec7d9",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
91
BassFalling/assets/Script/SpheroFalling.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
export enum Direction {
|
||||
up = 1,
|
||||
down = 2
|
||||
};
|
||||
|
||||
@ccclass
|
||||
export default class SpheroFalling extends cc.Component {
|
||||
|
||||
@property
|
||||
accelerate: number = 10;
|
||||
|
||||
@property
|
||||
hight: number = 0;
|
||||
|
||||
@property({ type: cc.Enum(Direction) })
|
||||
direction: Direction = Direction.down;
|
||||
|
||||
speed = 0;
|
||||
curTime = 0;
|
||||
startSpeed = 0;
|
||||
finallySpeed = 0;
|
||||
finishTime = 0;
|
||||
|
||||
onLoad() {
|
||||
|
||||
}
|
||||
|
||||
start() {
|
||||
this.finishTime = this.computeTime(this.hight, this.accelerate);
|
||||
this.finallySpeed = this.computeFinallySpeed(this.finishTime, this.accelerate);
|
||||
}
|
||||
|
||||
computeTime(h: number, g: number) {
|
||||
let result = (h * 2) / g;
|
||||
return Math.sqrt(result);
|
||||
}
|
||||
|
||||
computeFinallySpeed(time, g) {
|
||||
return time * g;
|
||||
}
|
||||
|
||||
computeDistance(t, a) {
|
||||
if (this.direction == Direction.down) {
|
||||
return -(t * t * a) / 2;
|
||||
} else {
|
||||
let temp1 = this.finallySpeed * t;
|
||||
let temp2 = (t * t * a) / 2;
|
||||
return temp1 - temp2;
|
||||
}
|
||||
}
|
||||
|
||||
onMoveY(time) {
|
||||
let p = this.computeDistance(time, this.accelerate);
|
||||
if (this.direction == Direction.down) {
|
||||
this.node.y = this.hight + p;
|
||||
} else {
|
||||
this.node.y = 0 + p;
|
||||
}
|
||||
}
|
||||
|
||||
judgeDirection(y) {
|
||||
if (y <= 0.01) {
|
||||
if (this.direction == Direction.up) return;
|
||||
this.direction = Direction.up;
|
||||
this.curTime = 0;
|
||||
} else if (Math.abs(y - this.hight) < 0.01) {
|
||||
if (this.direction == Direction.down) return;
|
||||
this.direction = Direction.down;
|
||||
this.curTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
checkBorder(time) {
|
||||
if (time > this.finishTime) {
|
||||
return this.finishTime;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
update(dt) {
|
||||
console.log('update', dt);
|
||||
this.curTime += dt;
|
||||
this.curTime = this.checkBorder(this.curTime);
|
||||
console.log('y', this.node.y);
|
||||
this.onMoveY(this.curTime);
|
||||
this.judgeDirection(this.node.y);
|
||||
}
|
||||
}
|
||||
9
BassFalling/assets/Script/SpheroFalling.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "d7ad8ad7-8ea2-4388-af99-1a1e9abf3a46",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"ver": "1.0.0",
|
||||
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"HelloWorld": {
|
||||
"ver": "1.0.3",
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"ver": "1.0.0",
|
||||
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"singleColor": {
|
||||
"ver": "1.0.3",
|
||||
|
||||
@@ -24,16 +24,6 @@
|
||||
"design-resolution-height": 640,
|
||||
"design-resolution-width": 960,
|
||||
"excluded-modules": [],
|
||||
"facebook": {
|
||||
"appID": "",
|
||||
"audience": {
|
||||
"enable": false
|
||||
},
|
||||
"enable": false,
|
||||
"live": {
|
||||
"enable": false
|
||||
}
|
||||
},
|
||||
"fit-height": true,
|
||||
"fit-width": false,
|
||||
"group-list": [
|
||||
@@ -41,12 +31,12 @@
|
||||
"ball",
|
||||
"ground"
|
||||
],
|
||||
"last-module-event-record-time": 0,
|
||||
"simulator-orientation": false,
|
||||
"simulator-resolution": {
|
||||
"height": 640,
|
||||
"width": 960
|
||||
},
|
||||
"use-customize-simulator": false,
|
||||
"use-project-simulator-setting": false
|
||||
"use-project-simulator-setting": false,
|
||||
"start-scene": "current"
|
||||
}
|
||||
67
BigNumber64Demo/.gitignore
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Fireball Projects
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
library/
|
||||
temp/
|
||||
local/
|
||||
build/
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Logs and databases
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# files for debugger
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.sln
|
||||
*.csproj
|
||||
*.pidb
|
||||
*.unityproj
|
||||
*.suo
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# OS generated files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# exvim files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*UnityVS.meta
|
||||
*.err
|
||||
*.err.meta
|
||||
*.exvim
|
||||
*.exvim.meta
|
||||
*.vimentry
|
||||
*.vimentry.meta
|
||||
*.vimproject
|
||||
*.vimproject.meta
|
||||
.vimfiles.*/
|
||||
.exvim.*/
|
||||
quick_gen_project_*_autogen.bat
|
||||
quick_gen_project_*_autogen.bat.meta
|
||||
quick_gen_project_*_autogen.sh
|
||||
quick_gen_project_*_autogen.sh.meta
|
||||
.exvim.app
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# webstorm files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.idea/
|
||||
|
||||
#//////////////////////////
|
||||
# VS Code
|
||||
#//////////////////////////
|
||||
|
||||
.vscode/
|
||||
37
BigNumber64Demo/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# BigNumber64Demo
|
||||
> 介绍如何在 javascript 处理64位大数。
|
||||
### 方案1
|
||||
[long.js](https://github.com/dcodeIO/long.js) 库
|
||||
##### 介绍
|
||||
A Long class for representing a 64 bit two's-complement integer value derived from the Closure Library for stand-alone use and extended with unsigned support.
|
||||
|
||||
##### 简单使用
|
||||
~~~
|
||||
var Long = require("long");
|
||||
|
||||
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
|
||||
|
||||
console.log(longVal.toString());
|
||||
~~~
|
||||
|
||||
##### 优势
|
||||
* 可以把服务器发过来的高位、底位数据合成一个大数。显示,+、-、*、/、。
|
||||
|
||||
### 方案2
|
||||
[bignumber.js](https://github.com/alexbardas/bignumber.js) 库
|
||||
##### 介绍
|
||||
BigNumber.js is a light javascript library for node.js and the browser. It supports arithmetic operations on Big Integers.
|
||||
|
||||
It is build with performance in mind, uses the fastest algorithms and supports all basic arithmetic operations (+, -, *, /, %, ^, abs). Works with both positive and negative big integers.
|
||||
|
||||
##### 简单介绍
|
||||
~~~
|
||||
var BigNumber = require('big-number');
|
||||
|
||||
BigNumber(5).plus(97).minus(53).plus(434).multiply(5435423).add(321453).multiply(21).div(2).pow(2);
|
||||
// 760056543044267246001
|
||||
~~~
|
||||
|
||||
##### 优势
|
||||
* 支持add/plus, minus/subtract, multiply/mult, divide/div, power/pow, mod, equals, lt, lte, gt, gte, isZero, abs
|
||||
|
||||
6
BigNumber64Demo/assets/Scene.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
368
BigNumber64Demo/assets/Scene/helloworld.fire
Normal file
@@ -0,0 +1,368 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.SceneAsset",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_rawFiles": null,
|
||||
"scene": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Scene",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_parent": null,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_ignoreAnchorPointForPosition": false,
|
||||
"_tag": -1,
|
||||
"_opacityModifyRGB": false,
|
||||
"_id": "2d2f792f-a40c-49bb-a189-ed176a246e49"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Canvas",
|
||||
"_objFlags": 0,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 252,
|
||||
"g": 252,
|
||||
"b": 252,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 480,
|
||||
"y": 320
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_ignoreAnchorPointForPosition": false,
|
||||
"_tag": -1,
|
||||
"_opacityModifyRGB": false,
|
||||
"_id": "a286bbGknJLZpRpxROV6M94",
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 11
|
||||
}
|
||||
],
|
||||
"_prefab": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "background",
|
||||
"_objFlags": 0,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 27,
|
||||
"g": 38,
|
||||
"b": 46,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_children": [],
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_ignoreAnchorPointForPosition": false,
|
||||
"_tag": -1,
|
||||
"_opacityModifyRGB": false,
|
||||
"_id": "e2e0crkOLxGrpMxpbC4iQg1",
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_prefab": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"_alignFlags": 45,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_originalWidth": 200,
|
||||
"_originalHeight": 150
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "410fb916-8721-4663-bab8-34397391ace7"
|
||||
},
|
||||
"_type": 1,
|
||||
"_useOriginalSize": false,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "cocos",
|
||||
"_objFlags": 0,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 195,
|
||||
"height": 270
|
||||
},
|
||||
"_children": [],
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 50
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_ignoreAnchorPointForPosition": false,
|
||||
"_tag": -1,
|
||||
"_opacityModifyRGB": false,
|
||||
"_id": "c4f30YOS65G64U2TwufdJ+2",
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_prefab": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc"
|
||||
},
|
||||
"_type": 0,
|
||||
"_useOriginalSize": true,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "label",
|
||||
"_objFlags": 0,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 492,
|
||||
"height": 112
|
||||
},
|
||||
"_children": [],
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": -180
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_ignoreAnchorPointForPosition": false,
|
||||
"_tag": -1,
|
||||
"_opacityModifyRGB": false,
|
||||
"_id": "31f1bH7V69Ajr1iXhluMpTB",
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 8
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
"_fontSize": 60,
|
||||
"_lineHeight": 60,
|
||||
"_enableWrapText": true,
|
||||
"_isSystemFontUsed": true,
|
||||
"_N$string": "Label",
|
||||
"_N$horizontalAlign": 1,
|
||||
"_N$verticalAlign": 1,
|
||||
"_N$overflow": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Canvas",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_designResolution": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_fitWidth": false,
|
||||
"_fitHeight": true
|
||||
},
|
||||
{
|
||||
"__type__": "280c3rsZJJKnZ9RqbALVwtK",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"label": {
|
||||
"__id__": 9
|
||||
},
|
||||
"text": "Hello, World!"
|
||||
}
|
||||
]
|
||||
7
BigNumber64Demo/assets/Scene/helloworld.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
BigNumber64Demo/assets/Script.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
22
BigNumber64Demo/assets/Script/HelloWorld.js
Normal file
@@ -0,0 +1,22 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
label: {
|
||||
default: null,
|
||||
type: cc.Label
|
||||
},
|
||||
// defaults, set visually when attaching this script to the Canvas
|
||||
text: 'Hello, World!'
|
||||
},
|
||||
|
||||
// use this for initialization
|
||||
onLoad: function () {
|
||||
this.label.string = this.text;
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
9
BigNumber64Demo/assets/Script/HelloWorld.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
5
BigNumber64Demo/assets/Script/libs.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "94d574ff-9875-4cb1-a36d-07c01b4e4092",
|
||||
"subMetas": {}
|
||||
}
|
||||
432
BigNumber64Demo/assets/Script/libs/bignumber.js
Normal file
@@ -0,0 +1,432 @@
|
||||
/**
|
||||
* big-number.js -> Arithmetic operations on big integers
|
||||
* Pure javascript implementation, no external libraries needed
|
||||
* Copyright(c) 2012-2018 Alex Bardas <alex.bardas@gmail.com>
|
||||
* MIT Licensed
|
||||
* It supports the following operations:
|
||||
* addition, subtraction, multiplication, division, power, absolute value
|
||||
* It works with both positive and negative integers
|
||||
*/
|
||||
|
||||
!(function() {
|
||||
'use strict';
|
||||
|
||||
// Helper function which tests if a given character is a digit
|
||||
var testDigit = function(digit) {
|
||||
return (/^\d$/.test(digit));
|
||||
};
|
||||
|
||||
// Helper function which returns the absolute value of a given number
|
||||
var abs = function(number) {
|
||||
var bigNumber;
|
||||
if (typeof number === 'undefined') {
|
||||
return;
|
||||
}
|
||||
bigNumber = BigNumber(number);
|
||||
bigNumber.sign = 1;
|
||||
return bigNumber;
|
||||
};
|
||||
|
||||
// Check if argument is valid array
|
||||
var isArray = function(arg) {
|
||||
return Object.prototype.toString.call(arg) === '[object Array]';
|
||||
};
|
||||
|
||||
var isValidType = function(number) {
|
||||
return [
|
||||
typeof number === 'number',
|
||||
typeof number === 'string' && number.length > 0,
|
||||
isArray(number) && number.length > 0,
|
||||
number instanceof BigNumber
|
||||
].some(function(bool) {
|
||||
return bool === true;
|
||||
});
|
||||
};
|
||||
|
||||
var errors = {
|
||||
'invalid': 'Invalid Number',
|
||||
'division by zero': 'Invalid Number - Division By Zero'
|
||||
};
|
||||
|
||||
// Constructor function which creates a new BigNumber object
|
||||
// from an integer, a string, an array or other BigNumber object
|
||||
function BigNumber(initialNumber) {
|
||||
var index;
|
||||
|
||||
if (!(this instanceof BigNumber)) {
|
||||
return new BigNumber(initialNumber);
|
||||
}
|
||||
|
||||
this.number = [];
|
||||
this.sign = 1;
|
||||
this.rest = 0;
|
||||
|
||||
// The initial number can be an array, string, number of another big number
|
||||
// e.g. array : [3,2,1], ['+',3,2,1], ['-',3,2,1]
|
||||
// number : 312
|
||||
// string : '321', '+321', -321'
|
||||
// BigNumber : BigNumber(321)
|
||||
// Every character except the first must be a digit
|
||||
|
||||
if (!isValidType(initialNumber)) {
|
||||
this.number = errors['invalid'];
|
||||
return;
|
||||
}
|
||||
|
||||
if (isArray(initialNumber)) {
|
||||
if (initialNumber.length && initialNumber[0] === '-' || initialNumber[0] === '+') {
|
||||
this.sign = initialNumber[0] === '+' ? 1 : -1;
|
||||
initialNumber.shift(0);
|
||||
}
|
||||
for (index = initialNumber.length - 1; index >= 0; index--) {
|
||||
if (!this.addDigit(initialNumber[index]))
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
initialNumber = initialNumber.toString();
|
||||
if (initialNumber.charAt(0) === '-' || initialNumber.charAt(0) === '+') {
|
||||
this.sign = initialNumber.charAt(0) === '+' ? 1 : -1;
|
||||
initialNumber = initialNumber.substring(1);
|
||||
}
|
||||
|
||||
for (index = initialNumber.length - 1; index >= 0; index--) {
|
||||
if (!this.addDigit(parseInt(initialNumber.charAt(index), 10))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BigNumber.prototype.addDigit = function(digit) {
|
||||
if (testDigit(digit)) {
|
||||
this.number.push(digit);
|
||||
} else {
|
||||
this.number = errors['invalid'];
|
||||
return false;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
BigNumber.prototype.isEven = function() {
|
||||
return this.number[0] % 2 === 0;
|
||||
};
|
||||
|
||||
// returns:
|
||||
// null if this.number is not a number
|
||||
// 0 if this.number === number
|
||||
// -1 if this.number < number
|
||||
// 1 if this.number > number
|
||||
BigNumber.prototype._compare = function(number) {
|
||||
var bigNumber;
|
||||
var index;
|
||||
|
||||
if (!isValidType(number)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
bigNumber = BigNumber(number);
|
||||
|
||||
// If the numbers have different signs, then the positive
|
||||
// number is greater
|
||||
if (this.sign !== bigNumber.sign) {
|
||||
return this.sign;
|
||||
}
|
||||
|
||||
// Else, check the length
|
||||
if (this.number.length > bigNumber.number.length) {
|
||||
return this.sign;
|
||||
} else if (this.number.length < bigNumber.number.length) {
|
||||
return this.sign * (-1);
|
||||
}
|
||||
|
||||
// If they have similar length, compare the numbers
|
||||
// digit by digit
|
||||
for (index = this.number.length - 1; index >= 0; index--) {
|
||||
if (this.number[index] > bigNumber.number[index]) {
|
||||
return this.sign;
|
||||
} else if (this.number[index] < bigNumber.number[index]) {
|
||||
return this.sign * (-1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
// Greater than
|
||||
BigNumber.prototype.gt = function(number) {
|
||||
return this._compare(number) > 0;
|
||||
};
|
||||
|
||||
// Greater than or equal
|
||||
BigNumber.prototype.gte = function(number) {
|
||||
return this._compare(number) >= 0;
|
||||
};
|
||||
|
||||
// this.number equals n
|
||||
BigNumber.prototype.equals = function(number) {
|
||||
return this._compare(number) === 0;
|
||||
};
|
||||
|
||||
// Less than or equal
|
||||
BigNumber.prototype.lte = function(number) {
|
||||
return this._compare(number) <= 0;
|
||||
};
|
||||
|
||||
// Less than
|
||||
BigNumber.prototype.lt = function(number) {
|
||||
return this._compare(number) < 0;
|
||||
};
|
||||
|
||||
// Addition
|
||||
BigNumber.prototype.add = function(number) {
|
||||
var bigNumber;
|
||||
if (typeof number === 'undefined') {
|
||||
return this;
|
||||
}
|
||||
bigNumber = BigNumber(number);
|
||||
|
||||
if (this.sign !== bigNumber.sign) {
|
||||
if (this.sign > 0) {
|
||||
bigNumber.sign = 1;
|
||||
return this.minus(bigNumber);
|
||||
}
|
||||
else {
|
||||
this.sign = 1;
|
||||
return bigNumber.minus(this);
|
||||
}
|
||||
}
|
||||
|
||||
this.number = BigNumber._add(this, bigNumber);
|
||||
return this;
|
||||
};
|
||||
|
||||
// Subtraction
|
||||
BigNumber.prototype.subtract = function(number) {
|
||||
var bigNumber;
|
||||
if (typeof number === 'undefined') {
|
||||
return this;
|
||||
}
|
||||
bigNumber = BigNumber(number);
|
||||
|
||||
if (this.sign !== bigNumber.sign) {
|
||||
this.number = BigNumber._add(this, bigNumber);
|
||||
return this;
|
||||
}
|
||||
|
||||
// If current number is lesser than the given bigNumber, the result will be negative
|
||||
this.sign = (this.lt(bigNumber)) ? -1 : 1;
|
||||
this.number = (abs(this).lt(abs(bigNumber)))
|
||||
? BigNumber._subtract(bigNumber, this)
|
||||
: BigNumber._subtract(this, bigNumber);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// adds two positive BigNumbers
|
||||
BigNumber._add = function(a, b) {
|
||||
var index;
|
||||
var remainder = 0;
|
||||
var length = Math.max(a.number.length, b.number.length);
|
||||
|
||||
for (index = 0; index < length || remainder > 0; index++) {
|
||||
a.number[index] = (remainder += (a.number[index] || 0) + (b.number[index] || 0)) % 10;
|
||||
remainder = Math.floor(remainder / 10);
|
||||
}
|
||||
|
||||
return a.number;
|
||||
};
|
||||
|
||||
// a - b
|
||||
// a and b are 2 positive BigNumbers and a > b
|
||||
BigNumber._subtract = function(a, b) {
|
||||
var index;
|
||||
var remainder = 0;
|
||||
var length = a.number.length;
|
||||
|
||||
for (index = 0; index < length; index++) {
|
||||
a.number[index] -= (b.number[index] || 0) + remainder;
|
||||
a.number[index] += (remainder = (a.number[index] < 0) ? 1 : 0) * 10;
|
||||
}
|
||||
// Count the zeroes which will be removed
|
||||
index = 0;
|
||||
length = a.number.length - 1;
|
||||
while (a.number[length - index] === 0 && length - index > 0) {
|
||||
index++;
|
||||
}
|
||||
if (index > 0) {
|
||||
a.number.splice(-index);
|
||||
}
|
||||
return a.number;
|
||||
};
|
||||
|
||||
// this.number * number
|
||||
BigNumber.prototype.multiply = function(number) {
|
||||
if (typeof number === 'undefined') {
|
||||
return this;
|
||||
}
|
||||
var bigNumber = BigNumber(number);
|
||||
var index;
|
||||
var givenNumberIndex;
|
||||
var remainder = 0;
|
||||
var result = [];
|
||||
|
||||
if (this.isZero() || bigNumber.isZero()) {
|
||||
return BigNumber(0);
|
||||
}
|
||||
|
||||
this.sign *= bigNumber.sign;
|
||||
|
||||
// multiply the numbers
|
||||
for (index = 0; index < this.number.length; index++) {
|
||||
for (remainder = 0, givenNumberIndex = 0; givenNumberIndex < bigNumber.number.length || remainder > 0; givenNumberIndex++) {
|
||||
result[index + givenNumberIndex] = (remainder += (result[index + givenNumberIndex] || 0) + this.number[index] * (bigNumber.number[givenNumberIndex] || 0)) % 10;
|
||||
remainder = Math.floor(remainder / 10);
|
||||
}
|
||||
}
|
||||
|
||||
this.number = result;
|
||||
return this;
|
||||
};
|
||||
|
||||
// this.number / number
|
||||
BigNumber.prototype.divide = function(number) {
|
||||
if (typeof number === 'undefined') {
|
||||
return this;
|
||||
}
|
||||
|
||||
var bigNumber = BigNumber(number);
|
||||
var index;
|
||||
var length;
|
||||
var result = [];
|
||||
var rest = BigNumber(0);
|
||||
|
||||
// test if one of the numbers is zero
|
||||
if (bigNumber.isZero()) {
|
||||
this.number = errors['division by zero'];
|
||||
return this;
|
||||
} else if (this.isZero()) {
|
||||
this.rest = BigNumber(0);
|
||||
return this;
|
||||
}
|
||||
|
||||
this.sign *= bigNumber.sign;
|
||||
bigNumber.sign = 1;
|
||||
|
||||
// Skip division by 1
|
||||
if (bigNumber.number.length === 1 && bigNumber.number[0] === 1) {
|
||||
this.rest = BigNumber(0);
|
||||
return this;
|
||||
}
|
||||
|
||||
for (index = this.number.length - 1; index >= 0; index--) {
|
||||
rest.multiply(10);
|
||||
rest.number[0] = this.number[index];
|
||||
result[index] = 0;
|
||||
while (bigNumber.lte(rest)) {
|
||||
result[index]++;
|
||||
rest.subtract(bigNumber);
|
||||
}
|
||||
}
|
||||
|
||||
index = 0;
|
||||
length = result.length - 1;
|
||||
while (result[length - index] === 0 && length - index > 0) {
|
||||
index++;
|
||||
}
|
||||
if (index > 0) {
|
||||
result.splice(-index);
|
||||
}
|
||||
|
||||
this.rest = rest;
|
||||
this.number = result;
|
||||
return this;
|
||||
};
|
||||
|
||||
// this.number % number
|
||||
BigNumber.prototype.mod = function(number) {
|
||||
return this.divide(number).rest;
|
||||
};
|
||||
|
||||
BigNumber.prototype.power = function(number) {
|
||||
if (typeof number === 'undefined')
|
||||
return;
|
||||
var bigNumber;
|
||||
var bigNumberPower;
|
||||
// Convert the argument to a big number
|
||||
if (!isValidType(number)) {
|
||||
this.number = errors['invalid'];
|
||||
return;
|
||||
}
|
||||
bigNumberPower = BigNumber(number);
|
||||
if (bigNumberPower.isZero()) {
|
||||
return BigNumber(1);
|
||||
}
|
||||
if (bigNumberPower.val() === '1') {
|
||||
return this;
|
||||
}
|
||||
|
||||
bigNumber = BigNumber(this);
|
||||
|
||||
this.number = [1];
|
||||
while (bigNumberPower.gt(0)) {
|
||||
if (!bigNumberPower.isEven()) {
|
||||
this.multiply(bigNumber);
|
||||
bigNumberPower.subtract(1);
|
||||
continue;
|
||||
}
|
||||
bigNumber.multiply(bigNumber);
|
||||
bigNumberPower.div(2);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// |this.number|
|
||||
BigNumber.prototype.abs = function() {
|
||||
this.sign = 1;
|
||||
return this;
|
||||
};
|
||||
|
||||
// Check if this.number is equal to 0
|
||||
BigNumber.prototype.isZero = function() {
|
||||
var index;
|
||||
for (index = 0; index < this.number.length; index++) {
|
||||
if (this.number[index] !== 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// this.number.toString()
|
||||
BigNumber.prototype.toString = function() {
|
||||
var index;
|
||||
var str = '';
|
||||
if (typeof this.number === 'string') {
|
||||
return this.number;
|
||||
}
|
||||
|
||||
for (index = this.number.length - 1; index >= 0; index--) {
|
||||
str += this.number[index];
|
||||
}
|
||||
|
||||
return (this.sign > 0) ? str : ('-' + str);
|
||||
};
|
||||
|
||||
// Use shorcuts for functions names
|
||||
BigNumber.prototype.plus = BigNumber.prototype.add;
|
||||
BigNumber.prototype.minus = BigNumber.prototype.subtract;
|
||||
BigNumber.prototype.div = BigNumber.prototype.divide;
|
||||
BigNumber.prototype.mult = BigNumber.prototype.multiply;
|
||||
BigNumber.prototype.pow = BigNumber.prototype.power;
|
||||
BigNumber.prototype.val = BigNumber.prototype.toString;
|
||||
|
||||
// CommonJS
|
||||
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||
module.exports = BigNumber;
|
||||
} else if (typeof window !== 'undefined') {
|
||||
window.BigNumber = BigNumber;
|
||||
}
|
||||
})();
|
||||
9
BigNumber64Demo/assets/Script/libs/bignumber.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "c8022bc5-283a-4bdc-ad83-0cd80ee9e648",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
1405
BigNumber64Demo/assets/Script/libs/long.js
Normal file
9
BigNumber64Demo/assets/Script/libs/long.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "d495a67e-8f57-4dfb-9d2f-4e2565cee8d0",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
BigNumber64Demo/assets/Texture.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
BIN
BigNumber64Demo/assets/Texture/HelloWorld.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
30
BigNumber64Demo/assets/Texture/HelloWorld.png.meta
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"subMetas": {
|
||||
"HelloWorld": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
|
||||
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 195,
|
||||
"height": 270,
|
||||
"rawWidth": 195,
|
||||
"rawHeight": 270,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
BigNumber64Demo/assets/Texture/singleColor.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
30
BigNumber64Demo/assets/Texture/singleColor.png.meta
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"subMetas": {
|
||||
"singleColor": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
|
||||
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 2,
|
||||
"height": 2,
|
||||
"rawWidth": 2,
|
||||
"rawHeight": 2,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
20635
BigNumber64Demo/creator.d.ts
vendored
Normal file
15
BigNumber64Demo/jsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode",
|
||||
"library",
|
||||
"local",
|
||||
"settings",
|
||||
"temp"
|
||||
]
|
||||
}
|
||||
4
BigNumber64Demo/project.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"engine": "cocos2d-html5",
|
||||
"packages": "packages"
|
||||
}
|
||||
13
BigNumber64Demo/settings/builder.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"orientation": {
|
||||
"landscapeLeft": true,
|
||||
"landscapeRight": true,
|
||||
"portrait": false,
|
||||
"upsideDown": false
|
||||
},
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "hello_world",
|
||||
"webOrientation": "auto"
|
||||
}
|
||||
7
BigNumber64Demo/settings/builder.panel.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"platform": "web-mobile",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "HelloWorld"
|
||||
}
|
||||
28
BigNumber64Demo/settings/project.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"collision-matrix": [
|
||||
[
|
||||
true
|
||||
]
|
||||
],
|
||||
"excluded-modules": [],
|
||||
"group-list": [
|
||||
"default"
|
||||
],
|
||||
"start-scene": "current",
|
||||
"design-resolution-width": 960,
|
||||
"design-resolution-height": 640,
|
||||
"fit-width": false,
|
||||
"fit-height": true,
|
||||
"use-project-simulator-setting": false,
|
||||
"simulator-orientation": false,
|
||||
"use-customize-simulator": false,
|
||||
"simulator-resolution": {
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"cocos-analytics": {
|
||||
"enable": false,
|
||||
"appID": "13798",
|
||||
"appSecret": "959b3ac0037d0f3c2fdce94f8421a9b2"
|
||||
}
|
||||
}
|
||||
BIN
BigNumber64Demo/template-banner.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
5
BigNumber64Demo/template.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "TEMPLATES.helloworld.name",
|
||||
"desc": "TEMPLATES.helloworld.desc",
|
||||
"banner": "template-banner.png"
|
||||
}
|
||||
@@ -11,7 +11,7 @@ cc.Class({
|
||||
onLoad() {
|
||||
this.halfBoxLength = parseInt(this.boxLength / 2);
|
||||
this.perimeter = 0;
|
||||
this.perimeterMax = 1000 + 500 * Math.PI;
|
||||
this.perimeterMax = this.boxLength * 2 + this.r * 2 * Math.PI;
|
||||
},
|
||||
|
||||
registerEvent() {
|
||||
@@ -21,11 +21,12 @@ cc.Class({
|
||||
|
||||
},
|
||||
/**
|
||||
* 定义
|
||||
* 0到500为右直线
|
||||
* 500到500+PI*r为上半圆
|
||||
* 500+PI*r到1000+PI*r为左直线
|
||||
* 最后1000+2PI*4为下半圆
|
||||
* 原理:距离s=时间t*速度v
|
||||
* 实现 -- 分割为四部分
|
||||
* 第一部分 -- 0到500为右直线
|
||||
* 第二部分 -- 500到500+PI*r为上半圆
|
||||
* 第三部分 -- 500+PI*r到1000+PI*r为左直线
|
||||
* 第四部分 -- 最后1000+2PI*4为下半圆
|
||||
* @param {*} dt
|
||||
* @param {*} speed
|
||||
*/
|
||||
@@ -35,7 +36,7 @@ cc.Class({
|
||||
let point = cc.v2(0, 0);
|
||||
if (this.perimeter <= this.boxLength) {
|
||||
point.x = this.r;
|
||||
point.y = -250 + this.perimeter;
|
||||
point.y = -this.halfBoxLength + this.perimeter;
|
||||
} else if (this.perimeter <= (this.boxLength + Math.PI * this.r)) {
|
||||
let length = this.perimeter - this.boxLength;
|
||||
let radian = length / this.r;
|
||||
@@ -43,7 +44,7 @@ cc.Class({
|
||||
point.y = this.halfBoxLength + this.r * Math.sin(radian);
|
||||
} else if (this.perimeter <= (2 * this.boxLength + Math.PI * this.r)) {
|
||||
point.x = -this.r;
|
||||
point.y = 250 - (this.perimeter - this.boxLength - Math.PI * this.r);
|
||||
point.y = this.halfBoxLength - (this.perimeter - this.boxLength - Math.PI * this.r);
|
||||
} else {
|
||||
let length = this.perimeter - 2 * this.boxLength;
|
||||
let radian = length / this.r;
|
||||
@@ -53,42 +54,6 @@ cc.Class({
|
||||
return point;
|
||||
},
|
||||
|
||||
getTrackByPoint(point, length) {
|
||||
console.log('getTrackByPoint');
|
||||
// point.x = Math.floor(point.x);
|
||||
// point.y = Math.floor(point.y);
|
||||
//效正由于半圆带来偏差
|
||||
if (point.x > this.r) {
|
||||
point.x = this.r;
|
||||
} else if (point.x < -this.r) {
|
||||
point.x = -this.r;
|
||||
}
|
||||
console.log(Math.abs(point.y) <= this.halfBoxLength, point.x == this.r);
|
||||
//box的右边轨道
|
||||
if (point.x == this.r && Math.abs(point.y) <= this.halfBoxLength) {
|
||||
point.y += length;
|
||||
return point;
|
||||
//box的上半圆
|
||||
} else if (Math.abs(point.x) <= this.r && point.y >= this.halfBoxLength) {
|
||||
//弧度
|
||||
let radian = length / this.r;
|
||||
point.x = this.r * Math.cos(radian);
|
||||
point.y = this.halfBoxLength + this.r * Math.sin(radian);
|
||||
return point;
|
||||
//左边
|
||||
} else if (point.x == -this.r && Math.abs(point.y) <= this.halfBoxLength) {
|
||||
point.y -= length;
|
||||
return point;
|
||||
//下半圆
|
||||
} else if (Math.abs(point.x) < this.r && point.y <= - this.halfBoxLength) {
|
||||
//弧度
|
||||
let radian = length / this.r;
|
||||
point.x = this.r * Math.cos(radian);
|
||||
point.y = -this.halfBoxLength - this.r * Math.sin(radian);
|
||||
return point;
|
||||
}
|
||||
},
|
||||
|
||||
update(dt) {
|
||||
// let point = this.nodeTarget.getPosition();
|
||||
let movePoint = this.getPointByPerimeter(dt, this.speed);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"ver": "1.0.0",
|
||||
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"HelloWorld": {
|
||||
"ver": "1.0.3",
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"ver": "1.0.0",
|
||||
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"singleColor": {
|
||||
"ver": "1.0.3",
|
||||
|
||||
76
HorseRaceLamp/assets/RollingMachine.js
Normal file
@@ -0,0 +1,76 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
list: [cc.Node],
|
||||
loopTimes: 4,
|
||||
awardTime: 1,
|
||||
loopTimeList: [cc.Float]
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.flickerTime = 0.15;
|
||||
// this.loopTimeList = [0.04, 0.04, 0.12, 0.2, 0.2];
|
||||
},
|
||||
|
||||
registerEvent() {
|
||||
|
||||
},
|
||||
|
||||
init(data) {
|
||||
|
||||
},
|
||||
|
||||
play(index, fn) {
|
||||
let seqList = [], len = this.list.length, i = 0, deltaTime = 0;
|
||||
let realTimes = len * this.loopTimes + index;
|
||||
for (i = 0; i <= realTimes; i++) {
|
||||
if (realTimes - i < 3) {
|
||||
deltaTime += this.loopTimeList[this.loopTimeList.length - 1];
|
||||
}
|
||||
let item = this.list[i % len];
|
||||
seqList.push(this.createAction(item, this.loopTimeList[Math.floor(i / len)] + deltaTime, true));
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
let item = this.list[index];
|
||||
seqList.push(this.createAction(item, this.flickerTime, false));
|
||||
seqList.push(cc.delayTime(this.flickerTime));
|
||||
}
|
||||
|
||||
seqList.push(cc.delayTime(this.awardTime));
|
||||
seqList.push(cc.callFunc(() => {
|
||||
fn && fn();
|
||||
}));
|
||||
|
||||
this.node.runAction(cc.sequence(seqList));
|
||||
},
|
||||
|
||||
createAction(item, time, isShow) {
|
||||
let seq = cc.sequence(cc.callFunc((data) => {
|
||||
item.active = isShow;
|
||||
}), cc.delayTime(time), cc.callFunc((data) => {
|
||||
item.active = !isShow;
|
||||
}));
|
||||
return seq;
|
||||
},
|
||||
|
||||
update(dt) {
|
||||
|
||||
},
|
||||
|
||||
onEnable() {
|
||||
this.registerEvent();
|
||||
},
|
||||
|
||||
onDisable() {
|
||||
this.offEvent();
|
||||
},
|
||||
|
||||
offEvent() {
|
||||
cc.emitter.offThis(this);
|
||||
},
|
||||
|
||||
onDestroy() {
|
||||
|
||||
}
|
||||
});
|
||||
9
HorseRaceLamp/assets/RollingMachine.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "1d222780-1af2-440a-8e0b-749bd8755e19",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
1445
HorseRaceLamp/assets/SlotMachine.fire
Normal file
7
HorseRaceLamp/assets/SlotMachine.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "31bca123-0de6-409a-94d8-28d1b2634535",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
44
HorseRaceLamp/assets/SlotMachine.js
Normal file
@@ -0,0 +1,44 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
rolling: cc.Node,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.rollingMachine = this.rolling.getComponent('RollingMachine');
|
||||
},
|
||||
|
||||
registerEvent() {
|
||||
|
||||
},
|
||||
|
||||
init(data) {
|
||||
|
||||
},
|
||||
|
||||
onEventClicked_play() {
|
||||
let index = 2
|
||||
this.rollingMachine.play(index);
|
||||
},
|
||||
|
||||
update(dt) {
|
||||
|
||||
},
|
||||
|
||||
onEnable() {
|
||||
this.registerEvent();
|
||||
},
|
||||
|
||||
onDisable() {
|
||||
this.offEvent();
|
||||
},
|
||||
|
||||
offEvent() {
|
||||
cc.emitter.offThis(this);
|
||||
},
|
||||
|
||||
onDestroy() {
|
||||
|
||||
}
|
||||
});
|
||||
9
HorseRaceLamp/assets/SlotMachine.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "1af8a771-dc51-43ab-a95f-2c295b365ef0",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
~~~
|
||||
npm install
|
||||
~~~
|
||||
安装Node的库
|
||||
安装Node的库 fs-jetpack 用于对文件操作
|
||||
|
||||
* 构建Android 工程 选择link模式
|
||||

|
||||
|
||||
@@ -24,7 +24,12 @@
|
||||
}
|
||||
//版本比最近版本等于or大于。需要清理热更新cache;
|
||||
if (versionCompareHandle(version, curVersion) >= 0) {
|
||||
hotUpdateSearchPaths && jsb.fileUtils.removeDirectory(hotUpdateSearchPaths);
|
||||
if (hotUpdateSearchPaths) {
|
||||
let list = JSON.parse(hotUpdateSearchPaths);
|
||||
list.forEach((path) => {
|
||||
jsb.fileUtils.removeDirectory(path);
|
||||
});
|
||||
}
|
||||
}
|
||||
//设置搜索路径
|
||||
if (window.cc && cc.sys.isNative) {
|
||||
|
||||
@@ -24,7 +24,12 @@
|
||||
}
|
||||
//版本比最近版本等于or大于。需要清理热更新cache;
|
||||
if (versionCompareHandle(version, curVersion) >= 0) {
|
||||
hotUpdateSearchPaths && jsb.fileUtils.removeDirectory(hotUpdateSearchPaths);
|
||||
if (hotUpdateSearchPaths) {
|
||||
let list = JSON.parse(hotUpdateSearchPaths);
|
||||
list.forEach((path) => {
|
||||
jsb.fileUtils.removeDirectory(path);
|
||||
});
|
||||
}
|
||||
}
|
||||
//设置搜索路径
|
||||
if (window.cc && cc.sys.isNative) {
|
||||
|
||||
@@ -24,7 +24,12 @@
|
||||
}
|
||||
//版本比最近版本等于or大于。需要清理热更新cache;
|
||||
if (versionCompareHandle(version, curVersion) >= 0) {
|
||||
hotUpdateSearchPaths && jsb.fileUtils.removeDirectory(hotUpdateSearchPaths);
|
||||
if (hotUpdateSearchPaths) {
|
||||
let list = JSON.parse(hotUpdateSearchPaths);
|
||||
list.forEach((path) => {
|
||||
jsb.fileUtils.removeDirectory(path);
|
||||
});
|
||||
}
|
||||
}
|
||||
//设置搜索路径
|
||||
if (window.cc && cc.sys.isNative) {
|
||||
|
||||
503
HotUpdateDemo/package-lock.json
generated
21
HotUpdateDemo/tools/BuildBeforeSetting.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const fileUtil = require('./FileUtil');
|
||||
let version, androidVersionXml;
|
||||
|
||||
function initParams(configPath) {
|
||||
let data = JSON.parse(fileUtil.read(configPath));
|
||||
version = data.version;
|
||||
androidVersionXml = data.root + 'frameworks/runtime-src/proj.android/AndroidManifest.xml';
|
||||
}
|
||||
|
||||
function repreatAndroidVersion(path) {
|
||||
let old = fileUtil.read(path);
|
||||
old = old.replace(/android:versionName="([1-9]\d|[1-9])(\.([1-9]\d|\d)){2}"/, `android:versionName="${version}"`);
|
||||
let result = Buffer.from(old);
|
||||
return fileUtil.write(path, result)
|
||||
}
|
||||
|
||||
function main(params) {
|
||||
initParams('./GameConfig.json');
|
||||
//修改android 版本号
|
||||
repreatAndroidVersion(androidVersionXml);
|
||||
}
|
||||
33
HotUpdateDemo/tools/CopyHotFiles.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const fileUtil = require('./FileUtil');
|
||||
|
||||
let hotUpdateRoot, hotUpdateDesRoot;
|
||||
//要复制的目录
|
||||
const targetDir = ['res', 'src'];
|
||||
|
||||
function initParams(configPath) {
|
||||
let data = JSON.parse(fileUtil.read(configPath));
|
||||
hotUpdateRoot = data.src;
|
||||
hotUpdateDesRoot = data.root + data.hotUpdateDirName;
|
||||
}
|
||||
|
||||
function forEachDir(list) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let item = list[i];
|
||||
let desPath = hotUpdateDesRoot + '/' + item;
|
||||
let srcPath = hotUpdateRoot + item;
|
||||
fileUtil.copyDir(srcPath, desPath);
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
initParams('./GameConfig.json');
|
||||
//消除目录文件
|
||||
fileUtil.checkDir(hotUpdateDesRoot);
|
||||
forEachDir(targetDir);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
|
||||
|
||||
|
||||
50
HotUpdateDemo/tools/ExportHotupdateDir.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const fileUtil = require('./FileUtil');
|
||||
|
||||
let hotUpdateRoot, hotUpdateFile, exportHotUpdateDir, version, packageUrl;
|
||||
const hotUpdateDir = 'hotUpdate', dirNameTemplate = 'hotUpdate-v', time = Date.parse(new Date()) / 1000;
|
||||
|
||||
function initParams(configPath) {
|
||||
let data = JSON.parse(fileUtil.read(configPath));
|
||||
hotUpdateRoot = data.src;
|
||||
hotUpdateFile = hotUpdateRoot + data.hotUpdateDirName;
|
||||
exportHotUpdateDir = hotUpdateRoot + data.hotupdateDirExport;
|
||||
version = data.version;
|
||||
packageUrl = data.packageUrl;
|
||||
}
|
||||
|
||||
function getVersion() {
|
||||
return version.replace(/\./g, '-');
|
||||
}
|
||||
|
||||
function reWritePackageUrl(dir, replaceName) {
|
||||
let desPath = dir;
|
||||
let game = fileUtil.read(desPath);
|
||||
let conf = JSON.parse(game);
|
||||
conf.packageUrl = conf.packageUrl.replace(hotUpdateDir, replaceName);
|
||||
fileUtil.write(desPath, JSON.stringify(conf));
|
||||
return conf.packageUrl;
|
||||
}
|
||||
|
||||
function main() {
|
||||
initParams('./GameConfig.json');
|
||||
const versionNo = getVersion(), dirName = `${dirNameTemplate}${versionNo}-${time}`;
|
||||
|
||||
//消除目录文件
|
||||
fileUtil.checkDir(exportHotUpdateDir);
|
||||
|
||||
let desPath = exportHotUpdateDir + '/' + dirName;
|
||||
//复制到新目录
|
||||
fileUtil.copyDir(hotUpdateFile, desPath);
|
||||
|
||||
//复制project.manifest/version.manifest
|
||||
fileUtil.copy(hotUpdateFile + '/project.manifest', exportHotUpdateDir + '/project.manifest');
|
||||
fileUtil.copy(hotUpdateFile + '/version.manifest', exportHotUpdateDir + '/version.manifest');
|
||||
//修改project.manifest 中的packageUrl为新资源
|
||||
reWritePackageUrl(exportHotUpdateDir + '/project.manifest', dirName);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
|
||||
|
||||
|
||||
143
HotUpdateDemo/tools/FileUtil.js
Normal file
@@ -0,0 +1,143 @@
|
||||
const jetpack = require('fs-jetpack');
|
||||
|
||||
/** 以下所有方法均为同步 **/
|
||||
//参考 https://www.npmjs.com/package/fs-jetpack#removepath
|
||||
|
||||
/**
|
||||
* 读取文件
|
||||
* @param {*} path
|
||||
* return string
|
||||
*/
|
||||
function read(path) {
|
||||
const data = jetpack.read(path);
|
||||
return data;
|
||||
}
|
||||
|
||||
function readDir(dir, fn) {
|
||||
if (jetpack.exists(dir) == 'dir') {
|
||||
let list = jetpack.list(dir);
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let name = list[i];
|
||||
if (name[0] === '.') continue;
|
||||
let subPath = jetpack.path(dir, name);
|
||||
if (jetpack.exists(subPath) == 'dir') {
|
||||
readDir(subPath, fn);
|
||||
} else if (jetpack.exists(subPath) == 'file') {
|
||||
fn && fn(subPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} path
|
||||
* @param {*} data String, Buffer, Object or Array
|
||||
*/
|
||||
function write(path, data) {
|
||||
jetpack.write(path, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得该路径 文件类型
|
||||
* @param {*} path
|
||||
* return
|
||||
* false if path doesn't exist.
|
||||
* "dir" if path is a directory.
|
||||
* "file" if path is a file.
|
||||
* "other" if none of the above.
|
||||
*/
|
||||
function exists(path) {
|
||||
const state = jetpack.exists(path);
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得该路径下的文件与目录
|
||||
* 返回一个数组
|
||||
* 等同于 fs.readdir
|
||||
* @param {*} path
|
||||
*/
|
||||
function list(path) {
|
||||
const list = jetpack.list(path);
|
||||
return list || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建目录
|
||||
* @param {*} path
|
||||
*/
|
||||
function dir(path) {
|
||||
jetpack.dir(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制 文件 or 目录
|
||||
* @param {*} src
|
||||
* @param {*} des
|
||||
*/
|
||||
function copy(src, des, isClear) {
|
||||
if (isClear && jetpack.exists(des)) {
|
||||
jetpack.remove(des);
|
||||
}
|
||||
//过滤文件 jetpack.copy('foo', 'bar', { matching: ['*.md', '!top-secret.md'] });
|
||||
jetpack.copy(src, des);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 文件 or 目录
|
||||
* @param {*} params
|
||||
*/
|
||||
function remove(path) {
|
||||
jetpack.remove(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个所在路径
|
||||
* @param {*} arg1
|
||||
* @param {*} arg2
|
||||
*/
|
||||
function path(arg1, arg2) {
|
||||
if (arguments.length == 0) {//当前路径
|
||||
const result = jetpack.path();
|
||||
return result;
|
||||
} else if (arguments.length == 1) {//当前路径下的子目录
|
||||
const result = jetpack.path(arg1);
|
||||
return result;
|
||||
} else if (arguments.length = 2) {
|
||||
const result = jetpack.path(arg1, arg2);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function checkDir(dir) {
|
||||
if (jetpack.exists(dir)) {
|
||||
console.log('clear dir');
|
||||
jetpack.remove(dir);
|
||||
}
|
||||
jetpack.dir(dir);
|
||||
}
|
||||
|
||||
function copyDir(src, des, isClear) {
|
||||
isClear && checkDir(des);
|
||||
jetpack.copy(src, des);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
read,
|
||||
readDir,
|
||||
write,
|
||||
exists,
|
||||
list,
|
||||
dir,
|
||||
copy,
|
||||
remove,
|
||||
path,
|
||||
checkDir,
|
||||
copyDir
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
12
HotUpdateDemo/tools/GameConfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": 1,
|
||||
"version": "1.0.1",
|
||||
"packageUrl": "http://localhost/hotUpdate/",
|
||||
"root": "../build/jsb-link/",
|
||||
"src": "../build/jsb-link/",
|
||||
"hotUpdateDirName": "hotUpdateFiles",
|
||||
"hotupdateDirExport": "exportHotUpdate",
|
||||
"zipDir": [
|
||||
"/res/import"
|
||||
]
|
||||
}
|
||||
54
HotUpdateDemo/tools/ModifyFileTime.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
import os.path
|
||||
import json
|
||||
|
||||
relativePath = ''
|
||||
zipDirList = []
|
||||
TIMESTAMP = 1330712292
|
||||
|
||||
|
||||
def modifyFileTime(filePath, time):
|
||||
# 修改访问和修改时间
|
||||
os.utime(filePath, (time, time))
|
||||
|
||||
|
||||
def modify(rootdir):
|
||||
for parent, dirnames, filenames in os.walk(rootdir):
|
||||
for filename in filenames:
|
||||
print(os.path.join(parent, filename))
|
||||
path1 = os.path.join(parent, filename)
|
||||
modifyFileTime(path1, TIMESTAMP)
|
||||
|
||||
for parent, dirnames, filenames in os.walk(rootdir):
|
||||
for filename in dirnames:
|
||||
print(os.path.join(parent, filename))
|
||||
path1 = os.path.join(parent, filename)
|
||||
modifyFileTime(path1, TIMESTAMP)
|
||||
|
||||
|
||||
def initParams(configPath):
|
||||
data = open(configPath, 'r')
|
||||
data = json.load(data)
|
||||
global relativePath
|
||||
relativePath = data['root'] + data['hotUpdateDirName']
|
||||
global zipDirList
|
||||
zipDirList = data['zipDir']
|
||||
des = data['des']
|
||||
|
||||
|
||||
def main():
|
||||
configPath = os.path.abspath(os.path.join(
|
||||
os.getcwd(), "./GameConfig.json"))
|
||||
initParams(configPath)
|
||||
for dir in zipDirList:
|
||||
abspath = os.path.abspath(os.path.join(os.getcwd(), relativePath+dir))
|
||||
print(abspath)
|
||||
modify(abspath)
|
||||
pass
|
||||
|
||||
|
||||
main()
|
||||
37
HotUpdateDemo/tools/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 热更新工具说明
|
||||
* GameConfig.json 游戏版本、打包配置
|
||||
* BuildBeforeSetting.js 构建前准备工作 如:设置版本号,设置为正式服,等等~
|
||||
* FileUtil.js 文件操作工具类
|
||||
* CopyHotFiles.js 把需要热更文件复制到新文件夹
|
||||
* VersionGenerator.js 生成文件信息,作为版本资源对比。十分重要
|
||||
* ModifyFileTime.py 修改文件的生成时间
|
||||
* ZipFile.py 把文件压缩
|
||||
|
||||
### 准备
|
||||
* 操作系统:window
|
||||
* 安装Node https://nodejs.org/zh-cn/
|
||||
* 安装Python 2.7 or 3.7
|
||||
* 以下操作都是基于android 打包 且模式为[link](https://docs.cocos.com/creator/manual/zh/publish/publish-native.html?h=link)。
|
||||
### 安装依赖
|
||||
* 打开命令行输入:
|
||||
~~~
|
||||
npm install
|
||||
~~~
|
||||
安装Node的库 fs-jetpack 用于对文件操作
|
||||
|
||||
### 操作
|
||||
首先进入tools
|
||||
* 运行 BuildBeforeSetting.js 对项目初始化
|
||||
然后进行构建工程,
|
||||
* 构建Android 工程 选择link模式
|
||||

|
||||
进入tools后
|
||||
* 运行CopyHotFiles.js 把热更新文件放到hotUpdateFiles文件夹
|
||||
* ModifyFileTime.py and ZipFile.py 对hotUpdateFiles中zipDir变量内文件修改时间(用于生成zip后,进行MD5后,md5信息不变)、zip压缩(用于更新时可以减少下载请求,提高热更速度、与更新文件的稳定性)
|
||||
* 运行VersionGenerator.js 对hotUpdateFiles进行md5得到版本信息
|
||||
* 运行ExportHotupdateDir.js 得到热更新资源到exportHotUpdate文件夹
|
||||
|
||||
### 支持https
|
||||
* 打开工程,修改libcocos2dx工程中Cocos2dxDownloader.java类。找到new AsyncHttpClient() 修改成new AsyncHttpClient(true, 80, 443)
|
||||
* 参考文章:https://forum.cocos.com/t/https/52302
|
||||
|
||||
77
HotUpdateDemo/tools/VersionGenerator.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const fileUtil = require('./FileUtil');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
let manifest = {
|
||||
packageUrl: 'http://localhost/tutorial-hot-update/remote-assets/',
|
||||
remoteManifestUrl: 'http://localhost/tutorial-hot-update/remote-assets/project.manifest',
|
||||
remoteVersionUrl: 'http://localhost/tutorial-hot-update/remote-assets/version.manifest',
|
||||
version: '1.0.0',
|
||||
assets: {},
|
||||
searchPaths: []
|
||||
};
|
||||
|
||||
let dest = './remote-assets/';
|
||||
let src = './jsb/';
|
||||
|
||||
function initParams(configPath) {
|
||||
let data = JSON.parse(fileUtil.read(configPath));
|
||||
//得到远程url
|
||||
manifest.packageUrl = data.packageUrl;
|
||||
manifest.remoteManifestUrl = data.packageUrl + 'project.manifest';
|
||||
manifest.remoteVersionUrl = data.packageUrl + 'version.manifest';
|
||||
//版本信息
|
||||
manifest.version = data.version;
|
||||
//构建后的对应目录
|
||||
src = data.root + data.hotUpdateDirName;
|
||||
|
||||
//目的目录
|
||||
dest = src;
|
||||
}
|
||||
|
||||
function md5InfoFromDir(dir, obj) {
|
||||
function fn(subPath) {
|
||||
let stat, size, md5, compressed, relative;
|
||||
stat = fs.statSync(subPath);
|
||||
size = stat['size'];
|
||||
// md5 = crypto.createHash('md5').update(fs.readFileSync(subpath, 'binary')).digest('hex');//返回的并非二进制类型,而是String。这会导致非文本文件md5计算错误
|
||||
md5 = crypto.createHash('md5').update(fs.readFileSync(subPath)).digest('hex');
|
||||
compressed = path.extname(subPath).toLowerCase() === '.zip';
|
||||
relative = path.relative(src, subPath);
|
||||
relative = relative.replace(/\\/g, '/');
|
||||
relative = encodeURI(relative);
|
||||
obj[relative] = {
|
||||
'size': size,
|
||||
'md5': md5
|
||||
};
|
||||
if (compressed) {
|
||||
obj[relative].compressed = true;
|
||||
}
|
||||
}
|
||||
fileUtil.readDir(dir, fn);
|
||||
}
|
||||
|
||||
function main() {
|
||||
initParams('./GameConfig.json');
|
||||
|
||||
md5InfoFromDir(path.join(src, 'src'), manifest.assets);
|
||||
md5InfoFromDir(path.join(src, 'res'), manifest.assets);
|
||||
|
||||
let destManifest = path.join(dest, 'project.manifest');
|
||||
fileUtil.write(destManifest, JSON.stringify(manifest));
|
||||
|
||||
delete manifest.assets;
|
||||
delete manifest.searchPaths;
|
||||
|
||||
destVersion = path.join(dest, 'version.manifest');
|
||||
fileUtil.write(destVersion, JSON.stringify(manifest));
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
90
HotUpdateDemo/tools/ZipFile.py
Normal file
@@ -0,0 +1,90 @@
|
||||
import os
|
||||
import os.path
|
||||
import zipfile
|
||||
import shutil
|
||||
import json
|
||||
|
||||
relativePath = ''
|
||||
zipDirList = []
|
||||
|
||||
|
||||
def zip_dir(dirname, zipfilename):
|
||||
filelist = []
|
||||
if os.path.isfile(dirname):
|
||||
filelist.append(dirname)
|
||||
else:
|
||||
for root, dirs, files in os.walk(dirname):
|
||||
for name in files:
|
||||
filelist.append(os.path.join(root, name))
|
||||
|
||||
zf = zipfile.ZipFile(zipfilename, "w", zipfile.zlib.DEFLATED)
|
||||
for tar in filelist:
|
||||
arcname = tar[len(dirname):]
|
||||
# print arcname
|
||||
zf.write(tar, arcname)
|
||||
zf.close()
|
||||
|
||||
|
||||
def unzip_file(zipfilename, unziptodir):
|
||||
if not os.path.exists(unziptodir):
|
||||
os.mkdir(unziptodir, 777)
|
||||
zfobj = zipfile.ZipFile(zipfilename)
|
||||
for name in zfobj.namelist():
|
||||
name = name.replace('\\', '/')
|
||||
|
||||
if name.endswith('/'):
|
||||
os.mkdir(os.path.join(unziptodir, name))
|
||||
else:
|
||||
ext_filename = os.path.join(unziptodir, name)
|
||||
ext_dir = os.path.dirname(ext_filename)
|
||||
if not os.path.exists(ext_dir):
|
||||
os.mkdir(ext_dir, 777)
|
||||
outfile = open(ext_filename, 'wb')
|
||||
outfile.write(zfobj.read(name))
|
||||
outfile.close()
|
||||
|
||||
|
||||
def encodeDir(rootdir):
|
||||
for parent, dirnames, filenames in os.walk(rootdir):
|
||||
print(parent, dirnames)
|
||||
for dirname in dirnames:
|
||||
print(parent)
|
||||
print(dirname)
|
||||
abspath = os.path.join(parent, dirname)
|
||||
# finishPath=os.path.join()
|
||||
zip_dir(abspath, abspath+'.zip')
|
||||
deleteDir(abspath)
|
||||
|
||||
|
||||
def deleteDir(dir):
|
||||
if(os.path.exists(dir)):
|
||||
shutil.rmtree(dir)
|
||||
|
||||
|
||||
def checkDir(rootdir):
|
||||
if os.path.exists(rootdir):
|
||||
os.removedirs(rootdir)
|
||||
os.makedirs(rootdir)
|
||||
|
||||
|
||||
def initParams(configPath):
|
||||
data = open(configPath, 'r')
|
||||
data = json.load(data)
|
||||
global relativePath
|
||||
relativePath = data['root'] + data['hotUpdateDirName']
|
||||
global zipDirList
|
||||
zipDirList = data['zipDir']
|
||||
|
||||
|
||||
def main():
|
||||
configPath = os.path.abspath(os.path.join(
|
||||
os.getcwd(), "./GameConfig.json"))
|
||||
initParams(configPath)
|
||||
for dir in zipDirList:
|
||||
abspath = os.path.abspath(os.path.join(os.getcwd(), relativePath+dir))
|
||||
print(abspath)
|
||||
encodeDir(abspath)
|
||||
pass
|
||||
|
||||
|
||||
main()
|
||||
@@ -1,250 +0,0 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var crypto = require('crypto');
|
||||
const jetpack = require('fs-jetpack');
|
||||
|
||||
var manifest = {
|
||||
packageUrl: 'http://localhost/tutorial-hot-update/remote-assets/',
|
||||
remoteManifestUrl: 'http://localhost/tutorial-hot-update/remote-assets/project.manifest',
|
||||
remoteVersionUrl: 'http://localhost/tutorial-hot-update/remote-assets/version.manifest',
|
||||
version: '1.0.0',
|
||||
assets: {},
|
||||
searchPaths: []
|
||||
};
|
||||
|
||||
var dest = './remote-assets/';
|
||||
var src = './jsb/';
|
||||
var hotDir = null;
|
||||
var packageRes = null;
|
||||
// Parse arguments
|
||||
var i = 2;
|
||||
while (i < process.argv.length) {
|
||||
var arg = process.argv[i];
|
||||
|
||||
switch (arg) {
|
||||
case '--url':
|
||||
case '-u':
|
||||
var url = process.argv[i + 1];
|
||||
manifest.packageUrl = url;
|
||||
manifest.remoteManifestUrl = url + 'project.manifest';
|
||||
manifest.remoteVersionUrl = url + 'version.manifest';
|
||||
i += 2;
|
||||
break;
|
||||
case '--version':
|
||||
case '-v':
|
||||
manifest.version = process.argv[i + 1];
|
||||
console.log('version=', manifest.version);
|
||||
i += 2;
|
||||
break;
|
||||
case '--src':
|
||||
case '-s':
|
||||
src = process.argv[i + 1];
|
||||
hotDir = path.join(src, 'hotUpdate');
|
||||
console.log('hotDir=', hotDir);
|
||||
packageRes = path.join(src, 'res');
|
||||
console.log('hpackageRes', packageRes);
|
||||
i += 2;
|
||||
break;
|
||||
case '--dest':
|
||||
case '-d':
|
||||
dest = process.argv[i + 1];
|
||||
i += 2;
|
||||
break;
|
||||
default:
|
||||
i += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件到obj中
|
||||
* 过滤渠道json
|
||||
* @param {*} dir
|
||||
* @param {*} obj
|
||||
*/
|
||||
function readDir(dir, obj) {
|
||||
console.log('readDir = ', dir);
|
||||
var stat = fs.statSync(dir);
|
||||
if (!stat.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
var subpaths = fs.readdirSync(dir),
|
||||
subpath, size, md5, compressed, relative;
|
||||
for (var i = 0; i < subpaths.length; ++i) {
|
||||
if (subpaths[i][0] === '.') {
|
||||
continue;
|
||||
}
|
||||
if (subpaths[i] == 'channel.json') {
|
||||
console.log('---------------channel.json-------------------');
|
||||
continue;
|
||||
}
|
||||
subpath = path.join(dir, subpaths[i]);
|
||||
stat = fs.statSync(subpath);
|
||||
if (stat.isDirectory()) {
|
||||
readDir(subpath, obj);
|
||||
} else if (stat.isFile()) {
|
||||
// Size in Bytes
|
||||
size = stat['size'];
|
||||
console.log('md5 ', subpath);
|
||||
// md5 = crypto.createHash('md5').update(fs.readFileSync(subpath, 'binary')).digest('hex');//返回的并非二进制类型,而是String。这会导致非文本文件md5计算错误
|
||||
md5 = crypto.createHash('md5').update(fs.readFileSync(subpath)).digest('hex'); //
|
||||
compressed = path.extname(subpath).toLowerCase() === '.zip';
|
||||
|
||||
relative = path.relative(src, subpath);
|
||||
relative = relative.replace(/\\/g, '/');
|
||||
relative = encodeURI(relative);
|
||||
obj[relative] = {
|
||||
'size': size,
|
||||
'md5': md5
|
||||
};
|
||||
if (compressed) {
|
||||
obj[relative].compressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//创建文件夹
|
||||
var mkdirSync = function (path) {
|
||||
try {
|
||||
fs.mkdirSync(path);
|
||||
} catch (e) {
|
||||
if (e.code != 'EEXIST') throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// Iterate res and src folder
|
||||
readDir(path.join(src, 'src'), manifest.assets);
|
||||
readDir(path.join(src, 'res'), manifest.assets);
|
||||
|
||||
var hotManifest = path.join(hotDir, 'project.manifest');
|
||||
var hotVersion = path.join(hotDir, 'version.manifest');
|
||||
var tmp = path.join(packageRes, 'raw-assets');
|
||||
var packageMenifest = path.join(tmp, 'project.manifest');
|
||||
console.log('packageMenifest', packageMenifest);
|
||||
mkdirSync(dest);
|
||||
//生成热更新目录
|
||||
mkdirSync(hotDir);
|
||||
|
||||
|
||||
//生成文件manifest转成hotProject.js
|
||||
let hotProjectPath = path.join(dest, 'hotManifest.js');
|
||||
console.log('create hotProject', hotProjectPath);
|
||||
isfailed = fs.writeFileSync(hotProjectPath, 'module.exports = ' + JSON.stringify(manifest));
|
||||
if (!isfailed) {
|
||||
console.log('hotManifest successfully generated');
|
||||
}
|
||||
|
||||
//生成文件manifest到hotUpdate
|
||||
isfailed = fs.writeFileSync(hotManifest, JSON.stringify(manifest));
|
||||
if (!isfailed) {
|
||||
console.log('hotManifest successfully generated');
|
||||
}
|
||||
|
||||
delete manifest.assets;
|
||||
delete manifest.searchPaths;
|
||||
|
||||
//生成版本manifest到hotUpdate
|
||||
isfailed = fs.writeFileSync(hotVersion, JSON.stringify(manifest));
|
||||
if (isfailed) {
|
||||
console.log('hotVersion successfully generated');
|
||||
}
|
||||
/*
|
||||
* 复制目录、子目录,及其中的文件
|
||||
* @param src {String} 要复制的目录
|
||||
* @param dist {String} 复制到目标目录
|
||||
*/
|
||||
function copyDirSync(path, dest) {
|
||||
let flist = jetpack.list(path)
|
||||
for (let i = 0; i < flist.length; i++) {
|
||||
let absolutePath = `${path}/${flist[i]}`
|
||||
if (jetpack.exists(absolutePath) == "file") { // 是文件则复制
|
||||
jetpack.copy(absolutePath, `${dest}/${flist[i]}`, {
|
||||
overwrite: true
|
||||
});
|
||||
}
|
||||
if (jetpack.exists(absolutePath) == "dir") { // 是目录则递归
|
||||
copyDirSync(absolutePath, `${dest}/${flist[i]}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除目录
|
||||
*/
|
||||
var rmdirSync = (function () {
|
||||
/**
|
||||
* 删除文件,如果是目录加入dirs 且进入
|
||||
* inner函数
|
||||
* @param {*} url
|
||||
* @param {*} dirs
|
||||
*/
|
||||
function iterator(url, dirs) {
|
||||
var stat = fs.statSync(url);
|
||||
if (stat.isDirectory()) {
|
||||
//收集目录
|
||||
dirs.unshift(url);
|
||||
inner(url, dirs);
|
||||
} else if (stat.isFile()) {
|
||||
fs.unlinkSync(url);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {*} path
|
||||
* @param {*} dirs
|
||||
*/
|
||||
function inner(path, dirs) {
|
||||
var arr = fs.readdirSync(path);
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
iterator(path + '/' + arr[i], dirs);
|
||||
}
|
||||
}
|
||||
return function (dir, cb) {
|
||||
cb = cb || function () {};
|
||||
var dirs = [];
|
||||
try {
|
||||
//删除文件,得到目录
|
||||
iterator(dir, dirs);
|
||||
//一次性删除所有收集到的目录
|
||||
for (var i = 0; i < dirs.length; i++) {
|
||||
fs.rmdirSync(dirs[i]);
|
||||
}
|
||||
cb();
|
||||
} catch (error) {
|
||||
//如果文件或目录本来就不存在,fs.statSync会报错,不过我们还是当成没有异常发生
|
||||
error.code === 'ENOENT' ? cb() : cb(error);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
const srcPath = path.join(src, 'src');
|
||||
const resPath = path.join(src, 'res');
|
||||
const distSrcPath = path.join(hotDir, 'src');
|
||||
const distResPath = path.join(hotDir, 'res');
|
||||
|
||||
//复制src目录前,先删除原有目录
|
||||
rmdirSync(distSrcPath, (err) => {
|
||||
err && console.log('err=', err);
|
||||
console.log('delete success');
|
||||
});
|
||||
|
||||
//复制res目录前,先删除原有目录
|
||||
rmdirSync(distResPath, (err) => {
|
||||
err && console.log('err=', err);
|
||||
console.log('delete success');
|
||||
});
|
||||
|
||||
//复制src目录
|
||||
copyDirSync(srcPath, distSrcPath);
|
||||
console.log('copy finish ', srcPath);
|
||||
|
||||
//复制res目录
|
||||
copyDirSync(resPath, distResPath);
|
||||
console.log('copy finish ', resPath);
|
||||
|
||||
//把生成的maifest 同步到build\jsb-xxx\res\raw-assets 而不需要再次构建重新生成
|
||||
fs.writeFileSync(packageMenifest, fs.readFileSync(hotManifest));
|
||||
console.log(`copy hotupdate to ${packageMenifest} successful`);
|
||||
|
||||
console.log('build hotupdte finish');
|
||||
@@ -60,16 +60,19 @@
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 15
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 13
|
||||
"__id__": 21
|
||||
},
|
||||
{
|
||||
"__id__": 14
|
||||
"__id__": 22
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@@ -231,14 +234,17 @@
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 11
|
||||
},
|
||||
{
|
||||
"__id__": 12
|
||||
},
|
||||
{
|
||||
"__id__": 13
|
||||
},
|
||||
{
|
||||
"__id__": 14
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@@ -295,6 +301,9 @@
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 9
|
||||
},
|
||||
{
|
||||
"__id__": 10
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@@ -382,6 +391,34 @@
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_enabled": true,
|
||||
"isAlignOnce": true,
|
||||
"_target": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_alignFlags": 40,
|
||||
"_left": 130,
|
||||
"_right": 130,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 700,
|
||||
"_originalHeight": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Mask",
|
||||
"_name": "",
|
||||
@@ -422,6 +459,34 @@
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"isAlignOnce": true,
|
||||
"_target": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_alignFlags": 40,
|
||||
"_left": 130,
|
||||
"_right": 130,
|
||||
"_top": 185,
|
||||
"_bottom": 185,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 700,
|
||||
"_originalHeight": 270
|
||||
},
|
||||
{
|
||||
"__type__": "cc.ScrollView",
|
||||
"_name": "",
|
||||
@@ -453,13 +518,13 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"scrollview": {
|
||||
"__id__": 11
|
||||
"__id__": 13
|
||||
},
|
||||
"content": {
|
||||
"__id__": 8
|
||||
},
|
||||
"mask": {
|
||||
"__id__": 9
|
||||
"__id__": 10
|
||||
},
|
||||
"prefab": {
|
||||
"__uuid__": "10c60cf0-420d-41d3-b409-ae1ebad07af7"
|
||||
@@ -471,6 +536,242 @@
|
||||
"gap_x": 0,
|
||||
"gap_y": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Button",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 16
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 18
|
||||
},
|
||||
{
|
||||
"__id__": 19
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "1cCEojzRZBE5TlenfIjah+",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 40
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": -248
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Label",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 15
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 17
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "1aD68m3NBDgJvHRJX1dw+U",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 40
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 16
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
"_actualFontSize": 20,
|
||||
"_fontSize": 20,
|
||||
"_lineHeight": 40,
|
||||
"_enableWrapText": false,
|
||||
"_N$file": null,
|
||||
"_isSystemFontUsed": true,
|
||||
"_spacingX": 0,
|
||||
"_N$string": "append",
|
||||
"_N$horizontalAlign": 1,
|
||||
"_N$verticalAlign": 1,
|
||||
"_N$fontFamily": "Arial",
|
||||
"_N$overflow": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 15
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Button",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 15
|
||||
},
|
||||
"_enabled": true,
|
||||
"transition": 2,
|
||||
"pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"hoverColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 20
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_N$disabledColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_N$normalSprite": {
|
||||
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
|
||||
},
|
||||
"_N$pressedSprite": {
|
||||
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
|
||||
},
|
||||
"pressedSprite": {
|
||||
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
|
||||
},
|
||||
"_N$hoverSprite": {
|
||||
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
|
||||
},
|
||||
"hoverSprite": {
|
||||
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
|
||||
},
|
||||
"_N$disabledSprite": {
|
||||
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
|
||||
},
|
||||
"_N$target": {
|
||||
"__id__": 15
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.ClickEvent",
|
||||
"target": {
|
||||
"__id__": 2
|
||||
},
|
||||
"component": "HelloWorld",
|
||||
"handler": "onEventClicked",
|
||||
"customEventData": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Canvas",
|
||||
"_name": "",
|
||||
|
||||
@@ -8,7 +8,13 @@ cc.Class({
|
||||
|
||||
start() {
|
||||
let script = this.listViewNode.getComponent('ListViewFactory');
|
||||
script.init([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
this.dataSize = 9;
|
||||
script.init([1, 2, 3, 4, 5, 6, 7, 8, 9], 2);
|
||||
},
|
||||
|
||||
onEventClicked() {
|
||||
let script = this.listViewNode.getComponent('ListViewFactory');
|
||||
script.append(this.dataSize++);
|
||||
},
|
||||
|
||||
// called every frame
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ListViewTs } from "./Listview/listview";
|
||||
import { ListViewTs, ListViewParams } from "./Listview/listview";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@@ -36,9 +36,26 @@ export default class ListViewFactory extends cc.Component {
|
||||
|
||||
listView: ListViewTs;
|
||||
|
||||
init(data) {
|
||||
init(data: Array<any>, offsetIndex: number = 0, time: number = 0.5) {
|
||||
//下一帧执行,当使用widget适配高宽,可以取得真实长度。
|
||||
this.scheduleOnce(() => {
|
||||
this._init(data, offsetIndex, time);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
append(data: any) {
|
||||
if (!this.listView) {
|
||||
this.init([data]);
|
||||
return;
|
||||
}
|
||||
this.listView.append_data(data);
|
||||
}
|
||||
|
||||
_init(data: Array<any>, offsetIndex: number = 0, time: number = 0.5) {
|
||||
//初始化
|
||||
let item = cc.instantiate(this.prefab);
|
||||
let size = this.getItemSize(item, this.gap_x, this.gap_y);
|
||||
|
||||
this.listView = new ListViewTs({
|
||||
scrollview: this.scrollview,
|
||||
mask: this.mask,
|
||||
@@ -53,8 +70,26 @@ export default class ListViewFactory extends cc.Component {
|
||||
});
|
||||
//显示
|
||||
this.listView.set_data(data);
|
||||
this.scrollview.scrollToTop();
|
||||
this.scrollview.stopAutoScroll();
|
||||
let realIdx = Math.floor(offsetIndex / this.column);
|
||||
if (realIdx > 0) {
|
||||
let offSet = this.setOffsetByIndex(realIdx, this.direction, size);
|
||||
this.scrollview.scrollToOffset(offSet, time);
|
||||
} else {
|
||||
this.scrollview.scrollToTop();
|
||||
this.scrollview.stopAutoScroll();
|
||||
}
|
||||
}
|
||||
|
||||
setOffsetByIndex(index: number, direction: number, size: cc.Size) {
|
||||
if (direction == 1) {
|
||||
return cc.v2(0, index * size.height);
|
||||
} else {
|
||||
return cc.v2(index * size.width, 0);
|
||||
}
|
||||
}
|
||||
|
||||
getItemSize(node: cc.Node, x: number, y: number) {
|
||||
return cc.size(node.width + x, node.height + y);
|
||||
}
|
||||
|
||||
update(dt) {
|
||||
|
||||
@@ -804,7 +804,7 @@ export enum ListViewDir {
|
||||
Horizontal = 2,
|
||||
}
|
||||
|
||||
type ListViewParams = {
|
||||
export type ListViewParams = {
|
||||
scrollview: cc.ScrollView;
|
||||
mask: cc.Mask;
|
||||
content: cc.Node;
|
||||
|
||||
67
RayCastDemo/.gitignore
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Fireball Projects
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
library/
|
||||
temp/
|
||||
local/
|
||||
build/
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Logs and databases
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# files for debugger
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.sln
|
||||
*.csproj
|
||||
*.pidb
|
||||
*.unityproj
|
||||
*.suo
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# OS generated files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# exvim files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*UnityVS.meta
|
||||
*.err
|
||||
*.err.meta
|
||||
*.exvim
|
||||
*.exvim.meta
|
||||
*.vimentry
|
||||
*.vimentry.meta
|
||||
*.vimproject
|
||||
*.vimproject.meta
|
||||
.vimfiles.*/
|
||||
.exvim.*/
|
||||
quick_gen_project_*_autogen.bat
|
||||
quick_gen_project_*_autogen.bat.meta
|
||||
quick_gen_project_*_autogen.sh
|
||||
quick_gen_project_*_autogen.sh.meta
|
||||
.exvim.app
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# webstorm files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.idea/
|
||||
|
||||
#//////////////////////////
|
||||
# VS Code
|
||||
#//////////////////////////
|
||||
|
||||
.vscode/
|
||||
2
RayCastDemo/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# 物理系统下瞄准线
|
||||
环境:Creator v2.0.0
|
||||
6
RayCastDemo/assets/Scene.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
1702
RayCastDemo/assets/Scene/helloworld.fire
Normal file
7
RayCastDemo/assets/Scene/helloworld.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "0.9.0",
|
||||
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
RayCastDemo/assets/Script.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
16
RayCastDemo/assets/Script/Helloworld.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
const {ccclass, property} = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class Helloworld extends cc.Component {
|
||||
|
||||
@property(cc.Label)
|
||||
label: cc.Label = null;
|
||||
|
||||
@property
|
||||
text: string = 'hello';
|
||||
|
||||
start () {
|
||||
// init logic
|
||||
this.label.string = this.text;
|
||||
}
|
||||
}
|
||||
9
RayCastDemo/assets/Script/Helloworld.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "e1b90feb-a217-4493-849d-9a611900d683",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
21
RayCastDemo/assets/Script/PhysicsMgr.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class PhysicsMgr extends cc.Component {
|
||||
|
||||
@property
|
||||
enabeld = true;
|
||||
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
|
||||
onLoad() {
|
||||
cc.director.getPhysicsManager().enabled = this.enabeld;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
// update (dt) {}
|
||||
}
|
||||
9
RayCastDemo/assets/Script/PhysicsMgr.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "53124fd2-8450-483a-a843-e9be55bdbd02",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
101
RayCastDemo/assets/Script/RayCastMgr.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
const AIM_LINE_MAX_LENGTH = 1440;
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class RayCastMgr extends cc.Component {
|
||||
|
||||
@property(cc.Node)
|
||||
startNode: cc.Node = null;
|
||||
|
||||
@property(cc.Graphics)
|
||||
graphic_line: cc.Graphics = null;
|
||||
|
||||
startLocation: cc.Vec2 = null;
|
||||
|
||||
curLength = 0;
|
||||
|
||||
onLoad() {
|
||||
this.startLocation = this.startNode.convertToWorldSpaceAR(cc.v2(0, 0));
|
||||
this.graphic_line.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
|
||||
this.graphic_line.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||
this.graphic_line.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
onTouchStart(touch: cc.Event.EventTouch) {
|
||||
const location = touch.getLocation();
|
||||
this.draw(cc.v2(location.x, location.y));
|
||||
}
|
||||
|
||||
onTouchMove(touch: cc.Event.EventTouch) {
|
||||
const location = touch.getLocation();
|
||||
this.draw(cc.v2(location.x, location.y));
|
||||
}
|
||||
|
||||
onTouchEnd(touch: cc.Event.EventTouch) {
|
||||
|
||||
}
|
||||
|
||||
draw(end) {
|
||||
this.graphic_line.clear();
|
||||
this.curLength = 0;
|
||||
// 计算射线
|
||||
this.drawRayCast(this.startLocation, end.subSelf(this.startLocation).normalizeSelf());
|
||||
this.graphic_line.stroke();
|
||||
}
|
||||
|
||||
drawRayCast(start: cc.Vec2, dirUnit: cc.Vec2) {
|
||||
let leftLength = AIM_LINE_MAX_LENGTH - this.curLength;
|
||||
if (leftLength <= 0) return;
|
||||
// 计算线的终点位置
|
||||
let end = start.add(dirUnit.mul(leftLength));
|
||||
// 检测给定的线段穿过哪些碰撞体,可以获取到碰撞体在线段穿过碰撞体的那个点的法线向量和其他一些有用的信息。
|
||||
let resultList = cc.director.getPhysicsManager().rayCast(start, end, cc.RayCastType.Closest);
|
||||
if (resultList.length < 1) {
|
||||
// 画剩余线段
|
||||
this.drawAimLine(start, end);
|
||||
} else {
|
||||
const result = resultList[0];
|
||||
// 指定射线与穿过的碰撞体在哪一点相交。
|
||||
const point = result.point;
|
||||
// 画入射线段
|
||||
this.drawAimLine(start, point);
|
||||
const lineLength = point.sub(start).mag();
|
||||
this.curLength += lineLength;
|
||||
// 指定碰撞体在相交点的表面的法线单位向量。
|
||||
const vector_n = result.normal;
|
||||
// 入射单位向量
|
||||
const vector_i = dirUnit;
|
||||
const vector_r = vector_i.sub(vector_n.mul(2 * vector_i.dot(vector_n)));
|
||||
// 接着计算下一段
|
||||
this.drawRayCast(point, vector_r);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param start 世界坐标系
|
||||
* @param end 世界坐标系
|
||||
*/
|
||||
drawAimLine(start: cc.Vec2, end: cc.Vec2) {
|
||||
// 转换坐标
|
||||
let startPoint = this.graphic_line.node.convertToNodeSpaceAR(start);
|
||||
this.graphic_line.moveTo(startPoint.x, startPoint.y);
|
||||
|
||||
// 画小圆圆
|
||||
const delta = 20, dirVector = end.sub(start);
|
||||
let total = Math.round(dirVector.mag() / delta);
|
||||
dirVector.normalizeSelf().mulSelf(delta);
|
||||
for (let i = 0; i < total; i++) {
|
||||
startPoint.addSelf(dirVector);
|
||||
this.graphic_line.circle(startPoint.x, startPoint.y, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// update (dt) {}
|
||||
}
|
||||
9
RayCastDemo/assets/Script/RayCastMgr.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "75cd2a7e-f307-4648-96b7-ba9888c22f69",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
RayCastDemo/assets/Texture.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
BIN
RayCastDemo/assets/Texture/HelloWorld.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
31
RayCastDemo/assets/Texture/HelloWorld.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"HelloWorld": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
|
||||
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 195,
|
||||
"height": 270,
|
||||
"rawWidth": 195,
|
||||
"rawHeight": 270,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
RayCastDemo/assets/Texture/item_10.png
Normal file
|
After Width: | Height: | Size: 548 B |
31
RayCastDemo/assets/Texture/item_10.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "1072a1c2-537e-427a-9a7a-febfb0cc2792",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"item_10": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "7076766c-671d-4fad-80d8-ab5c822e3609",
|
||||
"rawTextureUuid": "1072a1c2-537e-427a-9a7a-febfb0cc2792",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 134,
|
||||
"height": 139,
|
||||
"rawWidth": 134,
|
||||
"rawHeight": 139,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
RayCastDemo/assets/Texture/item_11.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
31
RayCastDemo/assets/Texture/item_11.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "b18e13db-6bd6-48ae-910e-c7ab8984ae65",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"item_11": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "c6116e42-3eaa-44a6-9e91-f20c7eeb3aa2",
|
||||
"rawTextureUuid": "b18e13db-6bd6-48ae-910e-c7ab8984ae65",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 135,
|
||||
"height": 158,
|
||||
"rawWidth": 135,
|
||||
"rawHeight": 158,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
RayCastDemo/assets/Texture/item_8.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
31
RayCastDemo/assets/Texture/item_8.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "130f22b5-4f11-414d-ba08-99885835c0a7",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"item_8": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "34661e88-7f90-42d8-8a7d-70727ed04a06",
|
||||
"rawTextureUuid": "130f22b5-4f11-414d-ba08-99885835c0a7",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 135,
|
||||
"height": 140,
|
||||
"rawWidth": 135,
|
||||
"rawHeight": 140,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
RayCastDemo/assets/Texture/item_9.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
31
RayCastDemo/assets/Texture/item_9.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "5591a452-f4cf-449d-ace2-fa200df80559",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"item_9": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "71932bfb-3278-4b00-9b82-afe6f927723f",
|
||||
"rawTextureUuid": "5591a452-f4cf-449d-ace2-fa200df80559",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 72,
|
||||
"height": 81,
|
||||
"rawWidth": 72,
|
||||
"rawHeight": 81,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
RayCastDemo/assets/Texture/singleColor.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
31
RayCastDemo/assets/Texture/singleColor.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"singleColor": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
|
||||
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 2,
|
||||
"height": 2,
|
||||
"rawWidth": 2,
|
||||
"rawHeight": 2,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
20635
RayCastDemo/creator.d.ts
vendored
Normal file
15
RayCastDemo/jsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode",
|
||||
"library",
|
||||
"local",
|
||||
"settings",
|
||||
"temp"
|
||||
]
|
||||
}
|
||||
6
RayCastDemo/project.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"engine": "cocos2d-html5",
|
||||
"packages": "packages",
|
||||
"version": "2.2.0",
|
||||
"id": "b9249570-68a9-49c5-8195-108f1ae0b31f"
|
||||
}
|
||||
13
RayCastDemo/settings/builder.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"orientation": {
|
||||
"landscapeLeft": true,
|
||||
"landscapeRight": true,
|
||||
"portrait": false,
|
||||
"upsideDown": false
|
||||
},
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "hello_world",
|
||||
"webOrientation": "auto"
|
||||
}
|
||||
7
RayCastDemo/settings/builder.panel.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"platform": "web-mobile",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "HelloWorld"
|
||||
}
|
||||
38
RayCastDemo/settings/project.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"collision-matrix": [
|
||||
[
|
||||
true
|
||||
]
|
||||
],
|
||||
"excluded-modules": [
|
||||
"Geom Utils",
|
||||
"3D",
|
||||
"3D Primitive"
|
||||
],
|
||||
"group-list": [
|
||||
"default"
|
||||
],
|
||||
"start-scene": "current",
|
||||
"design-resolution-width": 960,
|
||||
"design-resolution-height": 640,
|
||||
"fit-width": false,
|
||||
"fit-height": true,
|
||||
"use-project-simulator-setting": false,
|
||||
"simulator-orientation": false,
|
||||
"use-customize-simulator": false,
|
||||
"simulator-resolution": {
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"last-module-event-record-time": 0,
|
||||
"facebook": {
|
||||
"enable": false,
|
||||
"appID": "",
|
||||
"live": {
|
||||
"enable": false
|
||||
},
|
||||
"audience": {
|
||||
"enable": false
|
||||
}
|
||||
}
|
||||
}
|
||||
102
RayCastDemo/settings/services.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"service_id": "235",
|
||||
"service_name": "Cocos Analytics",
|
||||
"service_icon": "https://account.cocos.com/client/3f8f31ccf66995e183044f167c092395.png",
|
||||
"service_desc": "提供最核心最基本的数据、标准化界面功能简洁易用、数据准确性最好",
|
||||
"service_title": "精准了解游戏的新增、活跃、留存、付费等数据",
|
||||
"service_guide_url": "https://n-analytics.cocos.com/docs/",
|
||||
"service_sample_url": "https://github.com/cocos-creator/tutorial-dark-slash/tree/analytics",
|
||||
"service_dev_url": "http://analytics.cocos.com/realtime/jump_to/<app_id>",
|
||||
"service_type": "3",
|
||||
"service_type_zh": "公司和个人游戏",
|
||||
"support_platform": [
|
||||
"Android",
|
||||
"iOS",
|
||||
"HTML5"
|
||||
],
|
||||
"package_download_url": "https://download.cocos.com/CocosServices/plugins/service-analytics/1.2.3_2.1.1.zip",
|
||||
"package_version_desc": "<p><strong>更新日期:</strong> 2019/11/18<br />\n<strong>更新说明:</strong><br />\n1、更新统计SDK<br />\n2、修改微信小游戏和百度小游戏集成失败的问题<br />\n",
|
||||
"service_component_name": "service-analytics",
|
||||
"package_versions": [
|
||||
"1.2.3_2.1.1",
|
||||
"1.2.0_2.1.0",
|
||||
"1.1.7_2.0.3",
|
||||
"1.1.6_2.0.1_2.0.2",
|
||||
"1.1.5_2.0.1",
|
||||
"1.1.4_2.0.1",
|
||||
"1.1.3_2.0.1",
|
||||
"1.1.2_2.0.0",
|
||||
"1.0.0_1.0.5"
|
||||
],
|
||||
"build_platform": [
|
||||
],
|
||||
"require_verify": 0,
|
||||
"service_price": "",
|
||||
"service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见<a href='http://auth.cocos.com/CocosServiceAgreement.html'>《Cocos用户服务协议》</a>和<a href='http://auth.cocos.com/PrivacyPolicy.html'>《Cocos隐私政策》</a>"
|
||||
},
|
||||
{
|
||||
"service_id": "241",
|
||||
"service_name": "Matchvs",
|
||||
"service_icon": "https://account.cocos.com/client/14406719a07eb3d714d36e5edc6e06fa.png",
|
||||
"service_desc": "通过SDK接入快速实现联网功能、帧同步、国内外多节点、服务器独立部署、gameServer自定义游戏服务端逻辑。",
|
||||
"service_title": "专业成熟的移动游戏联网与服务端解决方案",
|
||||
"service_guide_url": "http://doc.matchvs.com/QuickStart/QuickStart-CocosCreator",
|
||||
"service_sample_url": "http://www.matchvs.com/serviceCourse",
|
||||
"service_dev_url": "http://www.matchvs.com/cocosLogin",
|
||||
"service_type": "3",
|
||||
"service_type_zh": "公司和个人游戏",
|
||||
"support_platform": [
|
||||
"Android",
|
||||
"iOS",
|
||||
"HTML5"
|
||||
],
|
||||
"package_download_url": "https://download.cocos.com/CocosServices/plugins/service-matchvs/1.0.10_3.7.9.10.zip",
|
||||
"package_version_desc": "<p><strong>更新日期:</strong> 2019/9/12\n<strong>更新内容:</strong>\n1.多语言支持\n2.SDK日常更新</p>",
|
||||
"service_component_name": "service-matchvs",
|
||||
"package_versions": [
|
||||
"1.0.9_3.7.9.9",
|
||||
"1.0.7_3.7.9.6",
|
||||
"1.0.6_3.7.9.2",
|
||||
"1.0.5_3.7.7.3",
|
||||
"1.0.3_3.7.6.4",
|
||||
"1.0.10_3.7.9.10"
|
||||
],
|
||||
"build_platform": [
|
||||
],
|
||||
"require_verify": 0,
|
||||
"service_price": "该服务按使用量计费,<a href='https://www.matchvs.com/price'><font color='#dddddd'>计费规则</font></a>,所产生的费用将由第三方从您的 <a href='https://account.cocos.com/#/finance/finance_list'><font color='#dddddd'>Cocos 账户余额</font></a> 中扣除。",
|
||||
"service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见<a href='http://auth.cocos.com/CocosServiceAgreement.html'>《Cocos用户服务协议》</a>和<a href='http://auth.cocos.com/PrivacyPolicy.html'>《Cocos隐私政策》</a>"
|
||||
},
|
||||
{
|
||||
"service_id": "242",
|
||||
"service_name": "Agora Voice",
|
||||
"service_icon": "https://account.cocos.com/uploads/client_icon/2019-07-16/273952d155b4cdb72d2b1bc61de91ade.png",
|
||||
"service_desc": "稳定、低耗、76ms超低延时、全球200+数据中心覆盖;变声器、超高音质、听声辩位等丰富玩法极速接入;全平台支持:Android、iOS、Web。",
|
||||
"service_title": "游戏内置实时语音",
|
||||
"service_guide_url": "https://docs.agora.io/cn/Interactive Gaming/game_c?platform=Cocos Creator",
|
||||
"service_sample_url": "https://github.com/AgoraIO/Voice-Call-for-Mobile-Gaming/tree/master/Basic-Voice-Call-for-Gaming/Hello-CocosCreator-Voice-Agora",
|
||||
"service_dev_url": "https://sso.agora.io/api/oauth/cocos/login",
|
||||
"service_type": "3",
|
||||
"service_type_zh": "公司和个人游戏",
|
||||
"support_platform": [
|
||||
"Android",
|
||||
"iOS",
|
||||
"HTML5"
|
||||
],
|
||||
"package_download_url": "https://download.cocos.com/CocosServices/plugins/service-agora/1.0.2_2.2.3.20_2.5.2.zip",
|
||||
"package_version_desc": "<b>更新日期:<b>2019/06/27<br>\n<br><b>更新内容:</b><br>\n1、修复部分BUG<br>\n2、代码优化",
|
||||
"service_component_name": "service-agora",
|
||||
"package_versions": [
|
||||
"1.0.2_2.2.3.20_2.5.2",
|
||||
"1.0.1_2.2.3.20_2.5.2"
|
||||
],
|
||||
"build_platform": [
|
||||
],
|
||||
"require_verify": 1,
|
||||
"service_price": "该服务按使用量计费,<a href='https://www.agora.io/cn/price/'><font color='#dddddd'>计费规则</font></a>,所产生的费用将由第三方从您的 <a href='https://account.cocos.com/#/finance/finance_list'><font color='#dddddd'>Cocos 账户余额</font></a> 中扣除。",
|
||||
"service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见<a href='http://auth.cocos.com/CocosServiceAgreement.html'>《Cocos用户服务协议》</a>和<a href='http://auth.cocos.com/PrivacyPolicy.html'>《Cocos隐私政策》</a>"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
RayCastDemo/template-banner.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
5
RayCastDemo/template.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "TEMPLATES.helloworld-ts.name",
|
||||
"desc": "TEMPLATES.helloworld-ts.desc",
|
||||
"banner": "template-banner.png"
|
||||
}
|
||||
18
RayCastDemo/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [ "dom", "es5", "es2015.promise" ],
|
||||
"target": "es5",
|
||||
"allowJs": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"library",
|
||||
"local",
|
||||
"temp",
|
||||
"build",
|
||||
"settings"
|
||||
]
|
||||
}
|
||||
67
RollingNumber/.gitignore
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Fireball Projects
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
library/
|
||||
temp/
|
||||
local/
|
||||
build/
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Logs and databases
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# files for debugger
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.sln
|
||||
*.csproj
|
||||
*.pidb
|
||||
*.unityproj
|
||||
*.suo
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# OS generated files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# exvim files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*UnityVS.meta
|
||||
*.err
|
||||
*.err.meta
|
||||
*.exvim
|
||||
*.exvim.meta
|
||||
*.vimentry
|
||||
*.vimentry.meta
|
||||
*.vimproject
|
||||
*.vimproject.meta
|
||||
.vimfiles.*/
|
||||
.exvim.*/
|
||||
quick_gen_project_*_autogen.bat
|
||||
quick_gen_project_*_autogen.bat.meta
|
||||
quick_gen_project_*_autogen.sh
|
||||
quick_gen_project_*_autogen.sh.meta
|
||||
.exvim.app
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# webstorm files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.idea/
|
||||
|
||||
#//////////////////////////
|
||||
# VS Code
|
||||
#//////////////////////////
|
||||
|
||||
.vscode/
|
||||
100
RollingNumber/assets/item_0.prefab
Normal file
@@ -0,0 +1,100 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.Prefab",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_rawFiles": null,
|
||||
"data": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "item_0",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_id": "",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 26,
|
||||
"height": 36
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "187189c9-582f-4213-a754-1c33a9512de9"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 2,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": false,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__uuid__": "4639edfe-5f74-45f9-9fe3-65a79e365fd3"
|
||||
},
|
||||
"fileId": "bbbnkIa1VGQ7eS3L4JlJtT",
|
||||
"sync": false
|
||||
}
|
||||
]
|
||||
6
RollingNumber/assets/item_0.prefab.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "4639edfe-5f74-45f9-9fe3-65a79e365fd3",
|
||||
"asyncLoadAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||