Skip to content

Commit b0edc66

Browse files
author
zhangbin
committed
Improve the test case of dragonbones.
1 parent d34293c commit b0edc66

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

assets/cases/dragonbones/DragonBones.fire

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@
255255
"_N$dragonAtlasAsset": {
256256
"__uuid__": "2349e917-5cb4-44bd-98ae-81fbad154586"
257257
},
258+
"_N$_defaultArmatureIndex": 3,
259+
"_N$_animationIndex": 0,
258260
"_N$timeScale": 1,
259261
"_N$debugBones": false
260262
},
@@ -611,6 +613,7 @@
611613
"a": 255
612614
},
613615
"duration": 0.1,
616+
"zoomScale": 0.1,
614617
"pressedSprite": {
615618
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
616619
},
@@ -619,6 +622,7 @@
619622
},
620623
"clickEvents": [],
621624
"_N$interactable": true,
625+
"_N$enableAutoGrayEffect": true,
622626
"_N$normalColor": {
623627
"__type__": "cc.Color",
624628
"r": 255,
@@ -824,6 +828,7 @@
824828
"a": 255
825829
},
826830
"duration": 0.1,
831+
"zoomScale": 0.1,
827832
"pressedSprite": {
828833
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
829834
},
@@ -832,6 +837,7 @@
832837
},
833838
"clickEvents": [],
834839
"_N$interactable": true,
840+
"_N$enableAutoGrayEffect": true,
835841
"_N$normalColor": {
836842
"__type__": "cc.Color",
837843
"r": 255,
@@ -1037,6 +1043,7 @@
10371043
"a": 255
10381044
},
10391045
"duration": 0.1,
1046+
"zoomScale": 0.1,
10401047
"pressedSprite": {
10411048
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
10421049
},
@@ -1045,6 +1052,7 @@
10451052
},
10461053
"clickEvents": [],
10471054
"_N$interactable": true,
1055+
"_N$enableAutoGrayEffect": true,
10481056
"_N$normalColor": {
10491057
"__type__": "cc.Color",
10501058
"r": 255,
@@ -1191,6 +1199,7 @@
11911199
"a": 255
11921200
},
11931201
"duration": 0.1,
1202+
"zoomScale": 0.1,
11941203
"pressedSprite": {
11951204
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
11961205
},
@@ -1199,6 +1208,7 @@
11991208
},
12001209
"clickEvents": [],
12011210
"_N$interactable": true,
1211+
"_N$enableAutoGrayEffect": true,
12021212
"_N$normalColor": {
12031213
"__type__": "cc.Color",
12041214
"r": 255,
@@ -1404,6 +1414,7 @@
14041414
"a": 255
14051415
},
14061416
"duration": 0.1,
1417+
"zoomScale": 0.1,
14071418
"pressedSprite": {
14081419
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
14091420
},
@@ -1416,6 +1427,7 @@
14161427
}
14171428
],
14181429
"_N$interactable": true,
1430+
"_N$enableAutoGrayEffect": true,
14191431
"_N$normalColor": {
14201432
"__type__": "cc.Color",
14211433
"r": 255,
@@ -1629,6 +1641,7 @@
16291641
"a": 255
16301642
},
16311643
"duration": 0.1,
1644+
"zoomScale": 0.1,
16321645
"pressedSprite": {
16331646
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
16341647
},
@@ -1641,6 +1654,7 @@
16411654
}
16421655
],
16431656
"_N$interactable": true,
1657+
"_N$enableAutoGrayEffect": true,
16441658
"_N$normalColor": {
16451659
"__type__": "cc.Color",
16461660
"r": 255,

assets/cases/dragonbones/DragonBonesCtrl.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ cc.Class({
6666
_aimState : null,
6767
_walkState : null,
6868
_attackState : null,
69-
_target : {
70-
default: cc.p(0, 0),
71-
type: cc.Vec2
72-
}
69+
_target : cc.p(0, 0),
7370
},
7471

7572
// use this for initialization
@@ -153,13 +150,6 @@ cc.Class({
153150
this._keyHandler(keyCode, false);
154151
},
155152
}, this.node);
156-
157-
cc.eventManager.addListener({
158-
event: cc.EventListener.MOUSE,
159-
onMouseDown : this._onMouseDown,
160-
onMouseUp : this._onMouseUp,
161-
onMouseMove : this._onMouseMove
162-
}, this.node);
163153
},
164154

165155
_keyHandler: function(keyCode, isDown) {
@@ -326,10 +316,10 @@ cc.Class({
326316

327317
_frameEventHandler : function (event) {
328318
if (event.detail.name === "onFire") {
329-
const firePointBone = event.detail.armature.getBone("firePoint");
319+
var firePointBone = event.detail.armature.getBone("firePoint");
330320
var localPoint = cc.p(firePointBone.global.x, firePointBone.global.y);
331321

332-
const display = event.detail.armature.display;
322+
var display = event.detail.armature.display;
333323
var globalPoint = display.convertToWorldSpace(localPoint);
334324

335325
this._fire(globalPoint);
@@ -342,7 +332,7 @@ cc.Class({
342332

343333
var armature = this._armatureDisplay.buildArmature("bullet_01");
344334
var effect = this._armatureDisplay.buildArmature("fireEffect_01");
345-
const radian = this._faceDir < 0 ? Math.PI - this._aimRadian : this._aimRadian;
335+
var radian = this._faceDir < 0 ? Math.PI - this._aimRadian : this._aimRadian;
346336
var bullet = new DragonBullet();
347337
bullet.init(this.node.parent._sgNode, armature, effect, radian + Math.random() * 0.02 - 0.01, 40, firePoint);
348338
this.addBullet(bullet);
@@ -430,7 +420,7 @@ cc.Class({
430420
}
431421
}
432422

433-
const aimOffsetY = this._armature.getBone("chest").global.y * this.node.scaleY;
423+
var aimOffsetY = this._armature.getBone("chest").global.y * this.node.scaleY;
434424

435425
if (this._faceDir > 0) {
436426
this._aimRadian = Math.atan2(-(this._target.y - this.node.y + aimOffsetY), this._target.x - this.node.x);
@@ -455,12 +445,12 @@ cc.Class({
455445
if (this._aimDir >= 0) {
456446
this._aimState = this._armature.animation.fadeIn(
457447
"aimUp", 0, 1,
458-
0, AIM_ANIMATION_GROUP, 2 //dragonBones.AnimationFadeOutMode.SameGroup
448+
0, AIM_ANIMATION_GROUP, dragonBones.AnimationFadeOutMode.SameGroup
459449
);
460450
} else {
461451
this._aimState = this._armature.animation.fadeIn(
462452
"aimDown", 0, 1,
463-
0, AIM_ANIMATION_GROUP, 2 //dragonBones.AnimationFadeOutMode.SameGroup
453+
0, AIM_ANIMATION_GROUP, dragonBones.AnimationFadeOutMode.SameGroup
464454
);
465455
}
466456

@@ -484,7 +474,7 @@ cc.Class({
484474
// Animation mixing.
485475
this._attackState = this._armature.animation.fadeIn(
486476
"attack_01", -1, -1,
487-
0, ATTACK_ANIMATION_GROUP, 2 //dragonBones.AnimationFadeOutMode.SameGroup
477+
0, ATTACK_ANIMATION_GROUP, dragonBones.AnimationFadeOutMode.SameGroup
488478
);
489479

490480
this._attackState.autoFadeOutTime = this._attackState.fadeTotalTime;
@@ -515,7 +505,7 @@ var DragonBullet = cc.Class({
515505

516506
if (effect) {
517507
this._effect = effect;
518-
const effectDisplay = this._effect.display;
508+
var effectDisplay = this._effect.display;
519509
effectDisplay.rotation = radian * dragonBones.DragonBones.RADIAN_TO_ANGLE;
520510
effectDisplay.setPosition(thePos);
521511
effectDisplay.scaleX = 1 + Math.random() * 1;

0 commit comments

Comments
 (0)