Commit 88e32403 authored by yu's avatar yu

新增图片类型

parent 1bad1dfe
This diff is collapsed.
......@@ -37,11 +37,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Node)
img_record: cc.Node = null;
@property(cc.Node)
record_word: cc.Node = null;
layout_pic: cc.Node = null;
@property(cc.Node)
question_word: cc.Node = null;
layout_word: cc.Node = null;
@property(cc.Node)
box2d: cc.Node = null;
@property(cc.Node)
layout_img: cc.Node = null;
onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
......@@ -69,6 +71,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.btn_record.on(cc.Node.EventType.TOUCH_END, this.onRecord, this);
this.btn_laba.on(cc.Node.EventType.TOUCH_END, this.showLaba, this);
this.img_record.on(cc.Node.EventType.TOUCH_END, this.onTouchRecordEnd, this);
cc.find("btn_close", this.layout_img).on(cc.Node.EventType.TOUCH_END, this.onCloseTips, this);
pg.event.on("game_start", () => {
this.gameStart();
});
......@@ -88,7 +91,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
gameStart(isPlayAudio = true) {
Game.getIns().state = GAME_STATE.RUNNING;
this.showQuestion();
this.showQuestion(isPlayAudio);
isPlayAudio && this.showLaba();
}
......@@ -98,8 +101,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
zjz_ske.active = false;
this.playLocalAudio("again");
this.initData();
this.record_word.getComponent(cc.Label).string = "";
this.question_word.getComponent(cc.Label).string = "";
// this.record_word.getComponent(cc.Label).string = "";
// this.question_word.getComponent(cc.Label).string = "";
pg.event.emit("mouse_10_num", Game.getIns().total);
pg.event.emit('box2d_init', Game.getIns().getTotalPageNum());
this.gameStart();
......@@ -111,14 +114,84 @@ export default class SceneComponent extends MyCocosSceneComponent {
// let item = this.node.getChildByName("item");
// item.y -= 5;
}
private showQuestion() {
private showQuestion(showImg = true) {
let question = Game.getIns().getCurrentPage();
this.question_word.getComponent(cc.Label).string = question.text;
if (question.type == "txt") {
let question_word = cc.find("question_word", this.layout_word);
question_word.getComponent(cc.Label).string = question.text;
let record_word = cc.find("record_word", this.layout_word);
record_word.getComponent(cc.Label).string = "";
this.layout_word.active = true;
this.layout_pic.active = false;
} else {
let question_word = cc.find("question_word", this.layout_pic);
question_word.getComponent(cc.Label).string = question.text;
let record_word = cc.find("record_word", this.layout_pic);
record_word.getComponent(cc.Label).string = "";
let pic = cc.find("pic", this.layout_pic);
pg.view.setNetImg(pic, question.picUrl, { w: 242, h: 242 });
this.layout_word.active = false;
this.layout_pic.active = true;
pic.on(cc.Node.EventType.TOUCH_END, this.showBigPic, this);
showImg && this.showLayoutImg();
}
}
private showRecordWord(word) {
let question = Game.getIns().getCurrentPage();
if (question.type == "txt") {
let record_word = cc.find("record_word", this.layout_word);
record_word.getComponent(cc.Label).string = word || "";
} else {
let record_word = cc.find("record_word", this.layout_pic);
record_word.getComponent(cc.Label).string = word || "";
}
}
private showLayoutImg(hide = true) {
let question = Game.getIns().getCurrentPage();
if (question.type != "img") return;
let big_pic = cc.find("big_pic", this.layout_img);
big_pic.setPosition(0, 0);
big_pic.scale = 1;
pg.view.setNetImg(big_pic, question.picUrl, { w: 720, h: 720 });
this.layout_img.active = true;
hide && this.tipsActionHide();
}
private tipsActionHide(isAction = true) {
let big_pic = cc.find("big_pic", this.layout_img);
let small_pic = cc.find("small_pic", this.layout_img);
let scaleX = small_pic.width / big_pic.width;
let scaleY = small_pic.height / big_pic.height;
let t = isAction ? 4 : 0;
let btn = cc.find("btn_close", this.layout_img);
btn.active = false;
cc.tween(big_pic).delay(t).to(0.3, { scaleX: scaleX, scaleY: scaleY, x: small_pic.x, y: small_pic.y })
.call(() => {
this.layout_img.active = false;
})
.start();
}
private showBigPic() {
let big_pic = cc.find("big_pic", this.layout_img);
let small_pic = cc.find("small_pic", this.layout_img);
let scaleX = small_pic.width / big_pic.width;
let scaleY = small_pic.height / big_pic.height;
big_pic.x = small_pic.x;
big_pic.y = small_pic.y;
small_pic.scaleX = scaleX;
small_pic.scaleY = scaleY;
this.layout_img.active = true;
let btn = cc.find("btn_close", this.layout_img);
cc.tween(big_pic).to(0.3, { scaleX: 1, scaleY: 1, x: 0, y: 0 })
.call(() => {
btn.active = true;
})
.start();
}
private onCloseTips() {
this.tipsActionHide(false);
}
private showTip(show = true) {
let tip_bg = cc.find("btn_record/tip_bg", this.node);
......@@ -224,7 +297,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (this.recordIntervalId) clearInterval(this.recordIntervalId);
this.btn_record.active = true;
this.img_record.active = false;
this.record_word.getComponent(cc.Label).string = data.text;
this.showRecordWord(data.text)
if (data.text == Game.getIns().getCurrentPage().word) {
this.playLocalAudio("right").then(() => {
this.playLocalAudio("diaoluo");
......@@ -288,7 +361,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.event.emit("box2d_roll")
} else {
this.playLocalAudio("next");
this.record_word.getComponent(cc.Label).string = "";
this.showRecordWord("")
this.gameStart();
}
}
......@@ -332,12 +405,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc.tween(start_ske).delay(1).by(0.5, { x: 500 }).call(() => {
this.layout_start.active = false;
this.showLaba(true);
this.showLayoutImg();
}).start();
});
}).start();
} else {
this.layout_start.active = false;
this.showLaba(true);
this.showLayoutImg();
}
})
}
......
......@@ -45,16 +45,18 @@ export class Item {
public audio;
public duration;
public optionList;
public bgItem;
public hotZoneItemArr;
public word;
public picUrl;
public type;
public text: string;
public isClick: boolean;
constructor(data, page) {
this.audio = data.audio;
this.text = data.text;
this.word = data.word;
this.type = data.type;
this.duration = data.time;
this.picUrl = data.image;
this.page = page;
// this.optionList = data.options.map((o, idx) => {
......
......@@ -23,13 +23,13 @@ export const defaultData =
"type": "img",
"audio": "http://staging-teach.cdn.ireadabc.com/449e65975d358514cc3494f9f67bc012_l.mp3",
"text": "what are you kettle ?",
"image": "",
"image": "http://staging-teach.cdn.ireadabc.com/95c760f287a3c55bacc6c12ea47259ea.jpg",
"time": 10,
"audioName": "cape.mp3",
"word": "oh no"
},
{
"type": "img",
"type": "txt",
"audio": "http://staging-teach.cdn.ireadabc.com/944ae51b57fb9390dd03104d9651e5f4_l.mp3",
"text": "what your name ?",
"image": "",
......@@ -38,7 +38,7 @@ export const defaultData =
"word": "join"
},
{
"type": "img",
"type": "txt",
"audio": "http://staging-teach.cdn.ireadabc.com/36067f9e2415d59fa37c3795a3929087_l.mp3",
"text": "what are you disdain?",
"image": "",
......
{
"ver": "2.3.5",
"uuid": "f2e561fb-156c-4edc-9137-5dc6ef1b3f7f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1096,
"height": 424,
"platformSettings": {},
"subMetas": {
"bg3": {
"ver": "1.0.4",
"uuid": "3f24ea61-fd4e-47c5-92fb-101bf0bd77f7",
"rawTextureUuid": "f2e561fb-156c-4edc-9137-5dc6ef1b3f7f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1096,
"height": 424,
"rawWidth": 1096,
"rawHeight": 424,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "cb5ae762-1e06-4f54-b95a-ee1b84c36a7c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 911,
"height": 107,
"platformSettings": {},
"subMetas": {
"bg_text": {
"ver": "1.0.4",
"uuid": "d9143143-15c2-4f19-ab93-79f11b0fde4a",
"rawTextureUuid": "cb5ae762-1e06-4f54-b95a-ee1b84c36a7c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 911,
"height": 107,
"rawWidth": 911,
"rawHeight": 107,
"borderTop": 30,
"borderBottom": 30,
"borderLeft": 60,
"borderRight": 60,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "1f5ec521-15a2-49f0-8237-747efff6f487",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 60,
"height": 60,
"platformSettings": {},
"subMetas": {
"btn_close": {
"ver": "1.0.4",
"uuid": "61e4ee90-b002-4136-a69e-d680cb74b360",
"rawTextureUuid": "1f5ec521-15a2-49f0-8237-747efff6f487",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 60,
"height": 60,
"rawWidth": 60,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "846774ad-b6a9-4f31-9ac7-6ccc8d505d6e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 250,
"height": 250,
"platformSettings": {},
"subMetas": {
"pic": {
"ver": "1.0.4",
"uuid": "38b63c37-4f15-441d-b599-8804e758545f",
"rawTextureUuid": "846774ad-b6a9-4f31-9ac7-6ccc8d505d6e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 250,
"height": 250,
"rawWidth": 250,
"rawHeight": 250,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "da449a78-119f-43a0-970e-bae114518b2a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 252,
"height": 252,
"platformSettings": {},
"subMetas": {
"pic_box": {
"ver": "1.0.4",
"uuid": "c6d5765b-730f-4f41-b95e-8241655ad3a2",
"rawTextureUuid": "da449a78-119f-43a0-970e-bae114518b2a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 252,
"height": 252,
"rawWidth": 252,
"rawHeight": 252,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
......@@ -110,7 +110,21 @@
题目{{i+1}}
</div>
<div style="margin-top: 20px;">
<div class="word-type-option-title">
题目类型:
</div>
<div style="margin-top: 5px;">
<nz-radio-group [(ngModel)]="question.type" (ngModelChange)="ngChange()">
<label nz-radio nzValue="img">
<span [style]="{color:question.type=='img' ? '#169BD5':'#000'}">图片</span>
</label>
<label nz-radio nzValue="txt">
<span [style]="{color:question.type=='txt' ? '#169BD5':'#000'}">文字</span>
</label>
</nz-radio-group>
</div>
</div>
<div class="option-text">
<div class="word-input-title">
<span style="color:red;margin-left:-15px">* </span>
......@@ -144,13 +158,13 @@
</div>
</div>
</div>
<!-- <div>
<div *ngIf="question.type=='img'">
<span style="font-size: 20px;">标题图片: </span>
<div style="width:300px">
<app-upload-image-with-preview [picUrl]="question.image"
(imageUploaded)="onImageUploadSuccess($event,'image',question)"></app-upload-image-with-preview>
</div>
</div> -->
</div>
<div class="option-time">
<div class="word-input-title">
<span>录音时间: </span>
......@@ -160,15 +174,15 @@
</div>
<div style="margin:0 20px">
<button class="btn-red" nz-button nzType="default" nzDanger (click)="removeQuestion(i)">删除题目</button>
<button class="btn-blue" style="margin-top: 10px;" nz-button
nzType="default" nzDanger (click)="copyQuestion(i)">复制题目</button>
<button class="btn-blue" style="margin-top: 10px;" nz-button nzType="default" nzDanger
(click)="copyQuestion(i)">复制题目</button>
</div>
</div>
</div>
<div style="margin-top: 20px;">
<button class="btn-blue" style="width: 1000px; height: 50px;" nz-button
nzType="default" nzDanger (click)="addQuestion()">+增加题目</button>
<button class="btn-blue" style="width: 1000px; height: 50px;" nz-button nzType="default" nzDanger
(click)="addQuestion()">+增加题目</button>
</div>
</div>
......
......@@ -52,7 +52,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
addQuestion() {
// if (this.item.questions.length == 6) return;
this.item.questions.push({
type: 'img',
type: 'txt',
audio: '',
text: '',
image: '',
......@@ -97,4 +97,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
console.log(e);
this.save();
}
ngChange() {
this.save();
}
}
\ 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