dashen-tool
Version:
无法超越的大神代码
1,355 lines (1,336 loc) • 37.5 kB
JavaScript
(function(){
var M = window.innerHeight,
S = window.innerWidth,
// S = 750,
R = PIXI.Container,
j = (PIXI.autoDetectRenderer,PIXI.loader),
q = (PIXI.loader.resources,
PIXI.utils.TextureCache,
PIXI.Texture,
PIXI.Text),
A = (new PIXI.ticker.Ticker,PIXI.Sprite),
L = (PIXI.Rectangle,
PIXI.Graphics),
X = new R;
X.width = S,
X.height = M;
S = 750;
var v = window.navigator.userAgent.toLowerCase(),
u = navigator.userAgent,
P = /iphone|nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|mobile/i.test(v) && !/pc=1/.test(location.search),
k = "micromessenger" == v.match(/MicroMessenger/i),//微信浏览器
C = "newsapp" == v.match(/newsapp/i),
I = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1,//android终端
U = (!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),//ios终端
/iphone/gi.test(navigator.userAgent) && 812 == screen.height && 375 == screen.width),
T = "https://static.ws.126.net/163/f2e/sales/health/nianyefan/v1/";
// T = "";
U && $("body").addClass("iphoneX");
$(".sleeping_content").width(750).height(M);
var mo=function(e){e.preventDefault();};
function stopMove(){
document.addEventListener("touchmove",mo,{passive: false});//禁止页面滑动
}
function canMove(){
document.removeEventListener("touchmove",mo,{passive: false});
}
function ANGLE(o, t) {
var n = t.x - o.x,
i = t.y - o.y,
e = Math.acos(i / Math.sqrt(n * n + i * i));
return n >= 0 && i >= 0 ? e = 2 * Math.PI - e : n >= 0 && i <= 0 && (e = 2 * Math.PI - e),
e
}
function DISTANCE(o, t) {
var n = Math.sqrt(Math.pow(t.x - o.x, 2) + Math.pow(t.y - o.y, 2));
return n
}
function getBeveling(o, t) {
return Math.sqrt(Math.pow(o, 2) + Math.pow(t, 2))
}
function convertCanvasToImage(o) {
var t = new Image;
return t.src = o.toDataURL("image/png"),
t
}
//禁止滑动
// stopMove();
// var app = new PIXI.Application({
// width: S,
// height: M,
// antialias: true,
// transparent: false,//透明度
// resolution: 1,
// backgroundColor: 0xd6362a,
// // backgroundColor: 16777215
// preserveDrawingBuffer:true
// });
var app = new PIXI.CanvasRenderer(S, M, {
backgroundColor: 16777215
});
$("#content").append(app.view);
var W = new R,Bg = new R,G = new R,E = new R,F = new R,Room = new R,Table = new R,Person = new R;
var r = new L;
r.beginFill(16777215),
// r.drawRect(0, 0, 750, M),
r.drawRect(0, 0, 750, (M-170-145-30)/0.88),
r.endFill();
var r1 = new L;
r1.beginFill(16777215),
r1.drawRect(0, 0, 750, M),
r1.endFill();
// G.mask = r;
G.addChild(r,r1);
W.addChild(Bg,F,G);
app.render(W);
d();
j.add(T + "img/share.png").add(T + "img/person1/p11.png").add(T + "img/person1/p33.png").add(T + "img/person1/p55.png").add(T + "img/person1/p77.png")
.add(T + "img/person1/p99.png").add(T + "img/person1/p22.png").add(T + "img/person1/p44.png").add(T + "img/person1/p66.png")
.add(T + "img/person1/p88.png").add(T + "img/person1/p10.png")
.add(T + "img/bg.png")
.add(T + "img/bg/room1.png").add(T + "img/bg/room2.png")
.add(T + "img/bg/room3.png").add(T + "img/bg/room4.png").add(T + "img/bg/room5.png")
.add(T + "img/bg/t1.png").add(T + "img/bg/t2.png")
.add(T + "img/bg/t3.png").add(T + "img/bg/t4.png").add(T + "img/bg/t5.png")
.add(T + "img/food2/f1.png").add(T + "img/food2/f2.png").add(T + "img/food2/f3.png").add(T + "img/food2/f4.png").add(T + "img/food2/f5.png")
.add(T + "img/food2/meat1.png").add(T + "img/food2/meat2.png").add(T + "img/food2/meat3.png").add(T + "img/food2/meat4.png")
.add(T + "img/food2/meat5.png").add(T + "img/food2/meat6.png").add(T + "img/food2/meat7.png").add(T + "img/food2/meat8.png")
.add(T + "img/food2/meat9.png").add(T + "img/food2/meat10.png").add(T + "img/food2/meat11.png").add(T + "img/food2/meat12.png")
.add(T + "img/food2/s1.png").add(T + "img/food2/s2.png").add(T + "img/food2/s3.png").add(T + "img/food2/s4.png").add(T + "img/food2/s5.png")
.add(T + "img/food2/x1.png").add(T + "img/food2/x2.png").add(T + "img/food2/x3.png").add(T + "img/food2/x4.png").add(T + "img/food2/x5.png")
.add(T + "img/food2/y1.png").add(T + "img/food2/y2.png").add(T + "img/food2/y3.png").add(T + "img/food2/y4.png")
.add(T + "img/food2/b1.png").add(T + "img/food2/b2.png").add(T + "img/food2/b3.png").add(T + "img/food2/b4.png")
.add(T + "img/food2/b5-1.png").add(T + "img/food2/b6-1.png").add(T + "img/food2/b7-1.png")
.add(T + "img/food2/b5-2.png").add(T + "img/food2/b6-2.png").add(T + "img/food2/b7-2.png").add(T + "img/food2/b8.png")
.add(T + "img/food2/b9.png").add(T + "img/food2/b10.png").add(T + "img/food2/b11.png").add(T + "img/food2/b12.png")
.add(T + "img/food2/c1.png").add(T + "img/food2/c22.png").add(T + "img/food2/c3.png").add(T + "img/food2/c4.png")
.add(T + "img/rotate.png").add(T + "img/flower.png")
.add(T + "img/scale.png").add(T + "img/ewm1.png").add(T + "img/bottom_logo.png")
.add(T + "img/del.png").on("progress", loadProgressHandler).load(go);
function go() {
var background = new A(j.resources[T + "img/bg.png"].texture);
background.width=S;
background.height=M;
Bg.addChild(background);
background.position.x=0;
background.position.y=0;
roomSelect(0,0);
tableSelect(1);
setTimeout(function(){
$('.start').fadeIn(2000);
$('.foods').addClass("pauseani")
},100)
}
function d() {
TWEEN.update();
requestAnimationFrame(d);
app.render(W);
}
$('.start').click(function(){
$('.loading').fadeOut();
});
function roomSelect(a,b) {
if (Room.children.length) {
Room.removeChildren();
}
if (Room.children.length==0) {
var room = new A(j.resources[T+z[a][b].imgUrl].texture);
room.interactive = !0;
room.width =S;
room.height =M;
room.on('touchstart', onDragShow);
Room.addChild(room);
G.addChild(Room);
}
}
function tableSelect(a) {
if (Table.children.length) {
Table.removeChildren();
}
if (Table.children.length==0) {
var table = new A(j.resources[T + "img/bg/t"+a+".png"].texture);
table.width=S;
table.position.x=0;
table.position.y=M-731;
Table.addChild(table);
table.on('touchstart', onDragShow);
G.addChild(Table);
}
}
var hit=false,hitScale=false,padding=0,isEnd= false,lastTarget=null;
var positionXY=[
[{x:10,y:200},{x:80,y:200},{x:150,y:200},{x:220,y:200},{x:290,y:200},{x:360,y:200}],
[{x:20,y:520},{x:100,y:520},{x:160,y:520},{x:210,y:520},{x:260,y:520},{x:310,y:520},{x:360,y:520},{x:400,y:520},{x:460,y:520},{x:500,y:520}],
];
function clearStage(){
if(lastTarget){
for (var i = 0; i < lastTarget.children.length; i++) {
if (i > 0) {
lastTarget.children[i].visible = false;
}
}
}
}
function setup (a,b){
clearStage();
// console.log("All files loaded");
// console.log(a,b)
// console.log([z[a][b].imgUrl]);
// var body = new A(j.resources[T + "img/p1.png"].texture);
var body = new A(j.resources[T+z[a][b].imgUrl].texture);
body.x = 0;
body.y = 0;
body.width = z[a][b].imgPosition.w;
body.height = z[a][b].imgPosition.h;
body.anchor.x=0.5;
body.anchor.y = 0.5;
var rotate = new A(j.resources[T + "img/rotate.png"].texture);
var del = new A(j.resources[T + "img/del.png"].texture);
var scale = new A(j.resources[T + "img/scale.png"].texture);
var border = new L; //绘制虚线轮廓
border.lineStyle(1, 0xff1010, 1);
border.drawRect(0, 0, body.width, body.height);
border.endFill();
border.x = body.x-body.width/2-padding/2;
border.y = body.y-body.height/2-padding/2;
border.width = body.width+padding;
border.height = body.height+padding;
border.visible = !1;
rotate.width = 56;
rotate.height = 56;
rotate.x = border.x-rotate.width/2;
rotate.y = border.y-rotate.height/2;
rotate.defaultstate = !0; //默认显示旋转按钮
rotate.visible = !1;
del.width = 56;
del.height = 56;
del.x = border.x + body.width-del.width/2+padding;
del.y = border.y -del.height/2;
del.defaultstate = !0; //默认显示旋转按钮
del.visible = !1;
scale.width = 56;
scale.height = 56;
scale.x = border.x + border.width - scale.width/2;
scale.y = border.y + border.height - scale.height/2;
scale.defaultstate = !0; //默认显示缩放按钮
scale.visible = !1;
border.interactive = scale.interactive = del.interactive = body.interactive = !0;
rotate.interactive = 0;
var editContainer = new R;
var materialContainer = new R;
editContainer.interactive=!0;
materialContainer.interactive=!0;
editContainer.addChild(body);
materialContainer.addChild(editContainer,border,rotate,del,scale);
// ---当前对象赋给最后一个
lastTarget=materialContainer;
if (indexSe==1||indexSe==7) {
var newP = positionXY[0][parseInt(Math.random() * positionXY[0].length)];
z[a][b].imgPosition.x=newP.x;
z[a][b].imgPosition.y=newP.y;
if (indexSe==7) {
if (b==4||b==6||b==8) {
z[a][b].imgPosition.x=0;
z[a][b].imgPosition.y=0
}
if (b==5||b==7||b==9) {
z[a][b].imgPosition.x=S-z[a][b].imgPosition.w-56;
z[a][b].imgPosition.y=0;
}
}
}
if (indexSe==2||indexSe==3||indexSe==4||indexSe==5||indexSe==6||indexSe==8) {
var newP = positionXY[1][parseInt(Math.random() * positionXY[1].length)];
z[a][b].imgPosition.x=newP.x;
z[a][b].imgPosition.y=newP.y;
}
materialContainer.position.set(materialContainer.width/2+28+z[a][b].imgPosition.x,materialContainer.height/2+28+z[a][b].imgPosition.y);
// materialContainer.position.set(materialContainer.width/2+z[a][b].imgPosition.x,materialContainer.height/2+z[a][b].imgPosition.y);
materialContainer.on('touchstart', onDragStart1)
.on('touchend', onDragEnd)
.on('touchmove', onDragMove1);
if (indexSe==1||indexSe==7) {
// console.log('选人物了或者配饰');
Person.addChild(materialContainer);
Person.active=!0;
}else {
// console.log('没有选人物');
E.addChild(materialContainer);
// G.addChild(Person,Table,E);
}
if(lastTarget!=null){
for (var i = 0; i < lastTarget.children.length; i++) {
if (i > 0) {
lastTarget.children[i].visible = true;
}
}
}
if ($(".save").fadeIn()) {
if (E.children.length||Person.children.length) {
$(".save").fadeIn();
$('.write').css('top','-180px');
}
}
G.addChild(Person,Table,E);
// console.log('------------------------------')
// console.log(E.children)
// console.log(Person.children)
// console.log('------------------------------')
rotate.interactive = !0;
rotate.on('touchstart',function(o){
hit=true;
o.stopPropagation();
this.dragging = !0;
var t = o.data.global;
this.parent.rotation = this.parent.rotation;
var n = ANGLE({
x: this.parent.position.x,
y: this.parent.position.y
}, t);
this.startRotation = n-this.parent.rotation;
}).on("touchmove", function(o) {
if (this.dragging&&hit) {
var t = o.data.global,
n = ANGLE({
x: this.parent.position.x,
y: this.parent.position.y
}, t);
this.parent.rotation = n - this.startRotation;
}
}).on("touchendoutside", function(o) {
var hit=false;
this.dragging = !1
}).on("touchend", function(o) {
var hit=false;
this.dragging = !1
});
// 删除
// del.buttonMode = !0;
del.on("touchstart", function(o) {
o.stopPropagation();
this.parent.parent.removeChild(this.parent);
});
// 放大缩小
scale.on('touchstart',function(o){
o.stopPropagation();
if (!this.dragging) {
this.data = o.data;
this.dragging = true;
hitScale=true;
// this.scale.x *= 1.1;
// this.scale.y *= 1.1;
// this.dragPoint = o.data.getLocalPosition(this.parent);
this.dragPoint = o.data.getLocalPosition(this.parent.children[0]);
this.parent.children[0]._boundsRect = this.parent.children[0].width;
console.log('fff'+this.dragPoint.x,this.dragPoint.y)
// this.dragPoint.x -= this.x;
// this.dragPoint.y -= this.y;
}
}).on("touchmove", function(o) {
if (this.dragging&&hitScale) {
var newPosition = this.data.getLocalPosition(this.parent.children[0]);
// console.log('asdffff'+newPosition.x /this.dragPoint.x);
var newScale=newPosition.x /this.dragPoint.x;
if (newScale<1) {
if (this.parent.children[0].width<this.parent.children[0]._localBoundsRect.width/2) {
return false
}
}
this.parent.children[0].scale.x *= newScale;
this.parent.children[0].scale.y *= newScale;
// console.log(this)
// console.log(this.parent._localBoundsRect.width)
this.parent.children[1].x = this.parent.children[0].x-this.parent.children[0].width/2-padding/2;
this.parent.children[1].y = this.parent.children[0].y-this.parent.children[0].height/2-padding/2;
this.parent.children[1].width = this.parent.children[0].width+padding;
this.parent.children[1].height = this.parent.children[0].height+padding;
this.parent.children[2].x = this.parent.children[0].x-this.parent.children[0].width/2-rotate.width/2-padding/2;
this.parent.children[2].y = this.parent.children[0].y-this.parent.children[0].height/2-rotate.height/2-padding/2;
this.parent.children[3].x = this.parent.children[0].x +this.parent.children[0].width/2-del.width/2+padding/2;
this.parent.children[3].y = this.parent.children[0].y -this.parent.children[0].height/2-del.height/2-padding/2;
this.x = this.parent.children[0].x + this.parent.children[0].width/2 - scale.width/2+padding/2;
this.y = this.parent.children[0].y + this.parent.children[0].height/2 - scale.height/2;
}
}).on("touchendoutside", function(o) {
if (this.dragging) {
this.dragging = false;
hitScale = false;
this.data = null;
}
}).on("touchend", function(o) {
if (this.dragging) {
this.dragging = false;
hitScale = false;
this.data = null;
}
})
}
function loadProgressHandler(loader, resource) {
// console.log("loading: " + resource.url);
// console.log("progress: " + loader.progress + "%");
var TEXT = (loader.progress).toFixed(0) + "%";
$('.present').text(TEXT);
}
function onDragStart(event) {
if (!this.interactive) {return}
if (E.children.length) {
for (var i = 0; i < E.children.length; i++) {
if (E.children[i].dragging) {
return false
}
}
}
if (Person.children.length) {
for (var i = 0; i < Person.children.length; i++) {
if (Person.children[i].dragging) {
return false
}
}
}
if(this.parent.active) {
// console.log('我是人物,哈哈航啊哈航啊');
// console.log(this.parent)
var arr1=E.children;
var arr2;
for (var i = 0; i < arr1.length; i++) {
arr1[i].interactive=!0;
for (var a = 0; a < arr1[i].children.length; a++) {
for (var b = 0; b < arr1[i].children.length; b++) {
if (b>0) {
arr1[i].children[b].visible=!1;
}
}
if ( a == arr1[i].children.length-1) {
console.log('遍历出最后一个元素')
arr2=arr1[arr1.length-1].children;
for (var v = 0; v < arr2.length; v++) {
if (v>0) {
arr2[v].visible=!1;
}
}
}
}
}
Person.addChild(this);
// G.addChild(Person,Table,E);
}else {
console.log('点击我了。我是菜--------');
// this.parent.interactive=!1;
var arr3=Person.children;
var arr4;
for (var i = 0; i < arr3.length; i++) {
arr3[i].interactive=!0;
for (var a = 0; a < arr3[i].children.length; a++) {
// arr3[i].children[1,2,3,4].visible=!1;
for (var b = 0; b < arr3[i].children.length; b++) {
if (b>0) {
arr3[i].children[b].visible=!1;
}
}
if ( a == arr3[i].children.length-1) {
console.log('遍历出最后一个元素')
arr4=arr3[arr3.length-1].children;
for (var v = 0; v < arr4.length; v++) {
if (v>0) {
arr4[v].visible=!1;
}
}
}
}
}
// ---------
E.addChild(this);
// G.addChild(Person,Table,E);
}
console.log(E.children);
console.log(this.parent.children.length);
console.log(this.parent.children);
// this.parent
for (var d = 0; d < this.parent.children.length; d++) {
for (var f = 0; f < this.parent.children[d].children.length; f++) {
if (f>0) {
this.parent.children[d].children[f].visible=!1;
}
}
}
// if (true) {}
for (var c = 0; c < this.children.length; c++) {
if (c>0){
this.children[c].visible=!0;
}
}
if (!this.dragging) {
this.data = event.data;
this.dragging = true;
this.scale.x *= 1.1;
this.scale.y *= 1.1;
this.dragPoint = event.data.getLocalPosition(this.parent);
this.dragPoint.x -= this.x;
this.dragPoint.y -= this.y;
}
}
function onDragMove(o) {
if (this.dragging) {
var newPosition = this.data.getLocalPosition(this.parent);
this.x = newPosition.x - this.dragPoint.x;
this.y = newPosition.y - this.dragPoint.y;
}
}
function onDragEnd() {
if (this.dragging) {
// console.log('拖动结束')
this.dragging = false;
this.scale.x /= 1.1;
this.scale.y /= 1.1;
this.data = null;
}
}
function onDragStart1(event) {
// if(lastTarget){
// lastTarget.interactive=!1;
// console.log('111')
// for (var i = 0; i < lastTarget.children.length; i++) {
// if (i > 0) {
// lastTarget.children[i].visible = false;
// }
// }
// }
// console.log(this);
// console.log(this.interactive);
var current = event.currentTarget;
for (var i = 0; i < current.children.length; i++) {
if (i > 0) {
current.children[i].visible = true;
}
}
this.parent.interactive = !1;
console.log('target is on touch',event.currentTarget);
if (this.parent.active) {
if(lastTarget&&lastTarget != current){
for (var i2 = 0; i2 < lastTarget.children.length; i2++) {
if (i2 > 0) {
lastTarget.children[i2].visible = false;
}
}
}
if(lastTarget != current){
lastTarget = current;
}
Person.addChild(this);
}else {
if(lastTarget&&lastTarget != current){
for (var i3 = 0; i3 < lastTarget.children.length; i3++) {
if (i3 > 0) {
lastTarget.children[i3].visible = false;
}
}
}
if(lastTarget != current){
lastTarget = current;
}
E.addChild(this);
}
this.interactive = !0;
if (!this.dragging) {
this.data = event.data;
this.dragging = true;
xxx = true;
this.scale.x *= 1.1;
this.scale.y *= 1.1;
this.dragPoint = event.data.getLocalPosition(this.parent);
this.dragPoint.x -= this.x;
this.dragPoint.y -= this.y;
}
}
function onDragMove1(event) {
var ch = event.currentTarget.children[1];
if (this.dragging&&ch&&ch.visible) {
var newPosition = this.data.getLocalPosition(this.parent);
this.x = newPosition.x - this.dragPoint.x;
this.y = newPosition.y - this.dragPoint.y;
}
}
$(".arrow_bg").bind("click", function() {
$(".select_main").hasClass("close") ? ($(".select_main").removeClass("close"),
$(".black_icon").show()) : ($(".select_main").addClass("close"),
$(".black_icon").hide())
});
// 底部选择bar
var indexSe = 0;
$(".scroll_bar ul li").bind("click", function() {
$(".select_main").removeClass("close");
if (!$(this).hasClass("selected")) {
// $(".select_main").hasClass("close") && $(".select_main").removeClass("close"),
$(".selected").removeClass("selected"),
$(this).addClass("selected");
var t = $(this).index();
indexSe= t;
$(".select_item").hide();
$(".select_item").eq(t).show();
}
})
var B = [];
var z = [
[{
imgUrl:"img/bg/room1.png",
imgPosition: {
x: 300,
y: 400,
w: 92*1.5,
h: 158*1.5
}
},{
imgUrl:"img/bg/room2.png",
imgPosition: {
x: 300,
y: 500,
w:220,
h:220
}
},{
imgUrl:"img/bg/room3.png",
imgPosition: {
x: 300,
y: 500,
w:220,
h:220
}
},{
imgUrl:"img/bg/room4.png",
imgPosition: {
x: 300,
y: 500,
w:220,
h:220
}
},{
imgUrl:"img/bg/room5.png",
imgPosition: {
x: 300,
y: 500,
w:220,
h:220
}
}],
[{
imgUrl:"img/person1/p11.png",
imgPosition: {
x: 10,
y: 200,
w:637/3.5,
h:1608/3.5
}
},{
imgUrl:"img/person1/p22.png",
imgPosition: {
x: 100,
y: 200,
w:600/3.6,
h:1537/3.6
}
},{
imgUrl:"img/person1/p33.png",
imgPosition: {
x: 200,
y: 200,
w:864/3.5,
h:1791/3.5
}
},{
imgUrl:"img/person1/p44.png",
imgPosition: {
x: 360,
y: 200,
w:631/3.5,
h:1744/3.5
}
},{
imgUrl:"img/person1/p55.png",
imgPosition: {
x: 480,
y: 200,
w:836/4,
h:1913/4
}
},{
imgUrl:"img/person1/p66.png",
imgPosition: {
x: 480,
y: 200,
w:823/4,
h:1790/4
}
},{
imgUrl:"img/person1/p77.png",
imgPosition: {
x: 480,
y: 200,
w:768/4,
h:1920/4
}
},{
imgUrl:"img/person1/p88.png",
imgPosition: {
x: 480,
y: 200,
w:669/3.5,
h:1785/3.5
}
},{
imgUrl:"img/person1/p99.png",
imgPosition: {
x: 480,
y: 200,
w:667/5,
h:1447/5
}
},{
imgUrl:"img/person1/p10.png",
imgPosition: {
x: 480,
y: 200,
w:680/5,
h:1540/5
}
}],
[{
imgUrl:"img/food2/meat1.png",
imgPosition: {
x: 200,
y: 520,
w: 1208/6,
h: 1067/6
}
},{
imgUrl:"img/food2/meat2.png",
imgPosition: {
x: 200,
y: 520,
w:1575/7,
h:1069/7
}
},{
imgUrl:"img/food2/meat3.png",
imgPosition: {
x: 200,
y: 520,
w:1725/10,
h:1117/10
}
},{
imgUrl:"img/food2/meat4.png",
imgPosition: {
x: 200,
y: 520,
w:1275/7,
h:1136/7
}
},{
imgUrl:"img/food2/meat5.png",
imgPosition: {
x: 200,
y: 520,
w:1146/7,
h:1243/7
}
},{
imgUrl:"img/food2/meat6.png",
imgPosition: {
x: 200,
y: 520,
w:1495/7,
h:1395/7
}
},{
imgUrl:"img/food2/meat7.png",
imgPosition: {
x: 200,
y: 520,
w:1269/7,
h:1463/7
}
},{
imgUrl:"img/food2/meat8.png",
imgPosition: {
x: 200,
y: 520,
w:851/5,
h:1155/5
}
},{
imgUrl:"img/food2/meat9.png",
imgPosition: {
x: 200,
y: 520,
w:1586/8,
h:1070/8
}
},{
imgUrl:"img/food2/meat10.png",
imgPosition: {
x: 200,
y: 520,
w:1458/8,
h:1014/8
}
},{
imgUrl:"img/food2/meat11.png",
imgPosition: {
x: 200,
y: 520,
w:1555/8,
h:1060/8
}
},{
imgUrl:"img/food2/meat12.png",
imgPosition: {
x: 200,
y: 520,
w:1605/8,
h:1563/8
}
}],
[{
imgUrl:"img/food2/s1.png",
imgPosition: {
x: 200,
y: 520,
w: 1312/7.5,
h: 1147/7.5
}
},{
imgUrl:"img/food2/s2.png",
imgPosition: {
x: 200,
y: 520,
w:1519/7,
h:889/7
}
},{
imgUrl:"img/food2/s3.png",
imgPosition: {
x: 200,
y: 520,
w:1456/7,
h:1037/7
}
},{
imgUrl:"img/food2/s4.png",
imgPosition: {
x: 200,
y: 520,
w:1381/7,
h:832/7
}
},{
imgUrl:"img/food2/s5.png",
imgPosition: {
x: 200,
y: 520,
w:1268/7,
h:888/7
}
}],
[{
imgUrl:"img/food2/f1.png",
imgPosition: {
x: 200,
y: 520,
w: 1280/12,
h: 1280/12
}
},{
imgUrl:"img/food2/f2.png",
imgPosition: {
x: 200,
y: 520,
w:1443/9,
h:1018/9
}
},{
imgUrl:"img/food2/f3.png",
imgPosition: {
x: 200,
y: 520,
w:1443/9,
h:945/9
}
},{
imgUrl:"img/food2/f4.png",
imgPosition: {
x: 200,
y: 520,
w:1449/12,
h:1157/12
}
},{
imgUrl:"img/food2/f5.png",
imgPosition: {
x: 200,
y: 520,
w:1328/9,
h:1115/9
}
}],
[{
imgUrl:"img/food2/x1.png",
imgPosition: {
x: 200,
y: 520,
w: 1503/6,
h: 882/6
}
},{
imgUrl:"img/food2/x2.png",
imgPosition: {
x: 200,
y: 520,
w:1358/9,
h:1021/9
}
},{
imgUrl:"img/food2/x3.png",
imgPosition: {
x: 200,
y: 520,
w:1323/9,
h:1086/9
}
},{
imgUrl:"img/food2/x4.png",
imgPosition: {
x: 200,
y: 520,
w:1399/12,
h:1305/12
}
},{
imgUrl:"img/food2/x5.png",
imgPosition: {
x: 200,
y: 520,
w:684/9,
h:1246/9
}
}],
[{
imgUrl:"img/food2/y1.png",
imgPosition: {
x: 200,
y: 520,
w: 974/8,
h: 1472/8
}
},{
imgUrl:"img/food2/y2.png",
imgPosition: {
x: 200,
y: 520,
w:420/7,
h:1692/7
}
},{
imgUrl:"img/food2/y3.png",
imgPosition: {
x: 200,
y: 520,
w:422/7,
h:1691/7
}
},{
imgUrl:"img/food2/y4.png",
imgPosition: {
x: 200,
y: 520,
w:606/8,
h:1493/8
}
}],
[{
imgUrl:"img/food2/b1.png",
imgPosition: {
x: 200,
y: 520,
w: 1058/6,
h: 1330/6
}
},{
imgUrl:"img/food2/b2.png",
imgPosition: {
x: 200,
y: 520,
w: 1058/6,
h: 1330/6
}
},{
imgUrl:"img/food2/b3.png",
imgPosition: {
x: 200,
y: 520,
w:1096/7,
h:1655/7
}
},{
imgUrl:"img/food2/b4.png",
imgPosition: {
x: 200,
y: 520,
w:1093/7,
h:1655/7
}
},{
imgUrl:"img/food2/b5-1.png",
imgPosition: {
x: 200,
y: 520,
w:83,
h:337
}
},{
imgUrl:"img/food2/b5-2.png",
imgPosition: {
x: 200,
y: 520,
w:83,
h:337
}
},{
imgUrl:"img/food2/b6-1.png",
imgPosition: {
x: 200,
y: 520,
w:83,
h:383
}
},{
imgUrl:"img/food2/b6-2.png",
imgPosition: {
x: 200,
y: 520,
w:83,
h:383
}
},{
imgUrl:"img/food2/b7-1.png",
imgPosition: {
x: 200,
y: 520,
w:84,
h:485
}
},{
imgUrl:"img/food2/b7-2.png",
imgPosition: {
x: 200,
y: 520,
w:84,
h:485
}
},{
imgUrl:"img/food2/b8.png",
imgPosition: {
x: 200,
y: 520,
w:2391/5,
h:506/5
}
},{
imgUrl:"img/food2/b9.png",
imgPosition: {
x: 200,
y: 520,
w:1398/8,
h:1389/8
}
},{
imgUrl:"img/food2/b10.png",
imgPosition: {
x: 200,
y: 520,
w:523/8,
h:2074/8
}
},{
imgUrl:"img/food2/b11.png",
imgPosition: {
x: 200,
y: 520,
w:238/3,
h:1065/3
}
}],
[{
imgUrl:"img/food2/c1.png",
imgPosition: {
x: 200,
y: 520,
w: 1262/9,
h: 2805/9
}
},{
imgUrl:"img/food2/c22.png",
imgPosition: {
x: 200,
y: 520,
w:1735/8,
h:2060/8
}
},{
imgUrl:"img/food2/c3.png",
imgPosition: {
x: 200,
y: 520,
w:1408/8,
h:2051/8
}
},{
imgUrl:"img/food2/c4.png",
imgPosition: {
x: 200,
y: 520,
w:1275/6,
h:871/6
}
},{
imgUrl:"img/food2/b12.png",
imgPosition: {
x: 200,
y: 520,
w:1090/8,
h:1779/8
}
}],
];
// $('.scroll_bar li').bind("click", function() {
// if ($(this).index()==1) {
// $('.select_room li').eq(0).addClass('active');
// }
// });
$(".select_item ul li").bind("click", function() {
var i =indexSe;
var j = $(this).index();
if ($(".select_guide").hide(),
$(".select_item ul li").removeClass("active"),
$(this).addClass("active")) {
if (indexSe==0) {
Room.children[0]._texture.textureCacheIds[0]=roomSelect(indexSe,j);
Table.children[0]._texture.textureCacheIds[0]=tableSelect(j+1);
G.addChild(Person,Table,E);
return false
}
if ((i===7&&j===4)||(i===7&&j===5)||(i===7&&j===6)) {
if (j===4) {
setup(i,j);
setup(i,j+1);
}
if(j===5){
setup(i,j+1);
setup(i,j+2);
}
if(j===6){
setup(i,j+2);
setup(i,j+3);
}
return false
}
if (i===7) {
if (j>=7) {j=j+3}
}
setup(i,j);
}
});
var fontLst=[
'有钱有闲不熬夜,颜值爆表没烦恼',
'年纪轻轻吃得好,有猫有狗睡得香',
'新春福气聚满堂,万众齐欢接亥春',
'金猪打滚财源来,逆风翻盘神保佑',
'逢考必过不挂科,心想事成游全球',
'天天睡到自然醒,数钱数到手抽筋',
'涨工资要啥有啥,被表白狂吃不胖',
'丰稔岁中猪领赏,新台阶上步登高',
'人逢盛世情无限,猪拱华门岁有余',
'新春豪宴莫留恋,酒菜七成最康健',
'方案不想写了,爱谁谁!',
'一屋,二人,三餐,四季',
'猫有鱼,狗有肉,我有啤酒肚',
'我们也终于证实了1+1=3',
'啥也不说了,看下图'
];
var wishFont;
var haveWishFont;
$('.write').click(function(){
if (haveWishFont&&$('.wish').hasClass('on')) {
return false
}
haveWishFont=true;
var currentFont = fontLst[parseInt(Math.random() * fontLst.length)];
$('.wish').addClass('on');
$('.fontlist').text(currentFont);
})
$('.clesed').click(function(){
haveWishFont=false;
$('.wish').removeClass('on');
})
$('.btn1').click(function(){
wishFont = fontLst[parseInt(Math.random() * fontLst.length)];
$('.fontlist').text(wishFont);
})
$('.btn2').click(function(){
haveWishFont=true;
wishFont = $('.fontlist').text();
$('.wish').removeClass('on');
})
function t(msg) {
// console.log(wishFont,haveWishFont);
var ewm = new A(j.resources[T + "img/ewm1.png"].texture);
ewm.width=ewm.height =140;
ewm.x=S*(0.88+0.12/2)-ewm.width;
ewm.y=M-ewm.height-30;
var flower1 = new A(j.resources[T + "img/flower.png"].texture);
flower1.x =50;
flower1.y =60;
var flower2 = new A(j.resources[T + "img/flower.png"].texture);
flower2.x =S-flower1.width-50;
flower2.y =60;
var logo_b = new A(j.resources[T + "img/bottom_logo.png"].texture);
logo_b.x =45;
logo_b.y =M-logo_b.height-30;
var font = new PIXI.Text(msg, {
fontSize: "30px",
fill: "#fdd0b6"
});
font.x = (S-font.width)/2;
font.y = 65;
F.addChild(ewm,flower1,flower2,font,logo_b);
for (var i = 0; i < F.children.length; i++) {
F.children[i].visible=!0;
}
W.addChild(F);
}
$(".save").bind("click", function() {
// console.log(wishFont);
// console.log(!wishFont);
// console.log(!haveWishFont);
// console.log($('.wish').hasClass('on'))
$(".select").hide();
if ($(".wish").hasClass('on')&&!haveWishFont) {
$(".wish").removeClass('on');
wishFont = fontLst[parseInt(Math.random() * fontLst.length)];
t(wishFont);
}
if (!wishFont||!haveWishFont||$('.wish').hasClass('on')) {
wishFont='';
$(".wish").removeClass('on');
if (!haveWishFont&&!wishFont) {
wishFont = fontLst[parseInt(Math.random() * fontLst.length)];
}
if ($('.wish').hasClass('on')&&haveWishFont) {
console.log('444')
wishFont = fontLst[parseInt(Math.random() * fontLst.length)];
}
t(wishFont);
}
if (wishFont&&haveWishFont) {
t(wishFont);
}
onDragShow();
// TweenMax.to(G.scale,0.2,{x:0.933,y:0.933,ease:Elastic.line,onStart:function(){
// G.position.x=750*(1 -0.933)/2;
// G.position.y=750*(1 -0.933)/2;
// },onComplete:function(){
// console.log('动画完成');
// },delay:0})
G.mask = r;
new TWEEN.Tween(G.scale).to({
x: 0.88,
y: 0.88
}, 200).onUpdate(function() {
G.position.set((1 - this.x) / .12 * 45, (1 - this.x) / .12 * 45 + 100);
for (var i = 0; i < F.children.length; i++) {
F.children[i].visible=!0;
$('.return').show();
}
}).start();
setTimeout(function() {
setTimeout(function() {
var t = convertCanvasToImage($("canvas")[0]);
console.log($("canvas")[0])
$(".result_img").show();
if (!isEnd) {
// console.log('kkkkk')
$(".saved_img").append(t);
isEnd=true;
}
$(".saved_img").show();
setTimeout(function() {
if (isEnd) {
$(".a_saved_guide").fadeIn(300);
setTimeout(function() {
$(".a_saved_guide").fadeOut(1000);
}, 3000)
}
}, 500);
}, 30)
}, 200)
})
$('.return').bind("click", function() {
// console.log('返回了')
G.mask = r1;
F.removeChildren();
isEnd=false;
wishFont='';
t(wishFont);
$('.return').hide();
$('.saved_img').hide();
$('.saved_img img').remove()
$('.result_img').hide();
$('.select').show();
new TWEEN.Tween(G.scale).to({
x: 1,
y: 1
}, 200).onUpdate(function() {
G.position.set((1 - this.x) / .12 * 45, (1 - this.x) / .12 * 45 +0);
for (var i = 0; i < F.children.length; i++) {
F.children[i].visible=!1;
}
}).start();
})
function onDragShow(o) {
// console.log(lastTarget);
// console.log('000000')
$('.wish').removeClass('on');
haveWishFont=false;
if(lastTarget!=null){
// console.log('111')
for (var i = 0; i < lastTarget.children.length; i++) {
if (i > 0) {
lastTarget.children[i].visible = false;
}
}
}
// if (E.children.length) {
// for (var i = 0; i < E.children.length; i++) {
// for (var a = 0; a < E.children[i].children.length; a++) {
// for (var b = 0; b < E.children[i].children.length; b++) {
// if (b>0) {
// E.children[i].children[b].visible=!1;
// }
// }
// }
// }
// }
// if (Person.children.length) {
// for (var i = 0; i < Person.children.length; i++) {
// for (var a = 0; a < Person.children[i].children.length; a++) {
// for (var b = 0; b < Person.children[i].children.length; b++) {
// if (b>0) {
// Person.children[i].children[b].visible=!1;
// G.addChild(Table,E);
// }
// }
// }
// }
// }
// G.addChild(Table,E);
}
})();