帧动画修复bug

This commit is contained in:
草莓 2024-12-31 18:54:05 +08:00
parent d818ff36ff
commit 105a35c087
4 changed files with 100 additions and 68 deletions

View File

@ -2477,9 +2477,10 @@ return code;
*/; */;
animationDrawable_s animationDrawable_s
: '帧动画' '总显示帧数' IntString '底色' ColorString? Colour '底色透明度' Number BGNL?Newline : '帧动画' '总显示帧数' IntString '底色' ColorString? Colour '底色透明度' IntString? BGNL?Newline
'图片序列同一帧后面覆盖先前的默认起始帧为0结束帧为最后一帧)'BGNL?Newline '图片序列同一帧后面覆盖先前的默认起始帧为0结束帧为最后一帧)'BGNL?Newline
'(剪裁区域不填写为全图,绘制区域不填写为全画面)'BGNL?Newline '(剪裁区域不填写为全图,绘制区域不填写为全画面)'BGNL?Newline
'(透明度100为不透明默认为不透明结束透明度默认与开始透明度相同'BGNL?Newline
animationDrawableimage+? Newline animationDrawableimage+? Newline
'音频序列(到达对应帧进行播放)'BGNL?Newline '音频序列(到达对应帧进行播放)'BGNL?Newline
animationDrawablesound+? Newline animationDrawablesound+? Newline
@ -2488,16 +2489,16 @@ animationDrawable_s
/* animationDrawable_s /* animationDrawable_s
tooltip : animationDrawable帧动画图片叠加 tooltip : animationDrawable帧动画图片叠加
helpUrl : /_docs/#/instruction helpUrl : /_docs/#/instruction
default : [30,"",'rgb(0, 0, 0)',1] default : [30,"0, 0, 0",'rgb(0, 0, 0)',""]
allImages : ['EvalString_0'] allImages : ['EvalString_0']
colour : this.imageColor colour : this.imageColor
if (Number_0 < 0||Number_0>1) throw new Error('透明度范围为0-1不填默认为1,0为透明1为不透明') if (IntString_1&&(IntString_1 < 0||IntString_1>100)) throw new Error('透明度范围为0-100,0为透明100为不透明,不填默认为不透明')
ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : ''; ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : '';
Number_0 = Number_0 ? (', "globalAlpha": '+Number_0+'') : ''; IntString_1 = IntString_1 ? (', "globalAlpha": '+IntString_1+'') : '';
var imageList=animationDrawableimage_0?',"imageList": [\n'+animationDrawableimage_0.slice(0,-1)+'\n]':'' var imageList=animationDrawableimage_0?',"imageList": [\n'+animationDrawableimage_0.slice(0,-1)+'\n]':''
var soundList=animationDrawablesound_0?',"soundList": [\n'+animationDrawablesound_0.slice(0,-1)+'\n]':'' var soundList=animationDrawablesound_0?',"soundList": [\n'+animationDrawablesound_0.slice(0,-1)+'\n]':''
var code = '{"type": "animationDrawable", "allFarme": '+IntString_0+ColorString_0+Number_0+imageList+soundList+'},\n'; var code = '{"type": "animationDrawable", "allFarme": '+IntString_0+ColorString_0+IntString_1+imageList+soundList+'},\n';
return code; return code;
*/; */;
@ -2507,37 +2508,40 @@ animationDrawableList
| animationDrawabletextEmpty; | animationDrawabletextEmpty;
animationDrawableimage animationDrawableimage
: '图片' EvalString? '起始帧' IntString? '起始透明度' Number BGNL? Newline : '图片' EvalString? '起始帧' IntString? '起始透明度' IntString? BGNL? Newline
'剪裁坐标cx' IntString? 'cy' IntString? '宽' IntString? '高' IntString? '绘制坐标x'IntString? 'y' IntString? '宽' IntString? '高' IntString? BGNL? Newline '剪裁坐标cx' IntString? 'cy' IntString? '宽' IntString? '高' IntString? '绘制坐标x'IntString? 'y' IntString? '宽' IntString? '高' IntString? BGNL? Newline
'结束帧' IntString? '结束透明度' Number '剪裁坐标cx' IntString? 'cy' IntString? '宽' IntString? '高' IntString? '绘制坐标x'IntString? 'y' IntString? '宽' IntString? '高' IntString? Newline '结束帧' IntString? '结束透明度' IntString? '剪裁坐标cx' IntString? 'cy' IntString? '宽' IntString? '高' IntString? '绘制坐标x'IntString? 'y' IntString? '宽' IntString? '高' IntString? Newline
/* animationDrawableimage /* animationDrawableimage
tooltip : 帧动画图片列表 tooltip : 帧动画图片列表
helpUrl : /_docs/#/instruction helpUrl : /_docs/#/instruction
default : ["","",1,"","","","","","","","","",1,"","","","","","","",""] default : ["","","","","","","","","","","","","","","","","","","","",""]
colour : this.subColor colour : this.subColor
allImages : ['EvalString_0'] allImages : ['EvalString_0']
if ((Number_0 < 0||Number_0>1)&&!Number_0||(Number_1 < 0||Number_1>1)&&!Number_1) throw new Error('透明度范围为0-1不填默认为1') if (IntString_1&&(IntString_1 < 0||IntString_1>100)) throw new Error('透明度范围为0-100,0为透明,100为不透明,不填默认为不透明')
if (IntString_11&&(IntString_11 < 0||IntString_11>100)) throw new Error('透明度范围为0-100,0为透明,100为不透明,不填默认为不透明')
IntString_0 = IntString_0 ? (', "beforefarme": '+IntString_0+'') : ''; IntString_0 = IntString_0 ? (', "beforefarme": '+IntString_0+'') : '';
IntString_1 = IntString_1 ? (', "cx": '+IntString_1+'') : ''; IntString_1 = IntString_1 ? (', "globalAlpha": '+IntString_1+'') : '';
IntString_2 = IntString_2 ? (', "cy": '+IntString_2+'') : ''; IntString_2 = IntString_2 ? (', "cx": '+IntString_2+'') : '';
IntString_3 = IntString_3 ? (', "cw": '+IntString_3+'') : ''; IntString_3 = IntString_3 ? (', "cy": '+IntString_3+'') : '';
IntString_4 = IntString_4 ? (', "ch": '+IntString_4+'') : ''; IntString_4 = IntString_4 ? (', "cw": '+IntString_4+'') : '';
IntString_5 = IntString_5 ? (', "x": '+IntString_5+'') : ''; IntString_5 = IntString_5 ? (', "ch": '+IntString_5+'') : '';
IntString_6 = IntString_6 ? (', "y": '+IntString_6+'') : ''; IntString_6 = IntString_6 ? (', "x": '+IntString_6+'') : '';
IntString_7 = IntString_7 ? (', "w": '+IntString_7+'') : ''; IntString_7 = IntString_7 ? (', "y": '+IntString_7+'') : '';
IntString_8 = IntString_8 ? (', "h": '+IntString_8+'') : ''; IntString_8 = IntString_8 ? (', "w": '+IntString_8+'') : '';
Number_0 = Number_0 ? (', "globalAlpha": '+Number_0+'') : ''; IntString_9 = IntString_9 ? (', "h": '+IntString_9+'') : '';
IntString_9 = IntString_9 ? (', "afterfarme": '+IntString_9+'') : '';
IntString_10 = IntString_10 ? (', "acx": '+IntString_10+'') : ''; IntString_10 = IntString_10 ? (', "afterfarme": '+IntString_10+'') : '';
IntString_11 = IntString_11 ? (', "acy": '+IntString_11+'') : ''; IntString_11 = IntString_11 ? (', "aglobalAlpha": '+IntString_11+'') : '';
IntString_12 = IntString_12 ? (', "acw": '+IntString_12+'') : ''; IntString_12 = IntString_12 ? (', "acx": '+IntString_12+'') : '';
IntString_13 = IntString_13 ? (', "ach": '+IntString_13+'') : ''; IntString_13 = IntString_13 ? (', "acy": '+IntString_13+'') : '';
IntString_14 = IntString_14 ? (', "ax": '+IntString_14+'') : ''; IntString_14 = IntString_14 ? (', "acw": '+IntString_14+'') : '';
IntString_15 = IntString_15 ? (', "ay": '+IntString_15+'') : ''; IntString_15 = IntString_15 ? (', "ach": '+IntString_15+'') : '';
IntString_16 = IntString_16 ? (', "aw": '+IntString_16+'') : ''; IntString_16 = IntString_16 ? (', "ax": '+IntString_16+'') : '';
IntString_17 = IntString_17 ? (', "ah": '+IntString_17+'') : ''; IntString_17 = IntString_17 ? (', "ay": '+IntString_17+'') : '';
Number_1 = Number_1 ? (', "aglobalAlpha": '+Number_1+'') : ''; IntString_18 = IntString_18 ? (', "aw": '+IntString_18+'') : '';
return '{ "image":"'+EvalString_0+'"'+IntString_0+IntString_1+IntString_2+IntString_3+IntString_4+IntString_5+IntString_6+IntString_7+IntString_8+Number_0+IntString_9+IntString_10+IntString_11+IntString_12+IntString_13+IntString_14+IntString_15+IntString_16+IntString_17+Number_1+'},' IntString_19 = IntString_19 ? (', "ah": '+IntString_19+'') : '';
return '{ "image":"'+EvalString_0+'"'+IntString_0+IntString_1+IntString_2+IntString_3+IntString_4+IntString_5+IntString_6+IntString_7+IntString_8+IntString_9+IntString_10+IntString_11+IntString_12+IntString_13+IntString_14+IntString_15+IntString_16+IntString_17+IntString_18+IntString_19+'},'
*/; */;
animationDrawablesound animationDrawablesound

