Commit a1aa324b authored by limingzhe's avatar limingzhe

fix: 拖拽异常

parent 81415e7d
{"ver":"1.1.2","uuid":"1689616d-6621-4fdf-87ec-126ceba30dc8","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "1689616d-6621-4fdf-87ec-126ceba30dc8",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
......@@ -5,9 +5,9 @@ function RemoteResourceCounter(count, cb) {
this.currentLoadedResourceCount = 0;
this.finishCallback = cb;
}
RemoteResourceCounter.prototype.load = function(num) {
RemoteResourceCounter.prototype.load = function (num) {
this.currentLoadedResourceCount += num;
console.log('RemoteResourceCounter', this.remoteResourceCount , this.currentLoadedResourceCount);
console.log('RemoteResourceCounter', this.remoteResourceCount, this.currentLoadedResourceCount);
if (this.remoteResourceCount <= this.currentLoadedResourceCount) {
this.finishCallback && this.finishCallback();
}
......@@ -22,78 +22,78 @@ cc.Class({
properties: {
videoplayer: {
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.VideoPlayer, // optional, default is typeof default
},
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.VideoPlayer, // optional, default is typeof default
},
cat: {
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
toggleButton: {
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
toggleButtonSprite: {
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
loadingSprite: {
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
// ATTRIBUTES:
default: null, // The default value will be used only when the component attaching
// to a node for the first time
type: cc.Node, // optional, default is typeof default
},
beginAudioClip: cc.AudioClip,
finishAudioClip: cc.AudioClip,
hintAudioClip: cc.AudioClip,
playStatus: {
default: null,
type: cc.SpriteFrame,
default: null,
type: cc.SpriteFrame,
},
pauseStatus: {
default: null,
type: cc.SpriteFrame,
default: null,
type: cc.SpriteFrame,
},
m1: {
default: null,
type: cc.Sprite,
},
default: null,
type: cc.Sprite,
},
m2: {
default: null,
type: cc.Sprite,
},
default: null,
type: cc.Sprite,
},
durationLabel: {
default: null,
type: cc.Label
},
currentTimeLabel: {
default: null,
type: cc.Label
},
barTag: {
default: null,
type: cc.Node
},
default: null,
type: cc.Label
},
currentTimeLabel: {
default: null,
type: cc.Label
},
barTag: {
default: null,
type: cc.Node
},
ProgressBar: {
default: null,
type: cc.ProgressBar
},
default: null,
type: cc.ProgressBar
},
qupeiyinBtn: {
default: null,
type: cc.Sprite
},
default: null,
type: cc.Sprite
},
hintBtn: {
default: null,
type: cc.Button
type: cc.Button
}
},
......@@ -103,35 +103,35 @@ cc.Class({
this.initSceneData();
this.initSize();
this._armatureDisPlay = this.cat.getComponent(dragonBones.ArmatureDisplay);
//获取 Armatrue
this._armature = this._armatureDisPlay.armature();
//获取 Armatrue
this._armature = this._armatureDisPlay.armature();
this._isReadyToPlay = false;
this.toggleButtonSpriteNode = this.toggleButtonSprite.getComponent(cc.Sprite);
this.setButtonPlayStatus(TOGGLE_BUTTON_STATUS.PAUSE);
},
onDestroy() {
this.isPlayMusicAnimation = false;
cc.audioEngine.stop(this.beginAudioID );
cc.audioEngine.stop(this.finishAudioID );
cc.audioEngine.stop(this.hintAudioID );
cc.audioEngine.stop(this.beginAudioID);
cc.audioEngine.stop(this.finishAudioID);
cc.audioEngine.stop(this.hintAudioID);
this.isDestroy = true;
if (this.hideControlId) {
clearTimeout(this.hideControlId);
}
if (this.videoPlayer) {
this.videoplayer.pause();
}
},
ctor() {
ctor() {
this.beginPlayed = false;
this.finishPlayed = false;
this.gameStatus = new RemoteResourceCounter(0, this.hideRabbit.bind(this))
},
......@@ -146,7 +146,7 @@ cc.Class({
onCompleted(player) {
console.log('onCompleted');
// this.videoStatus.isVideoPlaying = false;
if (this.hideControlId) {
clearTimeout(this.hideControlId);
}
......@@ -171,13 +171,13 @@ cc.Class({
}
this.finishPlayed = true;
} else {
this._armatureDisPlay.playAnimation('normal', 0);
if (window && window.courseware && window.courseware.nextPage) {
console.log('call window.courseware.nextPage');
// window.courseware.nextPage();
}
console.log('call window.courseware.nextPage');
// window.courseware.nextPage();
}
}
// this.videoplayer.currentTime = 0 ;
// this.ProgressBar.progress = 0;
......@@ -199,7 +199,7 @@ cc.Class({
this.gameStatus.load(1);
}
},
hideRabbit() {
// console.log('hideRabbit');
......@@ -212,7 +212,7 @@ cc.Class({
// } else {
// this.playGame();
// }
},
playGame() {
console.log('playGame');
......@@ -233,7 +233,7 @@ cc.Class({
}
},
playMusicAnimation(){
playMusicAnimation() {
this.isPlayMusicAnimation = true;
const op1 = this.m1.node.position
const op2 = this.m2.node.position
......@@ -248,32 +248,32 @@ cc.Class({
const dur1 = this.randRange(0.5, 1.2)
const dur2 = this.randRange(0.5, 1.2)
cc.tween(sprNode)
.to(dur1, pos1, { easing: 'cubicOut' })
.to(dur2, pos2, { easing: 'cubicIn' })
.call(() => {
// console.log('anim play ends');
fn(sprNode, op);
})
.start();
.to(dur1, pos1, { easing: 'cubicOut' })
.to(dur2, pos2, { easing: 'cubicIn' })
.call(() => {
// console.log('anim play ends');
fn(sprNode, op);
})
.start();
}
fn(this.m1.node, op1);
fn(this.m2.node, op2);
},
stopMusicAnimation(){
this.isPlayMusicAnimation = false;
stopMusicAnimation() {
this.isPlayMusicAnimation = false;
},
randRange(a, b) {
const t = [a, b].sort()
let r = Math.random() * (t[1] - t[0])
let r = Math.random() * (t[1] - t[0])
if (a >= 1) {
r = Math.random() * (t[1] - t[0] + 1)
r = Math.random() * (t[1] - t[0] + 1)
}
return r + t[0];
return r + t[0];
},
getRandomPosInRect(target, r) {
const x = this.randRange(target.x - r, target.x + r);
const y = this.randRange(target.y - r, target.y + r);
return {x, y}
return { x, y }
},
......@@ -316,6 +316,8 @@ cc.Class({
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
this.canvas = cc.find("Canvas");
},
......@@ -335,14 +337,14 @@ cc.Class({
this.data = JSON.parse(JSON.stringify(this.data))
this.preloadItem()
});
this.qupeiyinBtn.node.on(cc.Node.EventType.TOUCH_START, function() {
this.qupeiyinBtn.node.on(cc.Node.EventType.TOUCH_START, function () {
console.log(123123);
if (window.courseware && window.courseware.nextPage) {
window.courseware.nextPage();
}
}, this);
this.toggleButton.on(cc.Node.EventType.TOUCH_START, function() {
this.toggleButton.on(cc.Node.EventType.TOUCH_START, function () {
this.hideWolf();
this.delayHideControl();
......@@ -351,67 +353,67 @@ cc.Class({
console.log(cc.audioEngine.isMusicPlaying());
if (cc.audioEngine.isMusicPlaying()) {
return;
}
}
cc.audioEngine.stop(this.finishAudioID);
if (this.toggleButton.status == TOGGLE_BUTTON_STATUS.PAUSE) {
this.setButtonPlayStatus(true);
} else {
this.setButtonPlayStatus(false);
}
this._armatureDisPlay.playAnimation('normal', 0);
}, this);
this.hintBtn.node.on('click', function() {
this.hintBtn.node.on('click', function () {
console.log('play hint', (!cc.audioEngine.isMusicPlaying() && !this.videoplayer.isPlaying()));
if (!cc.audioEngine.isMusicPlaying() && !this.videoplayer.isPlaying()){
if (!cc.audioEngine.isMusicPlaying() && !this.videoplayer.isPlaying()) {
this.hintAudioID = cc.audioEngine.playMusic(this.hintAudioClip, false, 1);
this._armatureDisPlay.playAnimation('begin', 0);
cc.audioEngine.setFinishCallback(this.hintAudioID, () => {
this._armatureDisPlay.playAnimation('normal', 0);
})
}
}, this);
// 设置缓冲加载动画 转动
cc.tween(this.loadingSprite)
.by(0.1, { angle: -10 })
.repeatForever()
.start();
.repeatForever()
.start();
// 覆盖Air中的dialogStatus方法 用于监测视频加载状态
if(window['air']) {
if (window['air']) {
window["air"].dialogStatus = (statusCode) => {
console.log("缓冲", statusCode)
if(statusCode == 701) {
if (statusCode == 701) {
// 缓冲中
this.loadingSprite.active = true;
} else if(statusCode == 702) {
} else if (statusCode == 702) {
// 缓冲结束
this.loadingSprite.active = false;
}
}
}
}
cc.view.setResizeCallback((params) => {
console.log('Resize', params);
this.initdDrag()
});
this.initdDrag();
console.log('Resize', params);
this.initdDrag()
});
this.initdDrag();
window.p = this;
},
initdDrag() {
const maxX = this.ProgressBar.node.width;
const minX = 0;
this.barTag.off(cc.Node.EventType.TOUCH_START);
this.barTag.on(cc.Node.EventType.TOUCH_START, (e) => {
const maxX = this.ProgressBar.node.width;
const minX = 0;
this.barTag.off(cc.Node.EventType.TOUCH_START);
this.barTag.on(cc.Node.EventType.TOUCH_START, (e) => {
// return;
if (!this.videoplayer.isPlaying()) {
return
......@@ -422,68 +424,77 @@ cc.Class({
if (!this._isReadyToPlay) {
return;
}
console.log("TOUCH_START");
// this.userDragStart = true;
});
this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
this.barTag.on(cc.Node.EventType.TOUCH_MOVE,(e) => {
console.log("TOUCH_START");
// this.userDragStart = true;
});
this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
this.barTag.on(cc.Node.EventType.TOUCH_MOVE, (e) => {
this.delayHideControl();
this.delayHideControl();
// if (!this.videoplayer.isPlaying() ) {
// return;
// }
// console.log("TOUCH_MOVE");
var delta = e.getDelta();
let newX = this.barTag.x+delta.x;
newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX;
const percent = newX / maxX;
const dur = this.videoplayer.getDuration();
this.currentTimeLabel.string = this.formatTime(percent * dur );
const worldPos = e.getLocation();
const localPos = this.barTag.parent.convertToNodeSpaceAR(worldPos);
let newX = localPos.x;
// var delta = e.getDelta();
// let newX = this.barTag.x + delta.x;
newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX;
const percent = newX / maxX;
const dur = this.videoplayer.getDuration();
this.currentTimeLabel.string = this.formatTime(percent * dur);
// console.log(percent * dur);
this.videoplayer.currentTime = percent * dur;
});
this.barTag.off(cc.Node.EventType.TOUCH_ENDED);
this.barTag.on(cc.Node.EventType.TOUCH_ENDED, (e) => {
console.log("TOUCH_ENDED");
// this.userDragStart = false;
this.updateBarByPos(this.barTag.x);
});
this.barTag.on(cc.Node.EventType.MOUSE_UP, (e) => {
console.log("MOUSE_UP");
// this.userDragStart = false;
this.updateBarByPos(this.barTag.x);
});
// this.barTag.off(cc.Node.EventType.TOUCH_CANCEL);
// this.barTag.on(cc.Node.EventType.TOUCH_CANCEL, (e) => {
// console.log("TOUCH_CANCEL");
// this.userDragStart = false;
// this.updateBarByPos(this.barTag.x);
// });
// this.ProgressBar.node.off(cc.Node.EventType.TOUCH_START);
// this.ProgressBar.node.on(cc.Node.EventType.TOUCH_START, (e) => {
});
this.barTag.off(cc.Node.EventType.TOUCH_ENDED);
this.barTag.on(cc.Node.EventType.TOUCH_ENDED, (e) => {
console.log("TOUCH_ENDED");
// this.userDragStart = false;
this.updateBarByPos(this.barTag.x);
});
this.barTag.on(cc.Node.EventType.MOUSE_UP, (e) => {
console.log("MOUSE_UP");
// this.userDragStart = false;
this.updateBarByPos(this.barTag.x);
});
// this.barTag.off(cc.Node.EventType.TOUCH_CANCEL);
// this.barTag.on(cc.Node.EventType.TOUCH_CANCEL, (e) => {
// console.log("TOUCH_CANCEL");
// this.userDragStart = false;
// this.updateBarByPos(this.barTag.x);
// });
// this.ProgressBar.node.off(cc.Node.EventType.TOUCH_START);
// this.ProgressBar.node.on(cc.Node.EventType.TOUCH_START, (e) => {
// if (this.videoplayer.isPlaying()) {
// const pos = e.getLocation();
// const pPos = this.ProgressBar.node.convertToNodeSpaceAR(pos);
// const newX = Math.min(maxX, Math.max(pPos.x, minX));
// this.updateBarByPos(newX);
// }
// // console.log("ProgressBar TOUCH_START", newX);
// });
// this.node.off(cc.Node.EventType.TOUCH_START);
// this.node.on(cc.Node.EventType.TOUCH_START, (e) => {
// console.log("screen TOUCH_START");
// });
// const pgBar = this.ProgressBar.node;
},
// // console.log("ProgressBar TOUCH_START", newX);
// });
// this.node.off(cc.Node.EventType.TOUCH_START);
// this.node.on(cc.Node.EventType.TOUCH_START, (e) => {
// console.log("screen TOUCH_START");
// });
// const pgBar = this.ProgressBar.node;
},
getData(func) {
if (window && window.courseware) {
window.courseware.getData(func, 'scene');
......@@ -521,7 +532,7 @@ cc.Class({
this.addPreloadAudio(() => {
this.preload();
});
cc.debug.setDisplayStats(false);
},
......@@ -556,7 +567,7 @@ cc.Class({
preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
console.log('preloadArr: ', JSON.stringify( preloadArr) );
console.log('preloadArr: ', JSON.stringify(preloadArr));
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
this.videoplayer.remoteURL = this.data.video_url;
......@@ -569,7 +580,7 @@ cc.Class({
}
});
},
addServerListener() {
console.log('addServerListener');
......@@ -586,8 +597,8 @@ cc.Class({
addPreloadAudio(callback) {
this._audioResList.push({url: this.data.finish_audio_url || ''});
this._audioResList.push({url: this.data.hint_audio_url || ''});
this._audioResList.push({ url: this.data.finish_audio_url || '' });
this._audioResList.push({ url: this.data.hint_audio_url || '' });
const url1 = this.data.video_url;
if (!url1) {
......@@ -602,7 +613,7 @@ cc.Class({
this._audioResList.push({ url: url || '' });
callback();
})
})
},
getVideoUrl(callback) {
const url1 = this.data.video_url;
......@@ -687,7 +698,7 @@ cc.Class({
this.controlNode = cc.find("Canvas/Controls");
this.wolfNode = cc.find("Canvas/catBox");
this.controlNode.active = false;
this.wolfNode.active = false;
},
......@@ -718,7 +729,7 @@ cc.Class({
if (this.toggleButton.status == TOGGLE_BUTTON_STATUS.PLAY) {
return;
}
this.toggleButtonSpriteNode.spriteFrame= this.pauseStatus;
this.toggleButtonSpriteNode.spriteFrame = this.pauseStatus;
this.toggleButton.status = TOGGLE_BUTTON_STATUS.PLAY;
this.videoplayer.play();
this.playMusicAnimation();
......@@ -726,7 +737,7 @@ cc.Class({
if (this.toggleButton.status == TOGGLE_BUTTON_STATUS.PAUSE) {
return;
}
this.toggleButtonSpriteNode.spriteFrame= this.playStatus ;
this.toggleButtonSpriteNode.spriteFrame = this.playStatus;
this.toggleButton.status = TOGGLE_BUTTON_STATUS.PAUSE;
this.videoplayer.pause();
this.stopMusicAnimation();
......@@ -736,73 +747,73 @@ cc.Class({
return !!this.toggleButton.status;
},
updateBarByPos(newX) {
const maxX = this.ProgressBar.node.width;
const minX = 0;
const percent = newX / maxX;
updateBarByPos(newX) {
const maxX = this.ProgressBar.node.width;
const minX = 0;
const percent = newX / maxX;
if (percent > 1) {
percent = 1
}
this.ProgressBar.progress = percent;
const dur = this.videoplayer.getDuration();
console.log('updateBarByPos',percent * dur);
this.videoplayer.currentTime = percent * dur
},
updateBarByTime(ct){
this.currentTimeLabel.string = this.formatTime(ct);
const dur = this.videoplayer.getDuration();
let percent = ct / dur;
this.ProgressBar.progress = percent;
const dur = this.videoplayer.getDuration();
console.log('updateBarByPos', percent * dur);
this.videoplayer.currentTime = percent * dur
},
updateBarByTime(ct) {
this.currentTimeLabel.string = this.formatTime(ct);
const dur = this.videoplayer.getDuration();
let percent = ct / dur;
if (percent > 1) {
percent = 1
}
this.ProgressBar.progress = percent;
const maxX = this.ProgressBar.node.width;
const minX = 0;
let newX = percent * maxX;
newX = Math.min(maxX, Math.max(newX, minX));
const maxX = this.ProgressBar.node.width;
const minX = 0;
let newX = percent * maxX;
newX = Math.min(maxX, Math.max(newX, minX));
// console.log('updateBarByTime', newX);
this.barTag.x = newX;
},
formatTime(time) {
if (time === undefined) {
return '';
}
let hh = Math.floor(time / 60 / 60);
if (hh > 0) {
hh = `${hh.toString().padStart(2, '0')}:`;
} else {
hh = '';
}
const mm = Math.floor(time / 60).toString().padStart(2, '0');
const ss = Math.round(time % 60).toString().padStart(2, '0');
return `${hh}${mm}:${ss}`;
},
update (dt) {
this.barTag.x = newX;
},
formatTime(time) {
if (time === undefined) {
return '';
}
let hh = Math.floor(time / 60 / 60);
if (hh > 0) {
hh = `${hh.toString().padStart(2, '0')}:`;
} else {
hh = '';
}
const mm = Math.floor(time / 60).toString().padStart(2, '0');
const ss = Math.round(time % 60).toString().padStart(2, '0');
return `${hh}${mm}:${ss}`;
},
update(dt) {
if (this.toggleButtonSpriteNode) {
// console.log(this.userDragStart);
// console.log(this.userDragStart);
const ct = this.videoplayer.currentTime;
if (ct) {
this.updateBarByTime(ct);
}
if (ct) {
this.updateBarByTime(ct);
}
if (this.videoplayer.isPlaying()) {
if (this.videoplayer.isPlaying()) {
if (this.toggleButton.status === TOGGLE_BUTTON_STATUS.PLAY) {
return;
}
this.setButtonPlayStatus(false);
} else {
this.setButtonPlayStatus(false);
} else {
if (this.toggleButton.status === TOGGLE_BUTTON_STATUS.PAUSE) {
return;
}
this.setButtonPlayStatus(true);
}
}
this.setButtonPlayStatus(true);
}
}
},
......@@ -888,7 +899,7 @@ cc.Class({
this.initReplayBtn();
this.initArrowBtn();
},
initArrowBtn() {
......@@ -909,7 +920,7 @@ cc.Class({
initReplayBtn() {
this.replayBtn = cc.find("Canvas/btn_replay");
this.replayBtn.on('touchstart', () => {
this.hideWolf();
this.delayHideControl();
......@@ -917,11 +928,11 @@ cc.Class({
console.log(cc.audioEngine.isMusicPlaying());
if (cc.audioEngine.isMusicPlaying()) {
return;
}
}
cc.audioEngine.stop(this.finishAudioID);
if (this.toggleButton.status == TOGGLE_BUTTON_STATUS.PAUSE) {
this.setButtonPlayStatus(true);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment