cg改了一些东西
This commit is contained in:
parent
93fade2337
commit
e59bdda35a
@ -8663,7 +8663,8 @@ core.plugin.animate = {
|
||||
CGUI.style.transform = "translate(-50%,-50%)"
|
||||
const ctx = CGUI.getContext("2d");
|
||||
main.dom.CGUI = CGUI;
|
||||
if (core.getLocalStorage("page", null) == null) core.setLocalStorage("page", 0);
|
||||
let page = 0; //初始页面
|
||||
let show = false; //展示状态
|
||||
CGUI.onclick = function (e) {
|
||||
try {
|
||||
e.preventDefault();
|
||||
@ -8776,7 +8777,7 @@ core.plugin.animate = {
|
||||
["none", "none", 'none'],
|
||||
["none", "none", "none"]
|
||||
]
|
||||
];
|
||||
]
|
||||
}
|
||||
|
||||
//更新
|
||||
@ -8800,37 +8801,76 @@ core.plugin.animate = {
|
||||
|
||||
}
|
||||
onclick(px, py) { //点击
|
||||
if (show) {
|
||||
show = !show
|
||||
core.clearMap(ctx);
|
||||
this.drawUI();
|
||||
return
|
||||
}
|
||||
console.log([px, py]);
|
||||
|
||||
if (px >= 33 && px <= 177 && py >= 33 && py <= 177) { //离开按钮是一致的,其余的记区分横竖屏
|
||||
const makeBox = ([x, y], [w, h]) => {
|
||||
return [
|
||||
[x, y],
|
||||
[x + w, y + h]
|
||||
];
|
||||
}
|
||||
const inRect = ([x, y], [
|
||||
[sx, sy],
|
||||
[dx, dy]
|
||||
]) => {
|
||||
return sx <= x && x <= dx && sy <= y && y <= dy;
|
||||
};
|
||||
const pos = [px, py];
|
||||
const backbox = makeBox([33, 33], [144, 144])
|
||||
if (inRect(pos, backbox)) { //离开按钮是一致的,其余的记区分横竖屏
|
||||
CGUI.style.display = "none"
|
||||
core.clearMap(ctx)
|
||||
core.restart();
|
||||
return
|
||||
}
|
||||
if (core.domStyle.isVertical) {
|
||||
//竖屏
|
||||
if (px >= 33 && px <= 177 && py >= 384 && py <= 520) {
|
||||
const pageupbox = makeBox([33, 384], [144, 136])
|
||||
const pagedownbox = makeBox([33, 1080], [144, 190])
|
||||
const imagebox0 = makeBox([200, 300], [480, 320])
|
||||
if (inRect(pos, pageupbox)) {
|
||||
//2代表当前最大页数-1
|
||||
core.setLocalStorage("page", Math.min(2, core.getLocalStorage("page", 0) + 1));
|
||||
console.log(core.getLocalStorage("page"));
|
||||
} else if (px >= 33 && px <= 177 && py >= 1080 && py <= 1270) {
|
||||
core.setLocalStorage("page", Math.max(0, core.getLocalStorage("page", 2) - 1));
|
||||
console.log(core.getLocalStorage("page"));
|
||||
}
|
||||
} else {
|
||||
if (px >= 33 && px <= 177 && py >= 342 && py <= 471) {
|
||||
//2代表当前最大页数-1
|
||||
core.setLocalStorage("page", Math.min(2, core.getLocalStorage("page", 0) + 1));
|
||||
console.log(core.getLocalStorage("page"));
|
||||
} else if (px >= 33 && px <= 177 && py >= 837 && py <= 975) {
|
||||
core.setLocalStorage("page", Math.max(0, core.getLocalStorage("page", 2) - 1));
|
||||
console.log(core.getLocalStorage("page"));
|
||||
}
|
||||
for (let i = 0; i < 2; i++) {
|
||||
for (let j = 0; j < 3; j++) {
|
||||
//这里是绘图脚本,然而我并不会写,交给草莓了
|
||||
//drawImage(ctx, this.UIMx[core.getLocalStorage("page")][i * 3 - 3 + j], 480, 320, 300 + j * 500, 300 + i * 450);
|
||||
if (page < 2) {
|
||||
page++;
|
||||
core.clearMap(ctx);
|
||||
this.drawUI();
|
||||
}
|
||||
} else if (inRect(pos, pagedownbox)) {
|
||||
if (page > 0) {
|
||||
page--;
|
||||
core.clearMap(ctx);
|
||||
this.drawUI();
|
||||
}
|
||||
} else if (inRect(pos, imagebox0)) {
|
||||
const img = core.material.images.images[this.UIMx[page][0][0]]
|
||||
ctx.save(); //保存设置
|
||||
ctx.translate(1248, 0) //重新定位右上角为基准
|
||||
ctx.rotate(Math.PI / 2) //旋转90度
|
||||
ctx.drawImage(img, 0, 0, 2028, 1248)
|
||||
ctx.restore(); //重置画布设置
|
||||
show = !show;
|
||||
} else {
|
||||
const pageupbox = makeBox([33, 342], [144, 129])
|
||||
const pagedownbox = makeBox([33, 837], [144, 138])
|
||||
if (inRect(pos, pageupbox)) {
|
||||
if (page < 2) {
|
||||
page++;
|
||||
core.clearMap(ctx);
|
||||
this.drawUI();
|
||||
}
|
||||
} else if (inRect(pos, pagedownbox)) {
|
||||
if (page > 0) {
|
||||
page++;
|
||||
core.clearMap(ctx);
|
||||
this.drawUI();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8856,11 +8896,12 @@ core.plugin.animate = {
|
||||
core.fillText(ctx, '向上翻页', 100, 450, '#FFFFFF', core.ui._buildFont(24, true));
|
||||
core.fillText(ctx, '向下翻页', 100, 1150, '#FFFFFF', core.ui._buildFont(24, true));
|
||||
|
||||
// 添加3*2个4:3的画框
|
||||
// 添加3*2个4:3的画框,及图片
|
||||
for (let i = 0; i < 3; i++) {
|
||||
for (let j = 0; j < 2; j++) {
|
||||
core.fillRect(ctx, 200 + j * 500, 300 + i * 450, 480, 320, '#FFFFFF');
|
||||
core.strokeRect(ctx, 200 + j * 500, 300 + i * 450, 480, 320, "#444444", 2);
|
||||
const img = core.material.images.images[this.UIMx[page][j][i]]
|
||||
core.strokeRect(ctx, 200 + j * 500, 300 + i * 450, 480, 320, "#444444", 5);
|
||||
if (img) ctx.drawImage(img, 200 + j * 500 + 15, 300 + i * 450 + 15, 480 - 30, 320 - 30)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user