View File

@ -1 +1 @@
{"viewportLoc":[0,0],"editorLastFloorId":"street02"} {"viewportLoc":[0,0],"editorLastFloorId":"street01"}

View File

@ -41,14 +41,37 @@ main.floors.street01=
"4,11": [ "4,11": [
{ {
"type": "animationDrawable", "type": "animationDrawable",
"allFarme": 30, "allFarme": 300,
"globalAlpha": 1, "color": [
0,
0,
0
],
"imageList": [ "imageList": [
{ {
"image": "", "image": "bg_1511.png",
"h": 1, "beforefarme": 50,
"globalAlpha": 1, "globalAlpha": 0,
"aglobalAlpha": 1 "afterfarme": 250,
"aglobalAlpha": 100
},
{
"image": "eve_010304.png",
"beforefarme": 70,
"globalAlpha": 0,
"afterfarme": 170,
"aglobalAlpha": 100,
"ax": 0,
"ay": 0
},
{
"image": "eve_010304.png",
"beforefarme": 171,
"globalAlpha": 100,
"afterfarme": 270,
"aglobalAlpha": 100,
"ax": 800,
"ay": 0
} }
], ],
"soundList": [ "soundList": [

View File

@ -2609,6 +2609,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
main.dom.video1.style.width = obj.totalWidth + 3 + "px"; main.dom.video1.style.width = obj.totalWidth + 3 + "px";
main.dom.video1.style.height = obj.totalHeight + 3 + "px"; main.dom.video1.style.height = obj.totalHeight + 3 + "px";
} }
const innerSize = obj.canvasWidth * core.domStyle.scale + "px"; const innerSize = obj.canvasWidth * core.domStyle.scale + "px";
for (let i = 0; i < core.dom.gameCanvas.length; ++i) for (let i = 0; i < core.dom.gameCanvas.length; ++i)
core.dom.gameCanvas[i].style.width = core.dom.gameCanvas[ core.dom.gameCanvas[i].style.width = core.dom.gameCanvas[
@ -2655,8 +2657,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
const uictx = main.dom.outerUI.getContext("2d"); const uictx = main.dom.outerUI.getContext("2d");
core.registerAnimationFrame("lightFloor", true, function () { core.registerAnimationFrame("lightFloor", true, function () {
globalAlphafloor += globalAlphafloorStatus; globalAlphafloor += globalAlphafloorStatus;
if (globalAlphafloor === 100) globalAlphafloorStatus = -4; if (globalAlphafloor === 100) globalAlphafloorStatus = -2;
if (globalAlphafloor === 0) globalAlphafloorStatus = 4; if (globalAlphafloor === 0) globalAlphafloorStatus = 2;
if (core.domStyle.isVertical) { if (core.domStyle.isVertical) {
core.clearMap( core.clearMap(
@ -2676,7 +2678,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.drawImage( core.drawImage(
uictx, uictx,
"green.png", "green.png",
MAP_BLOCK_LEFT_VERTICAL + 125, MAP_BLOCK_LEFT_VERTICAL + 135,
MAP_BLOCK_TOP_VERTICAL + 170 MAP_BLOCK_TOP_VERTICAL + 170
); );
uictx.globalAlpha = 1; uictx.globalAlpha = 1;
@ -2692,7 +2694,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
uictx, uictx,
"green.png", "green.png",
MAP_BLOCK_LEFT + 150, MAP_BLOCK_LEFT + 150,
MAP_BLOCK_TOP + 170 MAP_BLOCK_TOP + 180
); );
uictx.globalAlpha = 1; uictx.globalAlpha = 1;
} }
@ -14200,54 +14202,58 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}, },
"帧动画/图片叠拼": function () { "帧动画/图片叠拼": function () {
// 在此增加新插件 // 在此增加新插件
this.animationDrawable = function ( this.animationDrawable = function (
allFarme = 0, allFarme,
color = "#000000", color,
globalAlpha = 1, globalAlpha,
imageList = [{ image: '', beforefarme: 0, cx: 0, cy: 0, cw: 0, ch: 0, x: 0, y: 0, w: 0, h: 0, globalAlpha: 1, afterfarme: 0, acx: 0, acy: 0, acw: 0, ach: 0, ax: 0, ay: 0, aw: 0, ah: 0, aglobalAlpha: 1 }], imageList,
soundList = [{ sound: "", startfarme: 0, stopbefore: false }] soundList
) { ) {
if (!core.isPlaying()) { if (!core.isPlaying()) {
return core.doAction(); return core.doAction();
} }
const canvas = main.dom.over const over = main.dom.over
const ctx = canvas.getContext('2d') const ctx = over.getContext('2d')
canvas.style.display = 'block' over.style.display = "block"
let farme = 0 let farme = 0
core.registerAnimationFrame('animationDrawable', function () { core.registerAnimationFrame('animationDrawable', true, function () {
if (core.domStyle.isVertical) { if (core.domStyle.isVertical) {
canvas.width = 416 * 3; ctx.canvas.width = 416 * 3;
canvas.height = 676 * 3; ctx.canvas.height = 676 * 3;
ctx.save(); //保存设置 ctx.save(); //保存设置
ctx.translate(416 * 3, 0); //重新定位右上角为基准 ctx.translate(416 * 3, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度 ctx.rotate(Math.PI / 2); //旋转90度
} else { } else {
canvas.width = 676 * 3; ctx.canvas.width = 676 * 3;
canvas.height = 416 * 3; ctx.canvas.height = 416 * 3;
} }
ctx.globalAlpha = globalAlpha
core.fillRect(ctx, 0, 0, canvas.width, canvas.height, color) ctx.globalAlpha = (globalAlpha ?? 100) / 100
core.fillRect(ctx, 0, 0, over.width, over.height, color)
imageList.forEach(function (one) { imageList.forEach(function (one) {
if (farme >= (one.beforefarme ?? 0) && farme <= (one.afterfarme ?? allFarme)) { if (farme >= (one.beforefarme ?? 0) && farme <= (one.afterfarme ?? allFarme)) {
const img = core.material.images.images?.[one.image]; const img = core.material.images.images?.[one.image];
if (img) { if (img) {
const gla = one.globalAlpha ?? 1; const gla = one.globalAlpha ?? 100;
const agla = one.aglobalAlpha ?? gla, const agla = one.aglobalAlpha ?? gla,
beforefarme = one.beforefarme ?? 0; beforefarme = one.beforefarme ?? 0;
const afterfarme = one.afterfarme ?? allFarme; const afterfarme = one.afterfarme ?? allFarme;
ctx.globalAlpha = gla + (agla - gla) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1) ctx.globalAlpha = (gla + (agla - gla) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1)) / 100
const cx = one.cx ?? 0 + (one.acx ?? 0 - one.cx ?? 0) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1),
cy = one.cy ?? 0 + (one.acy ?? 0 - one.cy ?? 0) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1),
cw = one.cw ?? img.width + (one.acw ?? img.width - one.cw ?? img.width) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1),
ch = one.ch ?? img.height + (one.acw ?? img.height - one.cw ?? img.height) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1),
x = one.x ?? 0 + (one.ax ?? 0 - one.x ?? 0) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1),
y = one.y ?? 0 + (one.ay ?? 0 - one.y ?? 0) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1),
w = one.w ?? canvas.width + (one.aw ?? canvas.width - one.w ?? canvas.width) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1),
h = one.h ?? canvas.height + (one.aw ?? canvas.height - one.w ?? canvas.height) * (farme - one.beforefarme ?? 0) / ((one.afterfarme ?? 0 - one.beforefarme ?? 0) || 1)
const cx = (one.cx ?? 0) + ((one.acx ?? 0) - (one.cx ?? 0)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1),
cy = (one.cy ?? 0) + ((one.acy ?? 0) - (one.cy ?? 0)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1),
cw = (one.cw ?? img.width) + ((one.acw ?? img.width) - (one.cw ?? img.width)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1),
ch = (one.ch ?? img.height) + ((one.acw ?? img.height) - (one.cw ?? img.height)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1),
x = (one.x ?? 0) + ((one.ax ?? 0) - (one.x ?? 0)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1),
y = (one.y ?? 0) + ((one.ay ?? 0) - (one.y ?? 0)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1),
w = (one.w ?? over.width) + ((one.aw ?? over.width) - (one.w ?? over.width)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1),
h = (one.h ?? over.height) + ((one.aw ?? over.height) - (one.w ?? over.height)) * (farme - beforefarme) / ((afterfarme - beforefarme) || 1)
ctx.drawImage(img, cx, cy, cw, ch, x, y, w, h) ctx.drawImage(img, cx, cy, cw, ch, x, y, w, h)
} }
} }
@ -14255,7 +14261,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}) })
soundList.forEach(function (one) { soundList.forEach(function (one) {
const lisen = one.sound && core.material.sounds[one.sound] && core.musicStatus.soundStatus; const lisen = one.sound && core.material.sounds[one.sound] && core.musicStatus.soundStatus;
if (frame == one.startfarme && lisen) { if (farme == one.startfarme && lisen) {
if (one.stopbefore) core.stopSound() if (one.stopbefore) core.stopSound()
core.playSound(sound); core.playSound(sound);
} }
@ -14264,10 +14270,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
ctx.globalAlpha = 1 ctx.globalAlpha = 1
ctx.restore(); ctx.restore();
core.clearMap(ctx)
if (farme > allFarme) { if (farme > allFarme) {
core.unregisterAnimationFrame('animationDrawable') core.unregisterAnimationFrame('animationDrawable')
canvas.style.display = 'none' over.style.display = 'none'
core.doAction() core.doAction()
} }
}) })