Commit a8d754cc authored by 邵世尧's avatar 邵世尧

提交

parent 7cae4830
......@@ -66,7 +66,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}, this.saveKey);
this.initData();
// this.initData();
}
ngOnChanges() {
......@@ -106,17 +106,30 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
sideA(){
this.item.sideA=1;
this.item.sideB=0;
this.picArr=[];
this.item.contentObj.picArr = this.picArr;
this.save();
console.log('radiovalue:' , this.radioValue);
console.log('item:' , this.item);
for(let i=0;i<6;i++){
let item = this.cardItemData();
this.picArr.push(item);
}
this.saveItem();
}
sideB(){
this.item.sideB=1;
this.item.sideA=0;
this.save();
console.log('item:' , this.item);
this.picArr=[];
this.item.contentObj.picArr = this.picArr;
for(let i=0;i<6;i++){
let item = this.cardItemData();
this.picArr.push(item);
}
this.saveItem();
console.log('init~data:', this.picArr);
}
getDefaultPicArr() {
......@@ -126,20 +139,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
initData() {
addItem6() {
this.picArr=[];
this.item.contentObj.picArr = this.picArr;
for(let i=1;i<=6;i++){
for(let i=0;i<6;i++){
let item = this.cardItemData();
this.picArr.push(item);
}
this.saveItem();
console.log('init~data:', this.picArr);
}
......
......@@ -1674,3 +1674,55 @@ export function shake(item, time = 0.5, callback = null, rate = 1) {
// --------------- custom class --------------------
export function showBlingBling(starImg, rectArea, parent, mapScale = 1, num = 30, disTime = 0.1, showTime = 3) {
const timeId = setInterval(() => {
showBlingStar(starImg, num, rectArea, parent, mapScale);
}, disTime * 1000);
//
// const tmpObj = {};
// tmpObj['timeId'] = timeId;
setTimeout(() => {
clearInterval(timeId);
}, showTime * 1000);
}
function showBlingStar(starImg, num, rectArea, parent, mapScale) {
for (let i = 0; i < num; i++) {
const star = new MySprite();
star.init(starImg);
const px = rectArea.x + Math.random() * rectArea.width;
const py = rectArea.y + Math.random() * rectArea.height;
star.x = px;
star.y = py;
console.log("startx"+star.x);
console.log("starty"+star.y);
const randomS = (0.1 + Math.random() * 0.8) * mapScale;
star.setScaleXY(0);
parent.addChild(star);
scaleItem(star, randomS, 0.3, () => {
setTimeout(() => {
scaleItem(star, 0, 0.3, () => {
parent.removeChild(star);
});
}, 100 + Math.random() * 200);
});
}
}
......@@ -2,7 +2,7 @@ import {Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListener
import {
Label,
MySprite, tweenChange, MyAnimation, randomSortByArr, ShapeRect, getMinScale, showPopParticle, moveItem, removeItemFromArr, rotateItem, showStar, showItem, alphaItem, endShow, hideItem,
MySprite, tweenChange, MyAnimation, randomSortByArr, ShapeRect, getMinScale, showPopParticle, moveItem, removeItemFromArr, rotateItem, showStar, showItem, alphaItem, endShow, hideItem, showBlingBling,
} from './Unit';
import {res, resAudio} from './resources';
......@@ -778,7 +778,10 @@ getPetal() {
bg
startBorder
bgLayer
initBg() {
this.bgLayer = new MySprite();
this.renderArr.push(this.bgLayer);
const bg = new ShapeRect();
bg.fillColor = '#75d100';
......@@ -805,6 +808,7 @@ initBg() {
}
count=0;
active=1;
last
mapDown(event) {
//点击按钮,骰子竖直跳下来,卡片弹出来
......@@ -844,6 +848,7 @@ active=1;
if (this.checkClickTarget( this.t)) {
console.log(this.canTouch+"-----00000000000");
this.a.stop();
this.w.stop();
this.canTouch = false;
......@@ -912,6 +917,12 @@ active=1;
//骰子转动,给一个随机数
this.canTouch = false;
this.tAnimation();
if(this.count!=1){
hideItem(this.faguang[this.last]);
}
if(this.count==6){
this.count=0;
setTimeout(() => {
......@@ -931,7 +942,7 @@ active=1;
});
}, 180);
}, 4000);
}, 1800);
}
......@@ -1003,7 +1014,7 @@ active=1;
console.log(this.t[this.randomt]+"kongmei22222222");
const animation=new MyAnimation();
for(let j=0;j<6;j++){
for(let j=0;j<2;j++){
for(let i=0;i<6;i++){
const imgobj=this.images.get('touzi'+i);
animation. addFrameByImg(imgobj);
......@@ -1011,7 +1022,7 @@ active=1;
}
}
animation.delayPerUnit=0.08;
animation.delayPerUnit=0.09;
//骰子旋转
animation.play();
......@@ -1029,12 +1040,32 @@ active=1;
let x=3;
// this.t.init(this.images.get("t"+x));
this.t.init(this.images.get("t"+(this.randomt+1)));
alphaItem(this.faguang[this.randomt],1);
this.last=this.randomt;
this.overCard(this.cardArr[this.randomt],()=>{
this.showParticle(this.cardArr[this.randomt]);
//发光特效
//this.cardArr[this.randomt].faguang.visible=true;
// this.cardArr[this.randomt].children[]
let rect = this.cardArr[this.randomt].getBoundingBox();
rect.x=this.cardArr[this.randomt].x-120;
rect.y=this.cardArr[this.randomt].y-140;
rect.width=250;
rect.height=250;
console.log("rect"+rect.width);
console.log("cardx"+this.cardArr[this.randomt].x);
console.log("cardy"+this.cardArr[this.randomt].y);
showBlingBling(this.images.get('ss'), rect, this.bgLayer, this.mapScale*1.5, 1, 0.05, 1.5);
});
console.log("old"+this.newball);
this.newball.splice(0,1);
console.log("new+"+this.newball);
this.a.start();
this.w.start();
......@@ -1048,44 +1079,7 @@ active=1;
ss2
ss3
ss4
showParticle(card){
this.ss1=new MySprite();
this.ss1.init(this.images.get("ss"));
card.addChild(this.ss1);
this.ss1.x=-100;
this.ss1.y=100;
showItem(this.ss1);
this.ss2=new MySprite();
this.ss2.init(this.images.get("ss"));
card.addChild(this.ss2);
this.ss2.x=-120;
this.ss2.y=80;
showItem(this.ss2);
this.ss3=new MySprite();
this.ss3.init(this.images.get("ss"));
card.addChild(this.ss3);
this.ss3.x=130;
this.ss3.y=-60;
showItem(this.ss3);
this.ss4=new MySprite();
this.ss4.init(this.images.get("ss"));
card.addChild(this.ss4);
this.ss4.x=120;
this.ss4.y=-90;
this.ss4.setScaleXY(2*this.mapScale);
showItem(this.ss4);
hideItem(this.ss1);
hideItem(this.ss2);
hideItem(this.ss3);
hideItem(this.ss4);
// showStar(this.ss,0.4);
// showPopParticle(this.images.get('ss'), {x: card.x/6.8,y: card.y-400} ,this.startBorder);
}
oldball
newball
......@@ -1179,7 +1173,7 @@ newball
});
setTimeout(() => {
tweenChange(cardArr[i], {scaleX: 1, scaleY: 1}, 0.3);
tweenChange(cardArr[i], {scaleX: 0.5, scaleY: 0.5}, 0.3);
}, 1000);
......@@ -1196,35 +1190,39 @@ newball
});
});
}
front
q
front=[]
back=[]
bs=[];
faguang=[]
randomItemCard(){
this.cardArr = [];
for(let i=0;i<6;i++){
let item = this.picArr[i];
let pic = new MySprite();
//初始化设置为隐藏
pic.alpha = 1;
pic.childDepandAlpha = true;
//声明正反面的对象
this.back[i] = new MySprite();
this.front = new MySprite();
this.front.init(this.images.get("front"));
this.front[i] = new MySprite();
this.faguang[i]=new MySprite();
this.faguang[i].alpha=0;
//设置索引
pic["index"] = i;
//给正反面添加默认的显示图片
// this.back1.init(this.images.get("cardBg6"));
// this.front1.init(this.images.get("frontBg"));
//内嵌框
this.faguang[i].init(this.images.get("发光"));
let bgRect = new ShapeRect();
bgRect.setSize(180, 180);
bgRect.setSize(390, 390);
bgRect.init();
bgRect.fillColor = '#ff83fa';
this.front.addChild(bgRect, -1);
this.front[i].addChild(bgRect, -1);
this.q=bgRect;
......@@ -1240,7 +1238,7 @@ bs=[];
pic.addChild(this.back[i]);
pic.addChild(this.front);
pic.addChild(this.front[i]);
}
else if(this.data.sideB==1){
......@@ -1248,7 +1246,7 @@ bs=[];
this.bs[i]=0;
}
pic.addChild(this.front);
pic.addChild(this.front[i]);
pic.addChild(this.back[i]);
......@@ -1260,33 +1258,34 @@ bs=[];
console.log(item.audio_url+"pic-audio");
}
const maxLen = 160;
const maxLen = 400;
if(item.pic_url){
let pic = new MySprite();
pic.init(this.images.get(item.pic_url));
//如果是横图设置图片填充卡片正面的比例
if(pic.width>=pic.height){
pic.setScaleXY(getMinScale(pic, maxLen-15));
if(pic.width>pic.height){
pic.setScaleXY(getMinScale(pic, maxLen));
pic.x=2;
this.front.addChild(pic);
this.front[i].addChild(pic);
}
//如果是竖图设置图片填充卡片正面的比例
if(pic.width<pic.height&&(pic.width+40)>=pic.height){
pic.setScaleXY(getMinScale(pic, maxLen));
if(pic.width<=pic.height&&(pic.width+40)>=pic.height){
pic.setScaleXY(getMinScale(pic, maxLen-80));
pic.x=0;
pic.y=-3;
}
//如果是正方图设置图片填充卡片正面的比例
if(pic.width<pic.height&&(pic.width+40)<pic.height){
pic.setScaleXY(getMinScale(pic, maxLen-10));
if(pic.width<=pic.height&&(pic.width+40)<pic.height){
pic.setScaleXY(getMinScale(pic, maxLen-60));
pic.x=-5;
pic.y=-6;
}
this.front.addChild(pic);
this.front[i].addChild(pic);
}else{
const label = new Label();
label.text = item.title;
......@@ -1297,10 +1296,13 @@ bs=[];
label.setMaxSize((bgRect.width - 20)+10);
console.log(bgRect.width - 20+"卡片文字位置");
this.front.addChild(label);
this.front[i].addChild(label);
}
this.front[i].addChild(this.faguang[i],-1);
this.back[i].addChild(this.faguang[i],-1);
this.cardArr.push(pic);
this.cardArr[i].alpha=1;
}
this.back[0].init(this.images.get("back0"));
......@@ -1309,6 +1311,12 @@ bs=[];
this.back[5].init(this.images.get("back1"));
this.back[3].init(this.images.get("back2"));
this.back[2].init(this.images.get("back2"));
this.front[0].init(this.images.get("front0"));
this.front[4].init(this.images.get("front0"));
this.front[1].init(this.images.get("front1"));
this.front[5].init(this.images.get("front1"));
this.front[3].init(this.images.get("front2"));
this.front[2].init(this.images.get("front2"));
}
......@@ -1335,6 +1343,7 @@ bs=[];
this.updateArr(this.renderArr);
this.updateItem(this.bgLayer);
}
......
......@@ -23,10 +23,13 @@ const res = [
['touzi3',"assets/play/4.png"],
['touzi4',"assets/play/5.png"],
['touzi5',"assets/play/6.png"],
['front',"assets/play/front.png"],
['front0',"assets/play/front0.png"],
['front1',"assets/play/front1.png"],
['front2',"assets/play/front2.png"],
['back0',"assets/play/back0.png"],
['back1',"assets/play/back1.png"],
['back2',"assets/play/back2.png"],
['发光',"assets/play/发光.png"],
];
......
src/assets/play/back0.png

39 KB | W: | H:

src/assets/play/back0.png

56.3 KB | W: | H:

src/assets/play/back0.png
src/assets/play/back0.png
src/assets/play/back0.png
src/assets/play/back0.png
  • 2-up
  • Swipe
  • Onion skin
src/assets/play/back1.png

39.6 KB | W: | H:

src/assets/play/back1.png

50.1 KB | W: | H:

src/assets/play/back1.png
src/assets/play/back1.png
src/assets/play/back1.png
src/assets/play/back1.png
  • 2-up
  • Swipe
  • Onion skin
src/assets/play/back2.png

54.5 KB | W: | H:

src/assets/play/back2.png

55.7 KB | W: | H:

src/assets/play/back2.png
src/assets/play/back2.png
src/assets/play/back2.png
src/assets/play/back2.png
  • 2-up
  • Swipe
  • Onion skin
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