Commit 59a9142a authored by asdf's avatar asdf

2

parent 428c74aa
......@@ -50,27 +50,29 @@
<div *ngIf="(question.optionList.length < 7)">
<button style="margin-top: 20px; float: left; border-width: 1px;
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>
</div>
</div>
</div>
<button style="margin-left: 5%; margin-top: 50px;margin-bottom: 8px; width: 100px; height: 32px;"
nz-button nzType="danger" (click)="removeQuestion(i)">
<br>
<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 style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 100px; height: 32px; "
nz-button nzType="dashed" nzDanger class="add-btn" (click)="copyQuestion(i)">
<button style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 100px; height: 32px; " nz-button
nzType="dashed" nzDanger class="add-btn" (click)="copyQuestion(i)">
复制问题
</button>
<button style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 120px; height: 32px;"
nz-button nzType="dashed" nzDanger class="add-btn" (click)="pasteQuestion(i)">
<button style="margin-left: 5px; margin-top: 50px;margin-bottom: 8px; width: 120px; height: 32px;" nz-button
nzType="dashed" nzDanger class="add-btn" (click)="pasteQuestion(i)">
粘贴到下一页
</button>
</div>
</div>
</div>
<button style="margin-left: 5%; margin-top: 8px; margin-bottom: 100px; height: 50px; width: 90%;" nz-button
nzType="dashed" class="add-btn" (click)="addQuestion()">
添加问题
......
......@@ -13,6 +13,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
saveKey = "DataKey_Cocos_FT11";
// 储存对象
item;
copyQuestionData;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
......@@ -22,7 +23,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item.questionList.push(
{
"rightOptionIdx": 0,
"rightOptionIndex": "",
"optionList": [{
"text": "",
"optionDragonBone": {
......@@ -60,10 +60,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save();
}
copyQuestion(idx){
this.copyQuestion = this.item.questionList[idx];
this.copyQuestionData = this.item.questionList[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) {
......
{
"__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 @@
"__id__": 1
},
"_enabled": true,
"audOver": {
"__uuid__": "c92eebf4-6f1f-4608-af47-a6277311de3f"
},
"audOver": null,
"_id": ""
},
{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* 事件模块
* 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({
extends: cc.Component,
properties: {
nodLight: cc.Node,
nodMask: cc.Node,
dragonBone: dragonBones.ArmatureDisplay,
spfAudio: [cc.SpriteFrame],
sprAudio: cc.Sprite,
spfAudioOn: cc.SpriteFrame,
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() {
this.init();
},
onEnable() {
this.node.on('touchstart', this.onTouchStart, this);
EventMgr.on('showAudioButton', this.showAudioButton, this);
},
onDisable() {
this.node.off('touchstart', this.onTouchStart, this);
EventMgr.off('showAudioButton', this.showAudioButton, this);
},
onTouchStart() {
if (GameData.isMoving) {
if (!GameData.startStepDone) {
return;
}
if (GameData.audioCount != 0) {
return;
}
if (GameData.currOptionIndex == this.index) {
if (this.isRight) {
this.chooseRight();
} else {
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.data = data;
this.isRight = isRight;
this.index = index;
this.loadDragonBone();
if (GameData.questionIndex % 2 == 0) {
this.sprBg.spriteFrame = this.spfBase[0];
} else {
this.sprBg.spriteFrame = this.spfBase[1];
}
this.label.string = data.text;
},
loadDragonBone() {
this.dragonBone.dragonAtlasAsset = null;
this.dragonBone.dragonAsset = null;
this.dragonBone.armatureName = '';
var imageUrl = this.data.optionDragonBone.texPngData2.url;
var skeUrl = this.data.optionDragonBone.skeJsonData2.url;
var atlasUrl = this.data.optionDragonBone.texJsonData2.url;
// imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
// skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
// atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';
var imageUrl = this.data.optionDragonBone.texPngData.url;
var skeUrl = this.data.optionDragonBone.skeJsonData.url;
var atlasUrl = this.data.optionDragonBone.texJsonData.url;
imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';
cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
if (error) {
console.log(error)
......@@ -92,18 +112,13 @@ cc.Class({
});
},
chooseRight() {
this.node.zIndex = 5;
this.showLight();
this.playAudioRight();
this.nodLight.active = true;
this.scene.moveToQuestion(this);
},
chooseWrong() {
this.showLight();
this.playAudioWrong();
cc.tween(this.node)
.to(0.2, { y: -150 })
.to(0.2, { y: 0 })
.start()
this.playShowCross();
},
playAudioRight() {
......@@ -111,6 +126,7 @@ cc.Class({
let id = cc.audioEngine.play(this.audRight, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.audioCount--;
this.scene.onClickAnswer(this, this.isRight);
})
},
playAudioWrong() {
......@@ -118,22 +134,72 @@ cc.Class({
let id = cc.audioEngine.play(this.audWrong, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
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() {
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() {
if(GameData.audioCount > 0){
if (GameData.audioCount > 0) {
return;
}
this.dragonBone.playAnimation(this.animationName, 0);
this.sprAudio.spriteFrame = this.spfAudio[0];
this.sprAudio.spriteFrame = this.spfAudioOff;
this.schedule(this.changeAudioSpfCb, 0.2)
this.playAudioOption(() => {
this.unschedule(this.changeAudioSpfCb)
this.sprAudio.spriteFrame = this.spfAudio[1];
this.sprAudio.spriteFrame = this.spfAudioOn;
GameData.isAudio = false;
});
},
......@@ -141,7 +207,7 @@ cc.Class({
playAudioOption(cb) {
GameData.audioCount++;
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) => {
if (err) {
console.log(err)
......
const saveKey = "DataKey_Cocos_FT11";
const BaseUI = require('BaseUI');
import EventMgr from './EventMgr';
cc.Class({
extends: BaseUI,
......@@ -7,13 +8,30 @@ cc.Class({
properties: {
audEnter: cc.AudioClip,
audMove: cc.AudioClip,
audMerge: cc.AudioClip,
audClick: cc.AudioClip,
audTryAgain: cc.AudioClip,
audDown: cc.AudioClip,
pfbItemAnswer: cc.Prefab,
pfbItemQuestion: cc.Prefab,
layerOver: cc.Prefab,
},
dragonBone: dragonBones.ArmatureDisplay,
spfAudio: [cc.SpriteFrame],
},
/**
* 图片文字N选N-默认页面,所有选项蒙黑,右下角小女巫播放"normal"动画,选项里的正方形是个图片,此时没有播放音频按钮
* 图片文字N选N-五个选项以上选项布局
* 图片文字N选N-喇叭按钮弹出,点击按钮播放音频,播放时喇叭有三个点和没三个点状态反复切换
* 图片文字N选N-选择一个选项,选项发光,所有选项喇叭先放大后缩小消失,如果选错,弹出x,女巫动作切换为“wrong”
* 图片文字N选N-错误选项上x号缩小消失,界面蒙半透明黑,错误选项旋转掉落出界面,界面中间弹出“try again!”然后缩小消失,界面亮起
* 图片文字N选N-选择一个选项,选项发光,如果选对,女巫飞到正确选项旁边,播放选对动作"right",播放选对选中特效
* 图片文字N选N-女巫回到右下角,界面蒙半透明黑,正确选项放大到屏幕中间,图片区域播放骨骼动画
* 图片文字N选N-正确选项放大后,伴随音频播放,文字依次变绿,音频结束完全变绿,然后再依次变成白色,再次点击再次重播
* 图片文字N选N-最后一道题做对放大到中间后,屏幕中间弹出“Well Done!"
* 图片文字N选N-女巫飞到屏幕中间靠下位置播放“finish”动画
* 图片文字N选N-女巫飞行轨迹
* 图片文字N选N-well done缩小淡出,女巫飞回原来位置
*
*/
// 生命周期 onLoad
onLoad() {
this._super();
......@@ -22,7 +40,8 @@ cc.Class({
this.initSize();
},
initNodes() {
this.sprAudio = this.nodeDict.sprAudio.getComponent(cc.Sprite);
this.sprAudio.node.active = false;
},
onEnable() {
......@@ -74,7 +93,7 @@ cc.Class({
},
getDefaultData() {
let dataJson = '{"questionList":[{"questionAudio":"http://staging-teach.cdn.ireadabc.com/d2a9d8815d0370dc3b9aa18987dee584.mp3","questionText":"标题1","optionList":[{"text":"题干文本1","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/48b884b3c7b3a717f6e4b055f490a1f1.json","name":"walkingfish_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/608b2c5f85297f0b7930325733b7bea9.json","name":"walkingfish_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/ecfd66f932659635f5b66642378d826b.png","name":"walkingfish_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/4e267b9c0b58ebb153bfc0ae520cb7fe.mp3"},{"text":"题干文本2","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/90fd9908a33a3d087ac53e6f7d794c18.mp3"},{"text":"题干文本3","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/7ee85feaee06931e85cd0dd4ee64eeb1.mp3"},{"text":"题干文本45","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/248e684b0680d5ae39bacab7242b49f0.mp3"}]},{"questionAudio":"http://staging-teach.cdn.ireadabc.com/1d192b1cb2f2b1864ca55e903711081a.mp3","questionText":"","optionList":[{"text":"题干文本","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/d2a9d8815d0370dc3b9aa18987dee584.mp3"},{"text":"题干文本","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/4e267b9c0b58ebb153bfc0ae520cb7fe.mp3"},{"text":"题干文本","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/90fd9908a33a3d087ac53e6f7d794c18.mp3"}]}]}';
let dataJson = '{"questionAudio":"http://staging-teach.cdn.ireadabc.com/d2a9d8815d0370dc3b9aa18987dee584.mp3","questionText":"123","questionList":[{"rightOptionIdx":0,"rightOptionIndex":"","optionList":[{"text":"123","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/48b884b3c7b3a717f6e4b055f490a1f1.json","name":"walkingfish_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/608b2c5f85297f0b7930325733b7bea9.json","name":"walkingfish_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/ecfd66f932659635f5b66642378d826b.png","name":"walkingfish_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/7ee85feaee06931e85cd0dd4ee64eeb1.mp3"},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""}]},{"rightOptionIdx":0,"rightOptionIndex":"","optionList":[{"text":"123","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/48b884b3c7b3a717f6e4b055f490a1f1.json","name":"walkingfish_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/608b2c5f85297f0b7930325733b7bea9.json","name":"walkingfish_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/ecfd66f932659635f5b66642378d826b.png","name":"walkingfish_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/7ee85feaee06931e85cd0dd4ee64eeb1.mp3"},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""}]},{"rightOptionIdx":0,"rightOptionIndex":"","optionList":[{"text":"123","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/48b884b3c7b3a717f6e4b055f490a1f1.json","name":"walkingfish_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/608b2c5f85297f0b7930325733b7bea9.json","name":"walkingfish_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/ecfd66f932659635f5b66642378d826b.png","name":"walkingfish_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/7ee85feaee06931e85cd0dd4ee64eeb1.mp3"},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""}]},{"rightOptionIdx":0,"rightOptionIndex":"","optionList":[{"text":"123","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/48b884b3c7b3a717f6e4b055f490a1f1.json","name":"walkingfish_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/608b2c5f85297f0b7930325733b7bea9.json","name":"walkingfish_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/ecfd66f932659635f5b66642378d826b.png","name":"walkingfish_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/7ee85feaee06931e85cd0dd4ee64eeb1.mp3"},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""}]},{"rightOptionIdx":0,"rightOptionIndex":"","optionList":[{"text":"123","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/48b884b3c7b3a717f6e4b055f490a1f1.json","name":"walkingfish_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/608b2c5f85297f0b7930325733b7bea9.json","name":"walkingfish_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/ecfd66f932659635f5b66642378d826b.png","name":"walkingfish_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/7ee85feaee06931e85cd0dd4ee64eeb1.mp3"},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""},{"text":"","optionDragonBone":{"skeJsonData":{"url":""},"texJsonData":{"url":""},"texPngData":{"url":""}},"optionAudio":""}]}]}';
let data = JSON.parse(dataJson);
return data;
},
......@@ -92,9 +111,7 @@ cc.Class({
this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.skeJsonData.url });
this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texJsonData.url });
this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texPngData.url });
this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.skeJsonData2.url });
this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texJsonData2.url });
this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texPngData2.url });
}
}
},
......@@ -116,6 +133,12 @@ cc.Class({
this.initData();
this.startGame();
this.dragonBone.on(dragonBones.EventObject.COMPLETE,(event)=>{
if(event.animationState.name == 'wrong'){
this.playNormal();
}
},this)
},
initData() {
......@@ -127,8 +150,7 @@ cc.Class({
for (let i = 0; i < optionList.length; i++) {
this.optionList[i] = i;
}
GameData.isMoving = false;
this.initQuestionAndAnswer();
this.initAnswer();
this.initTitle();
this.updateBtnStatus();
},
......@@ -139,47 +161,36 @@ cc.Class({
initTitle() {
let label = this.nodeDict.labTitle.getComponent(cc.Label);
label.string = this.data.questionList[GameData.questionIndex].questionText;
label.string = this.data.questionText;
label._forceUpdateRenderData();
if (this.nodeDict.labTitle.width > 567) {
this.nodeDict.labTitle.scale = 567 / this.nodeDict.labTitle.width
if (this.nodeDict.labTitle.width > 545) {
this.nodeDict.labTitle.scale = 545 / this.nodeDict.labTitle.width
}
},
// 初始化题干以及选项
initQuestionAndAnswer() {
// 初始化选项
initAnswer() {
let optionList = this.data.questionList[GameData.questionIndex].optionList;
let answerIndexs = [1, 2, 3];
if (optionList.length == 4) {
answerIndexs = [1, 2, 3, 4];
if (optionList.length <= 5) {
this.layerAnser = this.nodeDict.LayerFive;
} else {
this.layerAnser = this.nodeDict.LayerSeven;
}
this.nodeDict.LayerFive.active = false;
this.nodeDict.LayerSeven.active = false;
this.layerAnser.active = true;
for (let i = 0; i < optionList.length; i++) {
let question = cc.instantiate(this.pfbItemQuestion);
question.parent = this.nodeDict.nodQuestionParent;
question.x = this.getItemX(optionList, i);
let ItemQuestion = question.getComponent('ItemQuestion');
ItemQuestion.setInfo(optionList[i], i, this);
ItemQuestion.setGray();
let answer = cc.instantiate(this.pfbItemAnswer);
answer.parent = this.nodeDict.nodAnswerParent;
let index = Math.floor(Math.random() * answerIndexs.length)
answer.x = this.getItemX(optionList, answerIndexs[index] - 1);
answerIndexs.splice(index, 1);
answer.getComponent('ItemAnswer').setInfo(optionList[i], i, this);
let node = this.layerAnser.children[i];
node.active = true;
let isRight = false;
if (this.data.questionList[GameData.questionIndex].rightOptionIdx == i) {
isRight = true;
}
},
getItemX(optionList, index) {
let itemWidth = 300;
let space = 10;
let x = index * (itemWidth + space) - 1.5 * (itemWidth + space);
if (optionList.length == 3) {
space = 56;
x = index * (itemWidth + space) - 1 * (itemWidth + space);
node.getComponent('ItemAnswer').setInfo(optionList[i], i, this, isRight);
}
for (let i = this.layerAnser.children.length - 1; i >= optionList.length; i--) {
this.layerAnser.children[i].active = false;
}
return x;
},
......@@ -195,18 +206,18 @@ cc.Class({
playAudioQuestion(isBtn) {
GameData.audioCount++;
let url = this.data.questionList[GameData.questionIndex].questionAudio;
// url = 'http://127.0.0.1/iamflying.mp3';
url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(url, null, (err, clip) => {
if (err) {
console.log(err)
this.showRandomQuestion();
this.startStepDone();
return;
}
let id = cc.audioEngine.play(clip, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
GameData.audioCount--;
if (!isBtn) {
this.showRandomQuestion();
this.startStepDone();
}
})
});
......@@ -226,14 +237,10 @@ cc.Class({
})
},
// 随机亮起一个题干
showRandomQuestion() {
GameData.currOptionIndex = this.optionList[Math.floor(Math.random() * this.optionList.length)]
let question = this.nodeDict.nodQuestionParent.children[GameData.currOptionIndex];
let ItemQuestion = question.getComponent('ItemQuestion');
ItemQuestion.setNormal();
ItemQuestion.showQipao();
ItemQuestion.playAudioOption();
startStepDone() {
this.sprAudio.node.active = true;
GameData.startStepDone = true;
EventMgr.emit('showAudioButton');
},
showNext(index) {
......@@ -258,32 +265,6 @@ cc.Class({
node.parent = this.node;
},
moveToQuestion(ItemAnswer) {
GameData.isMoving = true;
let index = ItemAnswer.index;
let question = this.nodeDict.nodQuestionParent.children[index];
let pos = this.nodeDict.nodQuestionParent.convertToWorldSpaceAR(question.position);
pos = this.nodeDict.nodAnswerParent.convertToNodeSpaceAR(pos);
this.playAudioMove();
cc.tween(ItemAnswer.node)
.to(0.8, { position: pos })
.call(() => {
question.getComponent('ItemQuestion').setChooseRight(ItemAnswer.dragonBone, ItemAnswer.animationName);
ItemAnswer.node.destroy();
this.getComponent(cc.Animation).play('animLight');
this.playAudioMerge();
cc.tween(question)
.delay(3)
.call(() => {
question.getComponent('ItemQuestion').stopRightAnimation();
this.getComponent(cc.Animation).play('animDark');
GameData.isMoving = false;
})
.start()
})
.start()
},
updateBtnStatus() {
if (GameData.questionIndex == 0) {
this.nodeDict.btnLast.getComponent(cc.Button).interactable = false;
......@@ -297,6 +278,17 @@ cc.Class({
}
},
onClickAnswer(itemAnser,isRight){
for(let i = 0;i<this.layerAnser.children.length;i++){
this.layerAnser.children[i].getComponent('ItemAnswer').playHideAudioButton();
}
if(isRight){
}else{
this.playWrong();
}
},
onTurnLast() {
this.nodeDict.nodAnswerParent.destroyAllChildren();
this.nodeDict.nodQuestionParent.destroyAllChildren();
......@@ -304,13 +296,15 @@ cc.Class({
GameData.questionIndex--;
this.initData();
this.playAudioQuestion();
GameData.startStepDone = false;
},
onReplay() {
this.nodeDict.nodAnswerParent.destroyAllChildren();
this.nodeDict.nodQuestionParent.destroyAllChildren();
cc.audioEngine.stopAll();
this.initData();
this.startGame();
this.playAudioQuestion();
GameData.startStepDone = false;
},
onTurnNext() {
this.nodeDict.nodAnswerParent.destroyAllChildren();
......@@ -318,7 +312,8 @@ cc.Class({
cc.audioEngine.stopAll();
GameData.questionIndex++;
this.initData();
this.startGame();
this.playAudioQuestion();
GameData.startStepDone = false;
},
buttonListener(button) {
......@@ -333,7 +328,59 @@ cc.Class({
this.onReplay();
} else if (button.node.name == 'btnNext') {
this.onTurnNext();
} else if (button.node.name == 'btnAudio') {
this.onBtnClickAudio();
}
},
playNormal() {
this.dragonBone.playAnimation('normal', 1);
},
playWrong() {
this.dragonBone.playAnimation('wrong', 1);
},
playRight() {
this.dragonBone.playAnimation('right', 1);
},
playFinish() {
this.dragonBone.playAnimation('finish', 1);
},
changeAudioSpfCb() {
this.sprAudio.spriteFrame = this.sprAudio.spriteFrame == this.spfAudio[0] ? this.spfAudio[1] : this.spfAudio[0];
},
onBtnClickAudio() {
if (GameData.audioCount > 0) {
return;
}
this.dragonBone.playAnimation(this.animationName, 0);
this.sprAudio.spriteFrame = this.spfAudio[0];
this.schedule(this.changeAudioSpfCb, 0.2)
this.playAudio(() => {
this.unschedule(this.changeAudioSpfCb)
this.sprAudio.spriteFrame = this.spfAudio[1];
GameData.isAudio = false;
});
},
playAudio(cb) {
GameData.audioCount++;
let url = this.data.optionAudio;
url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
let id = cc.audioEngine.play(clip, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
if (!cc.isValid(this)) {
return;
}
GameData.audioCount--;
cb && cb();
})
});
},
});
{
"ver": "2.3.5",
"uuid": "c4f31b4c-2c43-41ee-9378-2d37ec60fe03",
"uuid": "f6cc5c79-3cc2-4f2c-94e1-316c8cbbe077",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"width": 52,
"height": 56,
"platformSettings": {},
"subMetas": {
"字体1": {
"btn_laba": {
"ver": "1.0.4",
"uuid": "5029f0ec-bc61-4f05-b995-2cfb9300c6c3",
"rawTextureUuid": "c4f31b4c-2c43-41ee-9378-2d37ec60fe03",
"uuid": "70507655-9387-4a55-9f14-668de2d65d86",
"rawTextureUuid": "f6cc5c79-3cc2-4f2c-94e1-316c8cbbe077",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"width": 52,
"height": 56,
"rawWidth": 52,
"rawHeight": 56,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "f4054894-0360-403a-8284-4f18713211e3",
"uuid": "9049a076-cef7-413d-9288-b5865033dee1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"width": 52,
"height": 56,
"platformSettings": {},
"subMetas": {
"字体2": {
"btn_laba2": {
"ver": "1.0.4",
"uuid": "02729643-d5ed-4c29-b865-11360f2590e5",
"rawTextureUuid": "f4054894-0360-403a-8284-4f18713211e3",
"uuid": "0278fa95-d13c-4b1c-ae81-5a1745b4d81a",
"rawTextureUuid": "9049a076-cef7-413d-9288-b5865033dee1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"width": 52,
"height": 56,
"rawWidth": 52,
"rawHeight": 56,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "baa2e22b-b057-4736-8aeb-955f7a401d93",
"uuid": "cd81f7fe-319d-4dfb-974c-71019f7f9a2c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2222,
"height": 1324,
"width": 179,
"height": 179,
"platformSettings": {},
"subMetas": {
"微信图片_20201223212514": {
"combined-shape": {
"ver": "1.0.4",
"uuid": "e07ee970-0aec-4531-952b-0b42d6d84260",
"rawTextureUuid": "baa2e22b-b057-4736-8aeb-955f7a401d93",
"uuid": "436ddb1e-bc7a-458b-b8e3-4f3eba78399c",
"rawTextureUuid": "cd81f7fe-319d-4dfb-974c-71019f7f9a2c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2222,
"height": 1324,
"rawWidth": 2222,
"rawHeight": 1324,
"width": 179,
"height": 179,
"rawWidth": 179,
"rawHeight": 179,
"borderTop": 0,
"borderBottom": 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