| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- // Learn cc.Class:
- // - https://docs.cocos.com/creator/manual/en/scripting/class.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
- cc.Class({
- extends: cc.Component,
- properties: {
- left: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- // to a node for the first time
- type: cc.Label, // optional, default is typeof default
- serializable: true, // optional, default is true
- },
- mid: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- // to a node for the first time
- type: cc.Label, // optional, default is typeof default
- serializable: true, // optional, default is true
- },
- right: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- // to a node for the first time
- type: cc.Label, // optional, default is typeof default
- serializable: true, // optional, default is true
- },
- front: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- // to a node for the first time
- type: cc.Label, // optional, default is typeof default
- serializable: true, // optional, default is true
- },
- back: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- // to a node for the first time
- type: cc.Label, // optional, default is typeof default
- serializable: true, // optional, default is true
- },
- limitLabel: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- // to a node for the first time
- type: cc.Label, // optional, default is typeof default
- serializable: true, // optional, default is true
- },
- limitDirectionLabel: {
- // ATTRIBUTES:
- default: null, // The default value will be used only when the component attaching
- // to a node for the first time
- type: cc.Label, // optional, default is typeof default
- serializable: true, // optional, default is true
- },
- x: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- y: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- z: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- sqrt: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- ox: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- oy: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- oz: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- oriSqrt: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- hitCountL: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- hitCountZ: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //调用测试次数
- phoneIndex: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- BLEIndex: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- avePhoneIndex: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- aveBLEIndex: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- writeValue: {
- default: '',
- visible: false,
- serializable: true,
- },
- jumpCount: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- runCount: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- moveState: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- handleState: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- min: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- s: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- ms: {
- default: null,
- type: cc.Label,
- serializable: true,
- }
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start() {
- this.leftCount = 0;
- this.rightCount = 0;
- this.midCount = 0;
- this.backCount = 0;
- this.onJumpCount(0);
- this.onRunCount(0);
- this.onResetState();
- },
- leftHook() {
- console.log("左勾拳");
- this.leftCount++;
- this.left.string = "左勾拳:" + this.leftCount;
- },
- jar() {
- console.log("直拳");
- this.midCount++;
- this.mid.string = "直拳:" + this.midCount;
- },
- rightHook() {
- console.log("右勾拳");
- this.rightCount++;
- this.right.string = "右勾拳: " + this.rightCount;
- },
- leftJump() {
- this.leftCount++;
- this.left.string = "左:" + this.leftCount;
- },
- frontJump() {
- this.midCount++;
- this.mid.string = "前:" + this.midCount;
- },
- rightJump() {
- this.rightCount++;
- this.right.string = "右: " + this.rightCount;
- },
- backJump() {
- this.backCount++;
- this.back.string = "后: " + this.backCount;
- },
- onSlide(e, customEventData) {
- // console.log(e.progress);
- window.webView.currentLimitValue = Math.floor(e.progress * 15);
- console.log("webview.currentLimitValue:", window.webView.currentLimitValue);
- this.limitLabel.string = window.webView.currentLimitValue;
- },
- onSlideDirection(e, customEventData) {
- // console.log(e.progress);
- window.webView.currentLimitDireValue = Math.floor(e.progress * 1000) / 100;
- console.log("webview.currentLimitDireValue:", window.webView.currentLimitDireValue);
- this.limitDirectionLabel.string = window.webView.currentLimitDireValue;
- },
- updateLMR(acc) {
- this.left.string = "x:" + acc.xAxis.toFixed(5);
- this.mid.string = "y:" + acc.yAxis.toFixed(5);
- this.right.string = "z:" + acc.zAxis.toFixed(5);
- },
- updateAcc(acc) {
- this.x.string = "x:" + acc.xAxis.toFixed(5);
- this.y.string = "y:" + acc.yAxis.toFixed(5);
- this.z.string = "z:" + acc.zAxis.toFixed(5);
- },
- updateStr(data) {
- this.sqrt.string = "d:" + data;
- },
- updateSqrt(value) {
- this.sqrt.string = "sqrt:" + value.toFixed(5);
- },
- updateOriSqrt(value) {
- this.oriSqrt.string = "oriS:" + value.toFixed(5);
- },
- updateOri(ori) {
- this.ox.string = " ox:" + ori.beta;
- this.oy.string = " oy:" + ori.gamma;
- this.oz.string = " oz:" + ori.alpha;
- },
- updateOriBeta(ori) {
- this.ox.string = "ox:" + ori.beta;
- },
- updateOriGamma(ori) {
- this.oy.string = "oy:" + ori.gamma;
- },
- updateOriAlpha(ori) {
- this.oz.string = "oz:" + ori.alpha;
- },
- updateHitCountL(data) {
- this.hitCountL.string = "hitx:" + data;
- },
- updateHitCountZ(data) {
- this.hitCountZ.string = "hitz:" + data.toFixed(2);
- },
- updatePhoneIndex(data) {
- this.phoneIndex.string = "p:" + data;
- },
- updateBLEIndex(data) {
- this.BLEIndex.string = "b:" + data;
- },
- onAvePhoneIndex(data) {
- this.avePhoneIndex.string = "ap:" + data;
- },
- onAveBLEIndex(data) {
- this.aveBLEIndex.string = "ab:" + data;
- },
- onWriteValueChange(data) {
- console.log(data);
- this.writeValue = data;
- },
- onJumpCount(data) {
- this.jumpCount.string = "jump:" + data;
- },
- onRunCount(data) {
- if (this.runCount)
- this.runCount.string = "run:" + data;
- },
- onMoveState(data) {
- this.moveState.string = "state:" + data;
- },
- onResetState() {
- this.moveState.string = "state: 无";
- },
- onHandleState(data) {
- this.handleState.string = "手柄:" + data;
- },
- updateTime(data) {
- this.min.string = "min:" + data.min.toFixed(1);
- this.s.string = "s:" + data.s.toFixed(1);
- this.ms.string = "ms:" + data.ms.toFixed(1);
- },
- onLeftCount(data) {
- this.left.string = "jump:" + data;
- }
- });
|