Commit 519a274e authored by limingzhe's avatar limingzhe

feat: 添加 spine

parent 2d11e844
File added
import { onHomeworkFinish, RandomInt, playAudioByUrl, loadDragonBones, getSpriteFrimeByUrl } from "../script/util";
import { onHomeworkFinish, RandomInt, playAudioByUrl, loadDragonBones, getSpriteFrimeByUrl, loadSpine } from "../script/util";
import { defaultData } from "../script/defaultData";
import { assign, createMachine, interpret, actions, forwardTo, matchesState } from "../script/xstate";
const { pure , send, raise, sendParent } = actions;
......@@ -457,6 +457,17 @@ cc.Class({
const k = this._hintsNodeList[i].after;
after[k]= {
actions: () => {
if (t.isSpine) {
const skeleton = t.getComponent(sp.Skeleton);
skeleton.pause();
skeleton.loop = false;
skeleton.animation = 'enlarge';
// skeleton.animation = skeleton.animationNames[0];
} else {
const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('enlarge', 1);
console.log(dragonDisplay._armatureKey, 'enlarge')
......@@ -466,6 +477,8 @@ cc.Class({
// event.armature.animation.play('normal', 0);
// console.log(event.animationState.name, dragonDisplay._armatureKey, 'end')
}, this);
}
// const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
......@@ -488,12 +501,22 @@ cc.Class({
for(let i = 0 ;i < this._allAnimationNodes.length; i++) {
const t = this._allAnimationNodes[i];
if (t.isSpine) {
const skeleton = t.getComponent(sp.Skeleton);
skeleton.pause();
skeleton.loop = true;
skeleton.animation = 'normal'
// skeleton.animation = skeleton.animationNames[0];
} else {
const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('normal', 0);
}
}
}
}
}
state.states.begin.after = after;
......@@ -505,7 +528,9 @@ cc.Class({
// console.log(1, state.value, state.context);
});
this.gameMachineService.start();
if (window.gameMachineService) {
window.gameMachineService = gameMachineService;
}
},
......@@ -586,7 +611,8 @@ cc.Class({
},
getDefaultData() {
return defaultData;
return {"begin_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","begin_sep_time":1,"guide_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","playing_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","right_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","wrong_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","wrong_audio1":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","wrong_audio2":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","end_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/84ec6edc20bceaaa9dbe824092b6860d.png","rect":{"x":549.55,"y":0,"width":449.9,"height":582}},"hotZoneItemArr":[{"id":"1659333645573","index":0,"audio_url":"http://staging-teach.cdn.ireadabc.com/5a1a2670845bfe76662e86d9a3a69f81.mp3","itemType":"rect","fontScale":1.21015625,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.21015625,"dragDot":{"x":774.5,"y":289.55016883743366},"gIdx":"1","labelText":"1","posX":887.5,"posY":165.5,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/d1f859d3fba84bd03565e543c986fb28.json","name":"6_4_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/70f96e1cc7f013e27ed1952c503fb750.json","name":"6_4_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b06f9b90018a6eb0175a01e355b9ced6.png","name":"6_4_tex.png"},"animType":"dragonBone","rect":{"x":36.08,"y":49.19,"width":153.95,"height":150.19}},{"id":"1659334098930","index":1,"audio_url":"http://staging-teach.cdn.ireadabc.com/16eb06a6beb9e4fa77c9b5d2d643ab29.mp3","itemType":"rect","fontScale":1.21015625,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.21015625,"dragDot":{"x":774.5,"y":289.55016883743366},"gIdx":"0","labelText":"1","posX":1212.5,"posY":643.5,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/bdbadb06e0c1157e727cecd28f28d10e.json","name":"spineboy-pro.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/e0945b8265ea3b8053afb814c6b849d3.atlas","name":"spineboy-pro.atlas"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/517553f50224915148f9efc5b7556798.png","name":"spineboy-pro.png"},"animType":"spine","rect":{"x":282.03,"y":408.15,"width":150.19,"height":150.19}}]}
// return defaultData;
},
preloadItem() {
......@@ -783,11 +809,48 @@ cc.Class({
}
if (block.gIdx == '0' || block.gIdx == '1') {
const n = new cc.Node();
n.scale = 0.25;
const db = n.addComponent(dragonBones.ArmatureDisplay);
n.parent = ground;
n.active = false;
if (block.animType == 'spine') {
const skeleton = n.addComponent(sp.Skeleton);
n.isSpine = true;
loadSpine(skeleton, block.texPngData.name, {
tex: block.texPngData.url,
atlas: block.texJsonData.url,
ske: block.skeJsonData.url,
}).then(({width, height}) => {
n.width = width;
n.height = height;
n.active = true;
// db.playAnimation('null', 0);
// skeleton.loop = true;
// skeleton.animation = skeleton.animationNames[0]
this._allAnimationNodes.push(n);
finishDbCount++;
console.log(finishDbCount, dbCount)
if (finishDbCount == dbCount) {
this.loadEnd();
}
}).catch(() => {
finishDbCount++;
console.log(finishDbCount, dbCount)
if (finishDbCount == dbCount) {
this.loadEnd();
}
});
} else {
const db = n.addComponent(dragonBones.ArmatureDisplay);
loadDragonBones(db, {
tex: block.texPngData.url,
atlas: block.texJsonData.url,
......@@ -810,6 +873,10 @@ cc.Class({
this.loadEnd();
}
});
}
if (block.gIdx == '0') {
const rectInfo = {
node: n,
......
......@@ -400,3 +400,78 @@ export function loadDragonBones(dragonDisplay,{tex, atlas, ske}) {
});
}
export function loadSpine(skeleton, picName, {tex, atlas, ske}) {
return new Promise((resolve, reject) => {
// cc.loader.load({ url: tex, type: 'png' }, (error, texture) => {
cc.assetManager.loadRemote(tex, (error, texture) => {
if (error) {
reject();
return;
}
// cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.assetManager.loadAny({ url: atlas }, (error, atlasJson) => {
if (error) {
reject();
return;
}
// cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
cc.assetManager.loadAny({ url: ske }, (error, dragonBonesJson) => {
if (error) {
reject();
return;
}
var asset = new sp.SkeletonData();
asset._uuid = ske;
asset.skeletonJson = JSON.stringify( dragonBonesJson );
asset.atlasText = atlasJson;
asset.textures = [texture];
asset.textureNames = [picName];
console.log('picName: ', picName);
skeleton.skeletonData = asset;
const jsonObj = dragonBonesJson //JSON.parse( assets[1]);
const animationNameObj = jsonObj.animations;
let animationNames = [];
for (let name in animationNameObj) {
console.log('name~~: ', name);
animationNames.push(name);
}
console.log("skeleton.animation: ", skeleton.animation);
skeleton.animationNames = animationNames;
skeleton.loop = false;
console.log("jsonObj['skeleton'] : ", jsonObj['skeleton'])
resolve(jsonObj['skeleton']);
// const atlasObj = new dragonBones.DragonBonesAtlasAsset()
// atlasObj.uuid = atlas
// atlasObj.atlasJson = atlasJson
// atlasObj.texture = texture
// const asset = new dragonBones.DragonBonesAsset()
// asset.uuid = ske
// asset.dragonBonesJson = dragonBonesJson;
// const armatureName = asset._dragonBonesJsonData.armature[0].name || 'default';
// dragonDisplay.armatureName = armatureName;
// dragonDisplay.dragonAtlasAsset = atlasObj
// dragonDisplay.dragonAsset = asset;
// resolve(asset._dragonBonesJsonData.armature[0].aabb);
});
});
});
});
}
......@@ -128,5 +128,8 @@
}
}
},
"defaultProject": "ng-template-generator"
"defaultProject": "ng-template-generator",
"cli": {
"analytics": "61925577-1d89-4137-97e7-a79129dc9dd5"
}
}
\ No newline at end of file
......@@ -20,10 +20,10 @@
"@angular/platform-browser": "~9.0.2",
"@angular/platform-browser-dynamic": "~9.0.2",
"@angular/router": "~9.0.2",
"@fortawesome/angular-fontawesome": "^0.6.0",
"@fortawesome/fontawesome-svg-core": "^1.2.27",
"@fortawesome/free-regular-svg-icons": "^5.12.1",
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@fortawesome/angular-fontawesome": "0.6.0",
"@fortawesome/fontawesome-svg-core": "1.2.27",
"@fortawesome/free-regular-svg-icons": "5.12.1",
"@fortawesome/free-solid-svg-icons": "5.12.1",
"@tweenjs/tween.js": "~18.5.0",
"ali-oss": "^6.5.1",
"compressing": "^1.5.0",
......
......@@ -2,7 +2,7 @@
<h5 style="margin-left: 2.5%;"> preview: </h5>
<div class="preview-box" #wrap>
<div class="preview-box" [style.height]="isRotate ? '95vw' : '35vw'" #wrap>
<canvas id="canvas" #canvas></canvas>
</div>
......@@ -69,17 +69,34 @@
</div>
<div *ngIf="customTypeGroupArr[it.gIdx].anima" align="center" style="margin-top: 5px">
<button nz-button (click)="setAnimaBtnClick(i)" >
<!-- <button nz-button (click)="setAnimaBtnClick(i)" >
<i nz-icon nzType="tool" nzTheme="outline"></i>
配置龙骨动画
</button>
</button> -->
<app-upload-dragon-bone
[skeJsonData]="it.skeJsonData || {}"
[texJsonData]="it.texJsonData || {}"
[texPngData]="it.texPngData || {}"
[animType]="it.animType || 'dragonBone'"
(save)="saveAnim($event, it)">
</app-upload-dragon-bone>
</div>
<div *ngIf="customTypeGroupArr[it.gIdx].animaSmall" align="center" style="margin-top: 5px">
<button nz-button (click)="setAnimaSmallBtnClick(i)" >
<!-- <button nz-button (click)="setAnimaSmallBtnClick(i)" >
<i nz-icon nzType="tool" nzTheme="outline"></i>
配置龙骨动画(小)
</button>
</button> -->
<app-upload-dragon-bone
[skeJsonData]="it.skeJsonData || {}"
[texJsonData]="it.texJsonData || {}"
[texPngData]="it.texPngData || {}"
(save)="saveAnim($event, it)">
</app-upload-dragon-bone>
</div>
......@@ -91,15 +108,15 @@
></app-audio-recorder>
</div>
<!-- <div *ngIf="customTypeGroupArr[it.gIdx]?.action" style="display: flex;align-items: center; margin-top: 5px">-->
<!-- <app-custom-action-->
<!-- style="margin: auto"-->
<!-- [item]="it ? it['actionData_' + it.gIdx] : {}"-->
<!-- [type]="customTypeGroupArr[it.gIdx].action.type"-->
<!-- [option]="customTypeGroupArr[it.gIdx].action.option"-->
<!-- (save)="onSaveCustomAction($event, it)">-->
<!-- ></app-custom-action>-->
<!-- </div>-->
<!-- <div *ngIf="customTypeGroupArr[it.gIdx]?.action" style="display: flex;align-items: center; margin-top: 5px">
<app-custom-action
style="margin: auto"
[item]="it ? it['actionData_' + it.gIdx] : {}"
[type]="customTypeGroupArr[it.gIdx].action.type"
[option]="customTypeGroupArr[it.gIdx].action.option"
(save)="onSaveCustomAction($event, it)">
></app-custom-action>
</div> -->
<div *ngIf="customTypeGroupArr[it.gIdx]?.isShowPos" style="display: flex; align-items: center; justify-content: center; margin-top: 5px;">
x: <input type="text" nz-input [(ngModel)]="it.posX" style="width: 50px; margin-right: 15px;" (blur)="saveItemPos(it)">
......@@ -118,11 +135,11 @@
<input type="text" nz-input [(ngModel)]="it.labelText" (blur)="saveText(it)">
</div>
<!-- <div *ngIf="customTypeGroupArr[it.gIdx]?.mathLabel" align="center" style="margin-top: 5px; display: flex; align-items: center; justify-content: center;">-->
<!-- <span style="width: 30%;">{{customTypeGroupArr[it.gIdx].mathLabel + ':'}}</span>-->
<!-- <app-formula-input [(ngfModel)]="it.mathLabel" ></app-formula-input>-->
<!-- <div *ngIf="customTypeGroupArr[it.gIdx]?.mathLabel" align="center" style="margin-top: 5px; display: flex; align-items: center; justify-content: center;">
<span style="width: 30%;">{{customTypeGroupArr[it.gIdx].mathLabel + ':'}}</span>
<app-formula-input [(ngfModel)]="it.mathLabel" ></app-formula-input>
<!-- </div>-->
</div> -->
<div *ngIf="customTypeGroupArr[it.gIdx]?.isCopy" align="center" style="margin-top: 5px; display: flex; align-items: center; justify-content: center;">
......@@ -226,6 +243,7 @@
<!--龙骨面板-->
<!--
<nz-modal [(nzVisible)]="animaPanelVisible" nzTitle="配置资源文件" (nzAfterClose)="closeAfterPanel()" (nzOnCancel)="animaPanelCancel()" (nzOnOk)="animaPanelOk()" nzOkText="保存">
<div class="anima-upload-btn">
......@@ -271,6 +289,6 @@
提示:需包含以下动画: {{customTypeGroupArr[curDragonBoneGIdx].animaNames.toString()}}
</div>
</nz-modal>
</nz-modal> -->
......@@ -11,8 +11,17 @@
<nz-modal [(nzVisible)]="animaPanelVisible" (nzAfterClose)="closePanel()" nzTitle="配置资源文件"
(nzOnCancel)="animaPanelCancel()" (nzOnOk)="animaPanelOk()" nzOkText="保存">
<nz-radio-group [ngModel]="animType" (ngModelChange)="animRadioChange($event)" style="display: flex; align-items: center; justify-content: center; flex-wrap: wrap;">
<div style="display: flex; ">
<label nz-radio nzValue="dragonBone">龙骨</label>
<label nz-radio nzValue="spine">spine</label>
</div>
</nz-radio-group>
<div class="anima-upload-btn">
<span style="margin-right: 10px">上传 ske_json 文件: </span>
<span *ngIf="animType == 'dragonBone'" style="margin-right: 10px">上传 ske_json 文件: </span>
<span *ngIf="animType == 'spine'" style="margin-right: 10px">上传 json 文件: </span>
<nz-upload [nzShowUploadList]="false" nzAccept="application/json" [nzAction]="uploadUrl" [nzData]="uploadData"
(nzChange)="skeJsonHandleChange($event)">
<button nz-button><i nz-icon nzType="upload"></i><span>Upload</span></button>
......@@ -22,8 +31,9 @@
</div>
<div class="anima-upload-btn">
<span style="margin-right: 10px">上传 tex_json 文件: </span>
<nz-upload [nzShowUploadList]="false" nzAccept="application/json" [nzAction]="uploadUrl" [nzData]="uploadData"
<span *ngIf="animType == 'dragonBone'" style="margin-right: 10px">上传 tex_json 文件: </span>
<span *ngIf="animType == 'spine'" style="margin-right: 10px">上传 atlas 文件: </span>
<nz-upload [nzShowUploadList]="false" [nzAccept]="animType == 'dragonBone' ? '.json' : '.atlas'" [nzAction]="uploadUrl" [nzData]="uploadData"
(nzChange)="texJsonHandleChange($event)">
<button nz-button><i nz-icon nzType="upload"></i><span>Upload</span></button>
</nz-upload>
......@@ -32,7 +42,8 @@
</div>
<div class="anima-upload-btn">
<span style="margin-right: 10px">上传 tex_png 文件: </span>
<span *ngIf="animType == 'dragonBone'" style="margin-right: 10px">上传 tex_png 文件: </span>
<span *ngIf="animType == 'spine'" style="margin-right: 10px">上传 png 文件: </span>
<nz-upload [nzShowUploadList]="false" nzAccept="image/*" [nzAction]="uploadUrl" [nzData]="uploadData"
(nzChange)="texPngHandleChange($event)">
<button nz-button><i nz-icon nzType="upload"></i><span>Upload</span></button>
......
......@@ -11,7 +11,7 @@ export class UploadDragonBoneComponent implements OnDestroy, OnChanges {
uploading = false;
progress = 0;
@Input()
btnName = '配置龙骨动画';
btnName = '配置骨骼动画';
@Input()
animaNames = [];
......@@ -21,32 +21,16 @@ export class UploadDragonBoneComponent implements OnDestroy, OnChanges {
texJsonData = {};
@Input()
texPngData = {};
@Input()
animType;
@Output()
save = new EventEmitter();
@Output()
refreshEmitter = new EventEmitter();
// @Input()
// picUrl;
// @Input()
// canDelete = false;
// @Output()
// imageUploaded = new EventEmitter();
// @Output()
// imageUploadFailure = new EventEmitter();
// @Output()
// delete = new EventEmitter();
// @Input()
// picItem = null;
// @Input()
// iconSize = 2;
// @Input()
// TIP = 'Click here to upload image';
// @Input()
// disableUpload = false;
uploadUrl;
uploadData;
......@@ -93,6 +77,7 @@ export class UploadDragonBoneComponent implements OnDestroy, OnChanges {
data['skeJsonData'] = this.skeJsonData;
data['texJsonData'] = this.texJsonData;
data['texPngData'] = this.texPngData;
data['animType'] = this.animType;
this.save.emit(data);
}
......@@ -155,6 +140,11 @@ export class UploadDragonBoneComponent implements OnDestroy, OnChanges {
}
animRadioChange(e) {
console.log(" in animRadioChange: ", e);
this.animType = e;
}
/**
* 刷新 渲染页面
......
This diff is collapsed.
......@@ -28,6 +28,7 @@ exports.asyncTweenBy = asyncTweenBy;
exports.showTrebleFirework = showTrebleFirework;
exports.onHomeworkFinish = onHomeworkFinish;
exports.loadDragonBones = loadDragonBones;
exports.loadSpine = loadSpine;
exports.FireworkSettings = void 0;
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
......@@ -354,7 +355,7 @@ function _showFireworks() {
case 0:
baseNode = fireworkSettings.baseNode, nodeList = fireworkSettings.nodeList, pos = fireworkSettings.pos, side = fireworkSettings.side, range = fireworkSettings.range, number = fireworkSettings.number, scalseRange = fireworkSettings.scalseRange;
new Array(number).fill(' ').forEach( /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_, i) {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_, i) {
var rabbonNode, node, rate, angle;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
......@@ -422,7 +423,7 @@ function _showFireworks() {
}));
return function (_x12, _x13) {
return _ref2.apply(this, arguments);
return _ref3.apply(this, arguments);
};
}());
......@@ -618,4 +619,74 @@ function loadDragonBones(dragonDisplay, _ref) {
});
}
function loadSpine(skeleton, picName, _ref2) {
var tex = _ref2.tex,
atlas = _ref2.atlas,
ske = _ref2.ske;
return new Promise(function (resolve, reject) {
// cc.loader.load({ url: tex, type: 'png' }, (error, texture) => {
cc.assetManager.loadRemote(tex, function (error, texture) {
if (error) {
reject();
return;
} // cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.assetManager.loadAny({
url: atlas
}, function (error, atlasJson) {
if (error) {
reject();
return;
} // cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
cc.assetManager.loadAny({
url: ske
}, function (error, dragonBonesJson) {
if (error) {
reject();
return;
}
var asset = new sp.SkeletonData();
asset._uuid = ske;
asset.skeletonJson = JSON.stringify(dragonBonesJson);
asset.atlasText = atlasJson;
asset.textures = [texture];
asset.textureNames = [picName];
console.log('picName: ', picName);
skeleton.skeletonData = asset;
var jsonObj = dragonBonesJson; //JSON.parse( assets[1]);
var animationNameObj = jsonObj.animations;
var animationNames = [];
for (var name in animationNameObj) {
console.log('name~~: ', name);
animationNames.push(name);
}
console.log("skeleton.animation: ", skeleton.animation);
skeleton.animationNames = animationNames;
skeleton.loop = false;
console.log("jsonObj['skeleton'] : ", jsonObj['skeleton']);
resolve(jsonObj['skeleton']); // const atlasObj = new dragonBones.DragonBonesAtlasAsset()
// atlasObj.uuid = atlas
// atlasObj.atlasJson = atlasJson
// atlasObj.texture = texture
// const asset = new dragonBones.DragonBonesAsset()
// asset.uuid = ske
// asset.dragonBonesJson = dragonBonesJson;
// const armatureName = asset._dragonBonesJsonData.armature[0].name || 'default';
// dragonDisplay.armatureName = armatureName;
// dragonDisplay.dragonAtlasAsset = atlasObj
// dragonDisplay.dragonAsset = asset;
// resolve(asset._dragonBonesJsonData.armature[0].aabb);
});
});
});
});
}
cc._RF.pop();
\ No newline at end of file
......@@ -450,6 +450,7 @@ cc.Class({
(0, _util.playAudioByUrl)(_this.data.end_audio, function () {
console.log('game finish');
(0, _util.onHomeworkFinish)();
}); // return new Promise((resolve,reject) => {
// setTimeout(() => {
// console.log('hint finish');
......@@ -467,6 +468,12 @@ cc.Class({
var k = _this._hintsNodeList[i].after;
after[k] = {
actions: function actions() {
if (t.isSpine) {
var skeleton = t.getComponent(sp.Skeleton);
skeleton.pause();
skeleton.loop = false;
skeleton.animation = 'enlarge'; // skeleton.animation = skeleton.animationNames[0];
} else {
var dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('enlarge', 1);
console.log(dragonDisplay._armatureKey, 'enlarge');
......@@ -474,7 +481,8 @@ cc.Class({
// event.name为事件名称
// event.armature.animation.play('normal', 0);
// console.log(event.animationState.name, dragonDisplay._armatureKey, 'end')
}, _this); // const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
}, _this);
} // const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
// dragonDisplay.playAnimation('enlarge', 1);
// console.log(dragonDisplay._armatureKey, 'enlarge')
// dragonDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event) => {
......@@ -483,6 +491,7 @@ cc.Class({
// event.armature.animation.play('normal', 0);
// console.log(event.animationState.name, dragonDisplay._armatureKey, 'end')
// }, this);
}
};
};
......@@ -500,11 +509,19 @@ cc.Class({
for (var _i = 0; _i < _this._allAnimationNodes.length; _i++) {
var _t = _this._allAnimationNodes[_i];
if (_t.isSpine) {
var skeleton = _t.getComponent(sp.Skeleton);
skeleton.pause();
skeleton.loop = true;
skeleton.animation = 'normal'; // skeleton.animation = skeleton.animationNames[0];
} else {
var dragonDisplay = _t.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('normal', 0);
}
}
}
};
}
......@@ -514,7 +531,10 @@ cc.Class({
this.gameMachineService = (0, _xstate.interpret)(gameMachine).onTransition(function (state) {// console.log(1, state.value, state.context);
});
this.gameMachineService.start();
if (window.gameMachineService) {
window.gameMachineService = gameMachineService;
}
},
// 生命周期 start
start: function start() {
......@@ -605,7 +625,101 @@ cc.Class({
func(this.getDefaultData());
},
getDefaultData: function getDefaultData() {
return _defaultData.defaultData;
return {
"begin_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"begin_sep_time": 1,
"guide_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"playing_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"right_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"wrong_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"wrong_audio1": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"wrong_audio2": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"end_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"bgItem": {
"url": "http://staging-teach.cdn.ireadabc.com/84ec6edc20bceaaa9dbe824092b6860d.png",
"rect": {
"x": 549.55,
"y": 0,
"width": 449.9,
"height": 582
}
},
"hotZoneItemArr": [{
"id": "1659333645573",
"index": 0,
"audio_url": "http://staging-teach.cdn.ireadabc.com/5a1a2670845bfe76662e86d9a3a69f81.mp3",
"itemType": "rect",
"fontScale": 1.21015625,
"imgScale": 1,
"imgSizeW": 0,
"imgSizeH": 0,
"mapScale": 1.21015625,
"dragDot": {
"x": 774.5,
"y": 289.55016883743366
},
"gIdx": "1",
"labelText": "1",
"posX": 887.5,
"posY": 165.5,
"skeJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/d1f859d3fba84bd03565e543c986fb28.json",
"name": "6_4_ske.json"
},
"texJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/70f96e1cc7f013e27ed1952c503fb750.json",
"name": "6_4_tex.json"
},
"texPngData": {
"url": "http://staging-teach.cdn.ireadabc.com/b06f9b90018a6eb0175a01e355b9ced6.png",
"name": "6_4_tex.png"
},
"animType": "dragonBone",
"rect": {
"x": 36.08,
"y": 49.19,
"width": 153.95,
"height": 150.19
}
}, {
"id": "1659334098930",
"index": 1,
"audio_url": "http://staging-teach.cdn.ireadabc.com/16eb06a6beb9e4fa77c9b5d2d643ab29.mp3",
"itemType": "rect",
"fontScale": 1.21015625,
"imgScale": 1,
"imgSizeW": 0,
"imgSizeH": 0,
"mapScale": 1.21015625,
"dragDot": {
"x": 774.5,
"y": 289.55016883743366
},
"gIdx": "0",
"labelText": "1",
"posX": 1212.5,
"posY": 643.5,
"skeJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/bdbadb06e0c1157e727cecd28f28d10e.json",
"name": "spineboy-pro.json"
},
"texJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/e0945b8265ea3b8053afb814c6b849d3.atlas",
"name": "spineboy-pro.atlas"
},
"texPngData": {
"url": "http://staging-teach.cdn.ireadabc.com/517553f50224915148f9efc5b7556798.png",
"name": "spineboy-pro.png"
},
"animType": "spine",
"rect": {
"x": 282.03,
"y": 408.15,
"width": 150.19,
"height": 150.19
}
}]
}; // return defaultData;
},
preloadItem: function preloadItem() {
this.addPreloadImage();
......@@ -855,10 +969,13 @@ cc.Class({
(function () {
var n = new cc.Node();
n.scale = 0.25;
var db = n.addComponent(dragonBones.ArmatureDisplay);
n.parent = ground;
n.active = false;
(0, _util.loadDragonBones)(db, {
if (_block.animType == 'spine') {
var skeleton = n.addComponent(sp.Skeleton);
n.isSpine = true;
(0, _util.loadSpine)(skeleton, _block.texPngData.name, {
tex: _block.texPngData.url,
atlas: _block.texJsonData.url,
ske: _block.skeJsonData.url
......@@ -867,6 +984,37 @@ cc.Class({
height = _ref.height;
n.width = width;
n.height = height;
n.active = true; // db.playAnimation('null', 0);
// skeleton.loop = true;
// skeleton.animation = skeleton.animationNames[0]
_this4._allAnimationNodes.push(n);
finishDbCount++;
console.log(finishDbCount, dbCount);
if (finishDbCount == dbCount) {
_this4.loadEnd();
}
})["catch"](function () {
finishDbCount++;
console.log(finishDbCount, dbCount);
if (finishDbCount == dbCount) {
_this4.loadEnd();
}
});
} else {
var db = n.addComponent(dragonBones.ArmatureDisplay);
(0, _util.loadDragonBones)(db, {
tex: _block.texPngData.url,
atlas: _block.texJsonData.url,
ske: _block.skeJsonData.url
}).then(function (_ref2) {
var width = _ref2.width,
height = _ref2.height;
n.width = width;
n.height = height;
n.active = true;
db.playAnimation('null', 0);
......@@ -886,6 +1034,7 @@ cc.Class({
_this4.loadEnd();
}
});
}
if (_block.gIdx == '0') {
var rectInfo = {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
{"version":"1.0.8","stats":{"/Users/admin/workspace/OP15/temp/quick-scripts/src/__qc_index__.js":"2022-01-10T08:17:43.297Z","/Users/admin/workspace/OP15/temp/quick-scripts/src/assets/OP15/scene/OP15.js":"2022-01-10T08:17:43.274Z","/Users/admin/workspace/OP15/temp/quick-scripts/src/assets/OP15/script/defaultData.js":"2022-01-10T08:17:43.271Z","/Users/admin/workspace/OP15/temp/quick-scripts/src/assets/OP15/script/util.js":"2022-01-10T08:17:43.270Z","/Users/admin/workspace/OP15/temp/quick-scripts/src/assets/OP15/script/state.js":"2022-01-10T08:17:43.269Z","/Users/admin/workspace/OP15/temp/quick-scripts/src/assets/OP15/script/xstate.js":"2022-01-10T08:17:43.272Z"}}
{"version":"1.0.8","stats":{"/Users/lmz/Documents/workspace/pro_hw/OP15/temp/quick-scripts/src/__qc_index__.js":"2022-08-01T06:30:44.713Z","/Users/lmz/Documents/workspace/pro_hw/OP15/temp/quick-scripts/src/assets/OP15/script/defaultData.js":"2022-08-01T06:30:44.689Z","/Users/lmz/Documents/workspace/pro_hw/OP15/temp/quick-scripts/src/assets/OP15/scene/OP15.js":"2022-08-01T06:30:44.691Z","/Users/lmz/Documents/workspace/pro_hw/OP15/temp/quick-scripts/src/assets/OP15/script/state.js":"2022-08-01T06:30:44.688Z","/Users/lmz/Documents/workspace/pro_hw/OP15/temp/quick-scripts/src/assets/OP15/script/util.js":"2022-08-01T06:30:44.689Z","/Users/lmz/Documents/workspace/pro_hw/OP15/temp/quick-scripts/src/assets/OP15/script/xstate.js":"2022-08-01T06:30:44.690Z"}}
This diff is collapsed.
(function () {
var scripts = [{"deps":{"./assets/OP15/script/xstate":3,"./assets/OP15/script/state":1,"./assets/OP15/script/defaultData":4,"./assets/OP15/scene/OP15":2,"./assets/OP15/script/util":5},"path":"preview-scripts/__qc_index__.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/state.js"},{"deps":{"../script/defaultData":4,"../script/xstate":3,"../script/util":5},"path":"preview-scripts/assets/OP15/scene/OP15.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/xstate.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/defaultData.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/util.js"}];
var scripts = [{"deps":{"./assets/OP15/script/state":3,"./assets/OP15/script/xstate":5,"./assets/OP15/script/defaultData":1,"./assets/OP15/scene/OP15":2,"./assets/OP15/script/util":4},"path":"preview-scripts/__qc_index__.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/defaultData.js"},{"deps":{"../script/defaultData":1,"../script/xstate":5,"../script/util":4},"path":"preview-scripts/assets/OP15/scene/OP15.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/state.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/util.js"},{"deps":{},"path":"preview-scripts/assets/OP15/script/xstate.js"}];
var entries = ["preview-scripts/__qc_index__.js"];
var bundleScript = 'preview-scripts/__qc_bundle__.js';
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -450,6 +450,7 @@ cc.Class({
(0, _util.playAudioByUrl)(_this.data.end_audio, function () {
console.log('game finish');
(0, _util.onHomeworkFinish)();
}); // return new Promise((resolve,reject) => {
// setTimeout(() => {
// console.log('hint finish');
......@@ -467,6 +468,12 @@ cc.Class({
var k = _this._hintsNodeList[i].after;
after[k] = {
actions: function actions() {
if (t.isSpine) {
var skeleton = t.getComponent(sp.Skeleton);
skeleton.pause();
skeleton.loop = false;
skeleton.animation = 'enlarge'; // skeleton.animation = skeleton.animationNames[0];
} else {
var dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('enlarge', 1);
console.log(dragonDisplay._armatureKey, 'enlarge');
......@@ -474,7 +481,8 @@ cc.Class({
// event.name为事件名称
// event.armature.animation.play('normal', 0);
// console.log(event.animationState.name, dragonDisplay._armatureKey, 'end')
}, _this); // const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
}, _this);
} // const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
// dragonDisplay.playAnimation('enlarge', 1);
// console.log(dragonDisplay._armatureKey, 'enlarge')
// dragonDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event) => {
......@@ -483,6 +491,7 @@ cc.Class({
// event.armature.animation.play('normal', 0);
// console.log(event.animationState.name, dragonDisplay._armatureKey, 'end')
// }, this);
}
};
};
......@@ -500,11 +509,19 @@ cc.Class({
for (var _i = 0; _i < _this._allAnimationNodes.length; _i++) {
var _t = _this._allAnimationNodes[_i];
if (_t.isSpine) {
var skeleton = _t.getComponent(sp.Skeleton);
skeleton.pause();
skeleton.loop = true;
skeleton.animation = 'normal'; // skeleton.animation = skeleton.animationNames[0];
} else {
var dragonDisplay = _t.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('normal', 0);
}
}
}
};
}
......@@ -514,7 +531,10 @@ cc.Class({
this.gameMachineService = (0, _xstate.interpret)(gameMachine).onTransition(function (state) {// console.log(1, state.value, state.context);
});
this.gameMachineService.start();
if (window.gameMachineService) {
window.gameMachineService = gameMachineService;
}
},
// 生命周期 start
start: function start() {
......@@ -605,7 +625,101 @@ cc.Class({
func(this.getDefaultData());
},
getDefaultData: function getDefaultData() {
return _defaultData.defaultData;
return {
"begin_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"begin_sep_time": 1,
"guide_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"playing_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"right_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"wrong_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"wrong_audio1": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"wrong_audio2": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"end_audio": "http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3",
"bgItem": {
"url": "http://staging-teach.cdn.ireadabc.com/84ec6edc20bceaaa9dbe824092b6860d.png",
"rect": {
"x": 549.55,
"y": 0,
"width": 449.9,
"height": 582
}
},
"hotZoneItemArr": [{
"id": "1659333645573",
"index": 0,
"audio_url": "http://staging-teach.cdn.ireadabc.com/5a1a2670845bfe76662e86d9a3a69f81.mp3",
"itemType": "rect",
"fontScale": 1.21015625,
"imgScale": 1,
"imgSizeW": 0,
"imgSizeH": 0,
"mapScale": 1.21015625,
"dragDot": {
"x": 774.5,
"y": 289.55016883743366
},
"gIdx": "1",
"labelText": "1",
"posX": 887.5,
"posY": 165.5,
"skeJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/d1f859d3fba84bd03565e543c986fb28.json",
"name": "6_4_ske.json"
},
"texJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/70f96e1cc7f013e27ed1952c503fb750.json",
"name": "6_4_tex.json"
},
"texPngData": {
"url": "http://staging-teach.cdn.ireadabc.com/b06f9b90018a6eb0175a01e355b9ced6.png",
"name": "6_4_tex.png"
},
"animType": "dragonBone",
"rect": {
"x": 36.08,
"y": 49.19,
"width": 153.95,
"height": 150.19
}
}, {
"id": "1659334098930",
"index": 1,
"audio_url": "http://staging-teach.cdn.ireadabc.com/16eb06a6beb9e4fa77c9b5d2d643ab29.mp3",
"itemType": "rect",
"fontScale": 1.21015625,
"imgScale": 1,
"imgSizeW": 0,
"imgSizeH": 0,
"mapScale": 1.21015625,
"dragDot": {
"x": 774.5,
"y": 289.55016883743366
},
"gIdx": "0",
"labelText": "1",
"posX": 1212.5,
"posY": 643.5,
"skeJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/bdbadb06e0c1157e727cecd28f28d10e.json",
"name": "spineboy-pro.json"
},
"texJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/e0945b8265ea3b8053afb814c6b849d3.atlas",
"name": "spineboy-pro.atlas"
},
"texPngData": {
"url": "http://staging-teach.cdn.ireadabc.com/517553f50224915148f9efc5b7556798.png",
"name": "spineboy-pro.png"
},
"animType": "spine",
"rect": {
"x": 282.03,
"y": 408.15,
"width": 150.19,
"height": 150.19
}
}]
}; // return defaultData;
},
preloadItem: function preloadItem() {
this.addPreloadImage();
......@@ -855,10 +969,13 @@ cc.Class({
(function () {
var n = new cc.Node();
n.scale = 0.25;
var db = n.addComponent(dragonBones.ArmatureDisplay);
n.parent = ground;
n.active = false;
(0, _util.loadDragonBones)(db, {
if (_block.animType == 'spine') {
var skeleton = n.addComponent(sp.Skeleton);
n.isSpine = true;
(0, _util.loadSpine)(skeleton, _block.texPngData.name, {
tex: _block.texPngData.url,
atlas: _block.texJsonData.url,
ske: _block.skeJsonData.url
......@@ -867,6 +984,37 @@ cc.Class({
height = _ref.height;
n.width = width;
n.height = height;
n.active = true; // db.playAnimation('null', 0);
// skeleton.loop = true;
// skeleton.animation = skeleton.animationNames[0]
_this4._allAnimationNodes.push(n);
finishDbCount++;
console.log(finishDbCount, dbCount);
if (finishDbCount == dbCount) {
_this4.loadEnd();
}
})["catch"](function () {
finishDbCount++;
console.log(finishDbCount, dbCount);
if (finishDbCount == dbCount) {
_this4.loadEnd();
}
});
} else {
var db = n.addComponent(dragonBones.ArmatureDisplay);
(0, _util.loadDragonBones)(db, {
tex: _block.texPngData.url,
atlas: _block.texJsonData.url,
ske: _block.skeJsonData.url
}).then(function (_ref2) {
var width = _ref2.width,
height = _ref2.height;
n.width = width;
n.height = height;
n.active = true;
db.playAnimation('null', 0);
......@@ -886,6 +1034,7 @@ cc.Class({
_this4.loadEnd();
}
});
}
if (_block.gIdx == '0') {
var rectInfo = {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -28,6 +28,7 @@ exports.asyncTweenBy = asyncTweenBy;
exports.showTrebleFirework = showTrebleFirework;
exports.onHomeworkFinish = onHomeworkFinish;
exports.loadDragonBones = loadDragonBones;
exports.loadSpine = loadSpine;
exports.FireworkSettings = void 0;
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
......@@ -354,7 +355,7 @@ function _showFireworks() {
case 0:
baseNode = fireworkSettings.baseNode, nodeList = fireworkSettings.nodeList, pos = fireworkSettings.pos, side = fireworkSettings.side, range = fireworkSettings.range, number = fireworkSettings.number, scalseRange = fireworkSettings.scalseRange;
new Array(number).fill(' ').forEach( /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_, i) {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_, i) {
var rabbonNode, node, rate, angle;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
......@@ -422,7 +423,7 @@ function _showFireworks() {
}));
return function (_x12, _x13) {
return _ref2.apply(this, arguments);
return _ref3.apply(this, arguments);
};
}());
......@@ -618,4 +619,74 @@ function loadDragonBones(dragonDisplay, _ref) {
});
}
function loadSpine(skeleton, picName, _ref2) {
var tex = _ref2.tex,
atlas = _ref2.atlas,
ske = _ref2.ske;
return new Promise(function (resolve, reject) {
// cc.loader.load({ url: tex, type: 'png' }, (error, texture) => {
cc.assetManager.loadRemote(tex, function (error, texture) {
if (error) {
reject();
return;
} // cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.assetManager.loadAny({
url: atlas
}, function (error, atlasJson) {
if (error) {
reject();
return;
} // cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
cc.assetManager.loadAny({
url: ske
}, function (error, dragonBonesJson) {
if (error) {
reject();
return;
}
var asset = new sp.SkeletonData();
asset._uuid = ske;
asset.skeletonJson = JSON.stringify(dragonBonesJson);
asset.atlasText = atlasJson;
asset.textures = [texture];
asset.textureNames = [picName];
console.log('picName: ', picName);
skeleton.skeletonData = asset;
var jsonObj = dragonBonesJson; //JSON.parse( assets[1]);
var animationNameObj = jsonObj.animations;
var animationNames = [];
for (var name in animationNameObj) {
console.log('name~~: ', name);
animationNames.push(name);
}
console.log("skeleton.animation: ", skeleton.animation);
skeleton.animationNames = animationNames;
skeleton.loop = false;
console.log("jsonObj['skeleton'] : ", jsonObj['skeleton']);
resolve(jsonObj['skeleton']); // const atlasObj = new dragonBones.DragonBonesAtlasAsset()
// atlasObj.uuid = atlas
// atlasObj.atlasJson = atlasJson
// atlasObj.texture = texture
// const asset = new dragonBones.DragonBonesAsset()
// asset.uuid = ske
// asset.dragonBonesJson = dragonBonesJson;
// const armatureName = asset._dragonBonesJsonData.armature[0].name || 'default';
// dragonDisplay.armatureName = armatureName;
// dragonDisplay.dragonAtlasAsset = atlasObj
// dragonDisplay.dragonAsset = asset;
// resolve(asset._dragonBonesJsonData.armature[0].aabb);
});
});
});
});
}
cc._RF.pop();
\ No newline at end of file
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