| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- cc.Class({
- extends: cc.Component,
- properties: {
- scaleX:1,
- AudioControllerNode: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- TalkingLabelNode:
- {
- default: null,
- type: cc.Node,
- serializable: true,
- }
- },
- start () {
- this.PunchedFaceNode = this.node.getChildByName("PunchedFace");
- this.LaughingFaceNode = this.node.getChildByName("LaughingFace");
- //动画
- this.PunchingAnimNode = this.node.getChildByName("PunchingAnim");
- this.armatureDisplay = this.PunchingAnimNode.getComponent(dragonBones.ArmatureDisplay);
- this.armature = this.armatureDisplay.armature();
- //添加动画事件监听
- this.armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, this.animationEventHandler, this);
- this.armatureDisplay.addEventListener(dragonBones.EventObject.FRAME_EVENT, this.animationEventHandler_Enter, this);
- this.StartAnim();
- this.AudioControllerScp = this.AudioControllerNode.getComponent('AudioController');
- //川普say china
- this.sayChinaCount = 0;
-
- this.AudioControllerScp.playAudio('Game/Audios/ChinaThatThanMe.mp3',function () {
- //this.TalkChinaFinished(this);
- }.bind(this));
- },
- StartAnim()
- {
- this.FlapX();
- this.schedule(this.FlapX, 0.5, cc.macro.REPEAT_FOREVER);
- },
- StopAnim()
- {
- this.unschedule(this.FlapX);
- },
- Win(callback)
- {
- this.StopAnim();
- this.PunchedFaceNode.active=true;
- this.armature.animation.play("attack1", 1);
- this.AudioControllerScp.playAudio('Game/Audios/Hit.mp3',function(){
- this.PunchedFaceNode.active = false;
- callback();
- }.bind(this));
- },
- Fail(callback)
- {
- this.LaughingFaceNode.active = true;
- this.AudioControllerScp.playAudio('Game/Audios/Laughing.mp3',function(){
- this.LaughingFaceNode.active = false;
- callback();
- }.bind(this));
- },
- FlapX()
- {
- this.scaleX = -this.scaleX;
- this.node.setScale(this.scaleX,1);
- if(this.scaleX == 1)
- {
- this.TalkingLabelNode.setScale(1,1);
- }
- else
- {
- this.TalkingLabelNode.setScale(-1,1);
- }
- },
- animationEventHandler(event)
- {
- if (event.type === dragonBones.EventObject.COMPLETE) {
- //主角
- if (event.animationState.name === "attack1") {
-
- }
- }
- },
- animationEventHandler_Enter(event) {
- },
- TalkChinaFinished(self)
- {
- self.scheduleOnce(function() {
- self.AudioControllerScp.playAudio('Game/Audios/China.mp3',function () {
- self.TalkChinaFinished(self);
- });
- },Math.floor(Math.random()*20+1))
- // let rate = Math.floor(Math.random()*10);
- // console.log(rate)
- // //if(Boolean(Math.round(Math.random())))
- // if(rate<3)
- // {
- // self.scheduleOnce(function() {
- // self.AudioControllerScp.playAudio('Game/Audios/BelieveMe.mp3',function () {
- // self.TalkChinaFinished(self);
- // });
- // },Math.floor(Math.random()*10+1))
- // }
- // else
- // {
- // self.scheduleOnce(function() {
- // self.AudioControllerScp.playAudio('Game/Audios/China.mp3',function () {
- // self.TalkChinaFinished(self);
- // });
- // },Math.floor(Math.random()*10+1))
- // }
- }
- });
|