Commit 59a9142a authored by asdf's avatar asdf

2

parent 428c74aa
...@@ -50,27 +50,29 @@ ...@@ -50,27 +50,29 @@
<div *ngIf="(question.optionList.length < 7)"> <div *ngIf="(question.optionList.length < 7)">
<button style="margin-top: 20px; float: left; border-width: 1px; <button style="margin-top: 20px; float: left; border-width: 1px;
border-style: dotted; padding: 20px; margin-right: 20px; border-style: dotted; padding: 20px; margin-right: 20px;
width: 230px; height: 263px;" nz-button nzType="dashed" class="add-btn" (click)="addOption(i)"> width: 230px; height: 343px;" nz-button nzType="dashed" class="add-btn" (click)="addOption(i)">
增加选项 增加选项
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<button style="margin-left: 5%; margin-top: 50px;margin-bottom: 8px; width: 100px; height: 32px;" <br>
nz-button nzType="danger" (click)="removeQuestion(i)"> <div>
<button style="margin-left: 5%; margin-top: 50px;margin-bottom: 8px; width: 100px; height: 32px;" nz-button
nzType="danger" (click)="removeQuestion(i)">
删除问题 删除问题
</button> </button>
<button style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 100px; height: 32px; " <button style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 100px; height: 32px; " nz-button
nz-button nzType="dashed" nzDanger class="add-btn" (click)="copyQuestion(i)"> nzType="dashed" nzDanger class="add-btn" (click)="copyQuestion(i)">
复制问题 复制问题
</button> </button>
<button style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 120px; height: 32px;" <button style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 120px; height: 32px;" nz-button
nz-button nzType="dashed" nzDanger class="add-btn" (click)="pasteQuestion(i)"> nzType="dashed" nzDanger class="add-btn" (click)="pasteQuestion(i)">
粘贴到下一页 粘贴到下一页
</button> </button>
</div> </div>
</div> </div>
</div>
<button style="margin-left: 5%; margin-top: 8px; margin-bottom: 100px; height: 50px; width: 90%;" nz-button <button style="margin-left: 5%; margin-top: 8px; margin-bottom: 100px; height: 50px; width: 90%;" nz-button
nzType="dashed" class="add-btn" (click)="addQuestion()"> nzType="dashed" class="add-btn" (click)="addQuestion()">
添加问题 添加问题
......
...@@ -13,6 +13,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -13,6 +13,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
saveKey = "DataKey_Cocos_FT11"; saveKey = "DataKey_Cocos_FT11";
// 储存对象 // 储存对象
item; item;
copyQuestionData;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
...@@ -22,7 +23,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -22,7 +23,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item.questionList.push( this.item.questionList.push(
{ {
"rightOptionIdx": 0, "rightOptionIdx": 0,
"rightOptionIndex": "",
"optionList": [{ "optionList": [{
"text": "", "text": "",
"optionDragonBone": { "optionDragonBone": {
...@@ -60,10 +60,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -60,10 +60,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save(); this.save();
} }
copyQuestion(idx){ copyQuestion(idx){
this.copyQuestion = this.item.questionList[idx]; this.copyQuestionData = this.item.questionList[idx];
} }
pasteQuestion(idx){ pasteQuestion(idx){
this.item.questionList.splice(idx + 1, 0, JSON.parse(JSON.stringify(this.copyQuestion))); this.item.questionList.splice(idx + 1, 0, JSON.parse(JSON.stringify(this.copyQuestionData)));
} }
addOption(questionIdx) { addOption(questionIdx) {
......
{
"__type__": "cc.AnimationClip",
"_name": "animDark",
"_objFlags": 0,
"_native": "",
"_duration": 0.016666666666666666,
"sample": 60,
"speed": 0.4,
"wrapMode": 1,
"curveData": {
"paths": {
"bg/bg_stardark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "0ea1bc39-9ee3-4378-b7b5-0a637fff01aa"
}
}
]
}
}
},
"bg/bg_moondark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "48f7c98b-5357-489f-a521-2cd6a62abde8"
}
}
]
}
}
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "a396ac09-978d-481b-a0e3-997a51f4678a",
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "animation",
"_objFlags": 0,
"_native": "",
"_duration": 0.016666666666666666,
"sample": 60,
"speed": 0.4,
"wrapMode": 1,
"curveData": {
"paths": {
"bg/bg_stardark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "3fc433b2-da4c-4aa2-bc03-1d202e971134"
}
}
]
}
}
},
"bg/bg_moondark": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "4ec3fc3d-35c2-4cde-af8c-52536d71c6d3"
}
}
]
}
}
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "20c8555e-3c4c-4d3e-b35a-afc1720cdfdb",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "86c3d350-b246-47cd-a46f-89901c28f26e",
"downloadMode": 0,
"duration": 2.403265,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "1c6f13c1-6289-4131-9566-d1dbd3849ff4",
"downloadMode": 0,
"duration": 0.522449,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "15166da1-4133-42f4-8122-b16ffdb68c51",
"downloadMode": 0,
"duration": 0.130612,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "c92eebf4-6f1f-4608-af47-a6277311de3f",
"downloadMode": 0,
"duration": 4.04898,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "3aeb3c97-e4a2-4f0f-a479-48b8eeb6eeed",
"downloadMode": 0,
"duration": 0.966531,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "eebbeec5-bfc1-4481-b447-2ee0a7a79ee8",
"downloadMode": 0,
"duration": 2.76898,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "169e45bc-9858-4f55-8020-667f6e4563c6",
"downloadMode": 0,
"duration": 0.940417,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "06e2267e-0be5-4c48-afe9-8390e1d89c88",
"subMetas": {}
}
\ No newline at end of file
...@@ -875,9 +875,7 @@ ...@@ -875,9 +875,7 @@
"__id__": 1 "__id__": 1
}, },
"_enabled": true, "_enabled": true,
"audOver": { "audOver": null,
"__uuid__": "c92eebf4-6f1f-4608-af47-a6277311de3f"
},
"_id": "" "_id": ""
}, },
{ {
......
This diff is collapsed.
/**
* 事件模块
* onfire.js
*
*/
interface Listener {
cb: Function;
once: boolean;
target: object;
}
interface EventsType {
[eventName: string]: Listener[];
}
class EventMgr {
// 所有事件的监听器
es: EventsType = {};
on(eventName: string, cb: Function, target: object) {
if (!this.es[eventName]) {
this.es[eventName] = [];
}
this.es[eventName].push({
cb,
once: false,
target,
});
}
once(eventName: string, cb: Function, target: object) {
if (!this.es[eventName]) {
this.es[eventName] = [];
}
this.es[eventName].push({
cb,
once: true,
target,
});
}
emit(eventName: string, params?: any) {
const listeners = this.es[eventName] || [];
let l = listeners.length;
for (let i = 0; i < l; i++) {
const { cb, once, target } = listeners[i];
let args = [eventName, params];
cb.apply(target, args);
if (once) {
listeners.splice(i, 1);
i--;
l--;
}
}
}
off(eventName?: string, cb?: Function, target?: object) {
// clean all
if (eventName === undefined) {
this.es = {};
} else {
if (cb === undefined) {
// clean the eventName's listeners
delete this.es[eventName];
} else if (cb === null) {
if (!target) {
return;
}
const listeners = this.es[eventName] || [];
// clean the event and listener
let l = listeners.length;
for (let i = 0; i < l; i++) {
if (listeners[i].target === target) {
listeners.splice(i, 1);
i--;
l--;
}
}
} else {
const listeners = this.es[eventName] || [];
// clean the event and listener
let l = listeners.length;
for (let i = 0; i < l; i++) {
if (listeners[i].cb === cb && listeners[i].target === target) {
listeners.splice(i, 1);
i--;
l--;
}
}
}
}
}
}
export default new EventMgr();
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "f25d28c5-2fa1-4bfc-ab0c-9f8e3e8ff631",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import EventMgr from './EventMgr';
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
nodLight: cc.Node,
nodMask: cc.Node,
dragonBone: dragonBones.ArmatureDisplay, dragonBone: dragonBones.ArmatureDisplay,
spfAudio: [cc.SpriteFrame], spfAudioOn: cc.SpriteFrame,
sprAudio: cc.Sprite, spfAudioOff: cc.SpriteFrame,
audRight: cc.AudioClip,
audWrong: cc.AudioClip,
audTryagain: cc.AudioClip,
}, },
// onLoad () {}, onLoad() {
this.nodLight = this.node.getChildByName('light');
this.nodMask = this.node.getChildByName('mask');
this.btnAudio = this.node.getChildByName('btnAudio');
this.btnAudio.on('click', this.onBtnClickAudio, this)
this.sprAudio = this.btnAudio.getChildByName('sprAudio').getComponent(cc.Sprite);
this.label = this.node.getChildByName('label').getComponent(cc.Label);
this.nodCross = this.node.getChildByName('cross');
this.nodCross.active = false;
},
start() { start() {
this.init();
}, },
onEnable() { onEnable() {
this.node.on('touchstart', this.onTouchStart, this); this.node.on('touchstart', this.onTouchStart, this);
EventMgr.on('showAudioButton', this.showAudioButton, this);
}, },
onDisable() { onDisable() {
this.node.off('touchstart', this.onTouchStart, this); this.node.off('touchstart', this.onTouchStart, this);
EventMgr.off('showAudioButton', this.showAudioButton, this);
}, },
onTouchStart() { onTouchStart() {
if (GameData.isMoving) { if (!GameData.startStepDone) {
return; return;
} }
if (GameData.audioCount != 0) { if (GameData.audioCount != 0) {
return; return;
} }
if (GameData.currOptionIndex == this.index) { if (this.isRight) {
this.chooseRight(); this.chooseRight();
} else { } else {
this.chooseWrong(); this.chooseWrong();
} }
}, },
showAudioButton() {
this.nodMask.runAction(cc.fadeOut(1))
this.btnAudio.active = true;
},
init() {
this.nodLight.active = false;
this.nodMask.active = true;
this.btnAudio.active = false;
},
setInfo(data, index, scene) { setInfo(data, index, scene, isRight) {
this.scene = scene; this.scene = scene;
this.data = data; this.data = data;
this.isRight = isRight;
this.index = index; this.index = index;
this.loadDragonBone(); this.loadDragonBone();
if (GameData.questionIndex % 2 == 0) {
this.sprBg.spriteFrame = this.spfBase[0]; this.label.string = data.text;
} else {
this.sprBg.spriteFrame = this.spfBase[1];
}
}, },
loadDragonBone() { loadDragonBone() {
this.dragonBone.dragonAtlasAsset = null; this.dragonBone.dragonAtlasAsset = null;
this.dragonBone.dragonAsset = null; this.dragonBone.dragonAsset = null;
this.dragonBone.armatureName = ''; this.dragonBone.armatureName = '';
var imageUrl = this.data.optionDragonBone.texPngData2.url; var imageUrl = this.data.optionDragonBone.texPngData.url;
var skeUrl = this.data.optionDragonBone.skeJsonData2.url; var skeUrl = this.data.optionDragonBone.skeJsonData.url;
var atlasUrl = this.data.optionDragonBone.texJsonData2.url; var atlasUrl = this.data.optionDragonBone.texJsonData.url;
// imageUrl = 'http://127.0.0.1/NewProject_2_tex.png'; imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
// skeUrl = 'http://127.0.0.1/NewProject_2_ske.json'; skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
// atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json'; atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';
cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => { cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
if (error) { if (error) {
console.log(error) console.log(error)
...@@ -92,18 +112,13 @@ cc.Class({ ...@@ -92,18 +112,13 @@ cc.Class({
}); });
}, },
chooseRight() { chooseRight() {
this.node.zIndex = 5; this.showLight();
this.playAudioRight(); this.playAudioRight();
this.nodLight.active = true;
this.scene.moveToQuestion(this);
}, },
chooseWrong() { chooseWrong() {
this.showLight();
this.playAudioWrong(); this.playAudioWrong();
cc.tween(this.node) this.playShowCross();
.to(0.2, { y: -150 })
.to(0.2, { y: 0 })
.start()
}, },
playAudioRight() { playAudioRight() {
...@@ -111,6 +126,7 @@ cc.Class({ ...@@ -111,6 +126,7 @@ cc.Class({
let id = cc.audioEngine.play(this.audRight, false, 1); let id = cc.audioEngine.play(this.audRight, false, 1);
cc.audioEngine.setFinishCallback(id, () => { cc.audioEngine.setFinishCallback(id, () => {
GameData.audioCount--; GameData.audioCount--;
this.scene.onClickAnswer(this, this.isRight);
}) })
}, },
playAudioWrong() { playAudioWrong() {
...@@ -118,22 +134,72 @@ cc.Class({ ...@@ -118,22 +134,72 @@ cc.Class({
let id = cc.audioEngine.play(this.audWrong, false, 1); let id = cc.audioEngine.play(this.audWrong, false, 1);
cc.audioEngine.setFinishCallback(id, () => { cc.audioEngine.setFinishCallback(id, () => {
GameData.audioCount--; GameData.audioCount--;
this.scene.onClickAnswer(this, this.isRight);
})
},
showLight() {
this.nodLight.active = true;
},
playHideAudioButton() {
this.btnAudio.runAction(
cc.sequence(
cc.scaleTo(0.2, 1.2),
cc.scaleTo(0.4, 0),
cc.callFunc(()=>{
}) })
)
)
},
playShowCross() {
this.nodCross.active = true;
this.nodCross.runAction(
cc.sequence(
cc.scaleTo(0.1, 1.2),
cc.scaleTo(0.2, 1),
cc.callFunc(()=>{
this.playHideCross();
})
)
)
},
playHideCross() {
this.nodCross.active = true;
this.nodCross.runAction(
cc.sequence(
cc.scaleTo(0.2, 1.2),
cc.scaleTo(0.4, 0),
cc.callFunc(()=>{
this.playAnswerDown();
})
)
)
},
playAnswerDown() {
this.node.runAction(
cc.spawn(
cc.rotateBy(1,720),
cc.moveBy(1, 0, -1000)
),
)
}, },
changeAudioSpfCb() { changeAudioSpfCb() {
this.sprAudio.spriteFrame = this.sprAudio.spriteFrame == this.spfAudio[0] ? this.spfAudio[1] : this.spfAudio[0]; this.sprAudio.spriteFrame = this.sprAudio.spriteFrame == this.spfAudioOff ? this.spfAudioOn : this.spfAudioOff;
}, },
onBtnClickAudio() { onBtnClickAudio() {
if(GameData.audioCount > 0){ if (GameData.audioCount > 0) {
return; return;
} }
this.dragonBone.playAnimation(this.animationName, 0); this.dragonBone.playAnimation(this.animationName, 0);
this.sprAudio.spriteFrame = this.spfAudio[0]; this.sprAudio.spriteFrame = this.spfAudioOff;
this.schedule(this.changeAudioSpfCb, 0.2) this.schedule(this.changeAudioSpfCb, 0.2)
this.playAudioOption(() => { this.playAudioOption(() => {
this.unschedule(this.changeAudioSpfCb) this.unschedule(this.changeAudioSpfCb)
this.sprAudio.spriteFrame = this.spfAudio[1]; this.sprAudio.spriteFrame = this.spfAudioOn;
GameData.isAudio = false; GameData.isAudio = false;
}); });
}, },
...@@ -141,7 +207,7 @@ cc.Class({ ...@@ -141,7 +207,7 @@ cc.Class({
playAudioOption(cb) { playAudioOption(cb) {
GameData.audioCount++; GameData.audioCount++;
let url = this.data.optionAudio; let url = this.data.optionAudio;
// url = 'http://127.0.0.1/iamflying.mp3'; url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(url, null, (err, clip) => { cc.assetManager.loadRemote(url, null, (err, clip) => {
if (err) { if (err) {
console.log(err) console.log(err)
......
This diff is collapsed.
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "c4f31b4c-2c43-41ee-9378-2d37ec60fe03", "uuid": "f6cc5c79-3cc2-4f2c-94e1-316c8cbbe077",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 1280, "width": 52,
"height": 720, "height": 56,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"字体1": { "btn_laba": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "5029f0ec-bc61-4f05-b995-2cfb9300c6c3", "uuid": "70507655-9387-4a55-9f14-668de2d65d86",
"rawTextureUuid": "c4f31b4c-2c43-41ee-9378-2d37ec60fe03", "rawTextureUuid": "f6cc5c79-3cc2-4f2c-94e1-316c8cbbe077",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
"offsetY": 0, "offsetY": 0,
"trimX": 0, "trimX": 0,
"trimY": 0, "trimY": 0,
"width": 1280, "width": 52,
"height": 720, "height": 56,
"rawWidth": 1280, "rawWidth": 52,
"rawHeight": 720, "rawHeight": 56,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "f4054894-0360-403a-8284-4f18713211e3", "uuid": "9049a076-cef7-413d-9288-b5865033dee1",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 1280, "width": 52,
"height": 720, "height": 56,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"字体2": { "btn_laba2": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "02729643-d5ed-4c29-b865-11360f2590e5", "uuid": "0278fa95-d13c-4b1c-ae81-5a1745b4d81a",
"rawTextureUuid": "f4054894-0360-403a-8284-4f18713211e3", "rawTextureUuid": "9049a076-cef7-413d-9288-b5865033dee1",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
"offsetY": 0, "offsetY": 0,
"trimX": 0, "trimX": 0,
"trimY": 0, "trimY": 0,
"width": 1280, "width": 52,
"height": 720, "height": 56,
"rawWidth": 1280, "rawWidth": 52,
"rawHeight": 720, "rawHeight": 56,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "baa2e22b-b057-4736-8aeb-955f7a401d93", "uuid": "cd81f7fe-319d-4dfb-974c-71019f7f9a2c",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 2222, "width": 179,
"height": 1324, "height": 179,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"微信图片_20201223212514": { "combined-shape": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "e07ee970-0aec-4531-952b-0b42d6d84260", "uuid": "436ddb1e-bc7a-458b-b8e3-4f3eba78399c",
"rawTextureUuid": "baa2e22b-b057-4736-8aeb-955f7a401d93", "rawTextureUuid": "cd81f7fe-319d-4dfb-974c-71019f7f9a2c",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
"offsetY": 0, "offsetY": 0,
"trimX": 0, "trimX": 0,
"trimY": 0, "trimY": 0,
"width": 2222, "width": 179,
"height": 1324, "height": 179,
"rawWidth": 2222, "rawWidth": 179,
"rawHeight": 1324, "rawHeight": 179,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
......
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