setOpacity -> setAlpha

This commit is contained in:
oc 2018-12-04 03:02:02 +08:00
parent 6b371c305f
commit 5b34fbe47e
4 changed files with 35 additions and 46 deletions

View File

@ -1002,7 +1002,6 @@ actions.prototype.clickViewMaps = function (x,y) {
} }
else if (x>=2 && x<=10 && y>=5 && y<=7) { else if (x>=2 && x<=10 && y>=5 && y<=7) {
core.clearMap('data'); core.clearMap('data');
core.setOpacity('data', 1);
core.ui.closePanel(); core.ui.closePanel();
} }
} }
@ -1031,7 +1030,6 @@ actions.prototype.keyUpViewMaps = function (keycode) {
if (keycode==27 || keycode==13 || keycode==32 || (!core.status.replay.replaying && keycode==67)) { if (keycode==27 || keycode==13 || keycode==32 || (!core.status.replay.replaying && keycode==67)) {
core.clearMap('data'); core.clearMap('data');
core.setOpacity('data', 1);
core.ui.closePanel(); core.ui.closePanel();
return; return;
} }

View File

@ -1531,33 +1531,37 @@ events.prototype.animateImage = function (type, image, loc, time, keep, callback
} }
clearInterval(core.interval.tipAnimate); clearInterval(core.interval.tipAnimate);
core.setAlpha('data', 1);
var opacityVal = 0; var alpha = 0;
if (type == 'hide') opacityVal = 1; if (type == 'hide') alpha = 1;
var x = core.calValue(loc[0]), y = core.calValue(loc[1]);
if (type == 'hide' && keep) { if (type == 'hide' && keep) {
core.clearMap('image'); core.clearMap('image', x, y, image.width, image.height);
} }
core.setAlpha('data', alpha);
core.setOpacity('data', opacityVal);
var x = core.calValue(loc[0]), y = core.calValue(loc[1]);
core.canvas.data.drawImage(image, x, y); core.canvas.data.drawImage(image, x, y);
core.setAlpha('data', 1);
// core.status.replay.animate=true; // core.status.replay.animate=true;
var animate = setInterval(function () { var animate = setInterval(function () {
if (type=='show') opacityVal += 0.1; if (type=='show') alpha += 0.1;
else opacityVal -= 0.1; else alpha -= 0.1;
core.setOpacity('data', opacityVal); core.clearMap('data', x, y, image.width, image.height);
if (opacityVal >=1 || opacityVal<=0) { if (alpha >=1 || alpha<=0) {
delete core.animateFrame.asyncId[animate]; delete core.animateFrame.asyncId[animate];
clearInterval(animate); clearInterval(animate);
if (type == 'show' && keep) if (type == 'show' && keep)
core.canvas.image.drawImage(image, x, y); core.canvas.image.drawImage(image, x, y);
core.clearMap('data'); core.setAlpha('data', 1);
core.setOpacity('data', 1);
// core.status.replay.animate=false;
if (core.isset(callback)) callback(); if (core.isset(callback)) callback();
} }
else {
core.setAlpha('data', alpha);
core.canvas.data.drawImage(image, x, y);
core.setAlpha('data', 1);
}
}, time / 10); }, time / 10);
core.animateFrame.asyncId[animate] = true; core.animateFrame.asyncId[animate] = true;
@ -1568,7 +1572,6 @@ events.prototype.moveImage = function (image, from, to, time, keep, callback) {
time = time || 1000; time = time || 1000;
clearInterval(core.interval.tipAnimate); clearInterval(core.interval.tipAnimate);
core.setAlpha('data', 1); core.setAlpha('data', 1);
core.setOpacity('data', 1);
var width = image.width, height = image.height; var width = image.width, height = image.height;

View File

@ -870,7 +870,7 @@ maps.prototype.moveBlock = function(x,y,steps,time,keep,callback) {
core.setBlock(id, nowX/32, nowY/32); core.setBlock(id, nowX/32, nowY/32);
core.showBlock(nowX/32, nowY/32); core.showBlock(nowX/32, nowY/32);
} }
// core.status.replay.animate=false; core.setAlpha('route',1);
if (core.isset(callback)) callback(); if (core.isset(callback)) callback();
} }
else { else {
@ -1009,7 +1009,7 @@ maps.prototype.jumpBlock = function(sx,sy,ex,ey,time,keep,callback) {
delete core.animateFrame.asyncId[animate]; delete core.animateFrame.asyncId[animate];
clearInterval(animate); clearInterval(animate);
core.clearMap('route'); core.clearMap('route');
core.setOpacity('route', 1); core.setAlpha('route', 1);
if (keep) { if (keep) {
core.setBlock(id, ex, ey); core.setBlock(id, ex, ey);
core.showBlock(ex, ey); core.showBlock(ex, ey);
@ -1351,6 +1351,7 @@ maps.prototype.drawAnimateFrame = function (animate, centerX, centerY, index) {
core.canvas.animate.drawImage(image, -realWidth/2 - core.bigmap.offsetX, -realHeight/2 - core.bigmap.offsetY, realWidth, realHeight); core.canvas.animate.drawImage(image, -realWidth/2 - core.bigmap.offsetX, -realHeight/2 - core.bigmap.offsetY, realWidth, realHeight);
core.loadCanvas('animate'); core.loadCanvas('animate');
} }
core.setAlpha('animate', 1);
}) })
} }

View File

@ -144,7 +144,7 @@ ui.prototype.setAlpha = function (map, alpha) {
else core.canvas[map].globalAlpha = alpha; else core.canvas[map].globalAlpha = alpha;
} }
////// 设置某个canvas的透明度 ////// ////// 设置某个canvas的透明度尽量不要使用本函数而是全部换成setAlpha实现 //////
ui.prototype.setOpacity = function (map, opacity) { ui.prototype.setOpacity = function (map, opacity) {
if (map == 'all') { if (map == 'all') {
for (var m in core.canvas) { for (var m in core.canvas) {
@ -186,10 +186,9 @@ ui.prototype.closePanel = function () {
////// 左上角绘制一段提示 ////// ////// 左上角绘制一段提示 //////
ui.prototype.drawTip = function (text, itemIcon) { ui.prototype.drawTip = function (text, itemIcon) {
var textX, textY, width, height, hide = false, opacityVal = 0; var textX, textY, width, height, hide = false, alpha = 0;
clearInterval(core.interval.tipAnimate); clearInterval(core.interval.tipAnimate);
core.setFont('data', "16px Arial"); core.setFont('data', "16px Arial");
core.setOpacity('data', 0);
core.canvas.data.textAlign = 'left'; core.canvas.data.textAlign = 'left';
if (!core.isset(itemIcon)) { if (!core.isset(itemIcon)) {
textX = 16; textX = 16;
@ -205,22 +204,22 @@ ui.prototype.drawTip = function (text, itemIcon) {
} }
core.interval.tipAnimate = window.setInterval(function () { core.interval.tipAnimate = window.setInterval(function () {
if (hide) { if (hide) {
opacityVal -= 0.1; alpha -= 0.1;
} }
else { else {
opacityVal += 0.1; alpha += 0.1;
} }
core.setOpacity('data', opacityVal); core.clearMap('data', 5, 5, 416, height);
core.clearMap('data', 5, 5, 400, height); core.setAlpha('data', alpha);
core.fillRect('data', 5, 5, width, height, '#000'); core.fillRect('data', 5, 5, width, height, '#000');
if (core.isset(itemIcon)) { if (core.isset(itemIcon)) {
core.canvas.data.drawImage(core.material.images.items, 0, itemIcon * 32, 32, 32, 10, 8, 32, 32); core.canvas.data.drawImage(core.material.images.items, 0, itemIcon * 32, 32, 32, 10, 8, 32, 32);
} }
core.fillText('data', text, textX + 5, textY + 15, '#fff'); core.fillText('data', text, textX + 5, textY + 15, '#fff');
if (opacityVal > 0.6 || opacityVal < 0) { core.setAlpha('data', 1);
if (alpha > 0.6 || alpha < 0) {
if (hide) { if (hide) {
core.clearMap('data', 5, 5, 400, height); core.clearMap('data', 5, 5, 416, height);
core.setOpacity('data', 1);
clearInterval(core.interval.tipAnimate); clearInterval(core.interval.tipAnimate);
return; return;
} }
@ -231,8 +230,7 @@ ui.prototype.drawTip = function (text, itemIcon) {
core.timeout.getItemTipTimeout = null; core.timeout.getItemTipTimeout = null;
}, 750); }, 750);
} }
opacityVal = 0.6; alpha = 0.6;
core.setOpacity('data', opacityVal);
} }
} }
}, 30); }, 30);
@ -1032,16 +1030,13 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
var top = (416-height)/2, bottom = height; var top = (416-height)/2, bottom = height;
// var left = 97, top = 64, right = 416 - 2 * left, bottom = 416 - 2 * top; core.fillRect('ui', left, top, right, bottom, 'rgba(0,0,0,0.85)');
core.setAlpha('ui', 0.85);
core.fillRect('ui', left, top, right, bottom, '#000000');
core.setAlpha('ui', 1); core.setAlpha('ui', 1);
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2); core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
core.clearMap('data'); core.clearMap('data');
clearInterval(core.interval.tipAnimate); clearInterval(core.interval.tipAnimate);
core.setAlpha('data', 1); core.setAlpha('data', 1);
core.setOpacity('data', 1);
core.status.boxAnimateObjs = []; core.status.boxAnimateObjs = [];
var globalFont = core.status.globalAttribute.font; var globalFont = core.status.globalAttribute.font;
@ -1388,7 +1383,6 @@ ui.prototype.drawBook = function (index) {
clearInterval(core.interval.tipAnimate); clearInterval(core.interval.tipAnimate);
core.clearMap('data'); core.clearMap('data');
core.setOpacity('data', 1);
core.clearMap('ui'); core.clearMap('ui');
core.setAlpha('ui', 1); core.setAlpha('ui', 1);
@ -1624,7 +1618,6 @@ ui.prototype.drawBookDetail = function (index) {
clearInterval(core.interval.tipAnimate); clearInterval(core.interval.tipAnimate);
core.clearMap('data'); core.clearMap('data');
core.setOpacity('data', 1);
var left=10, right=416-2*left; var left=10, right=416-2*left;
var content_left = left + 25; var content_left = left + 25;
@ -1710,8 +1703,7 @@ ui.prototype.drawMaps = function (index, x, y) {
core.setAlpha('ui', 1); core.setAlpha('ui', 1);
core.clearMap('animate'); core.clearMap('animate');
core.setOpacity('animate', 0.4); core.fillRect('animate', 0, 0, 416, 416, 'rgba(0,0,0,0.4)');
core.fillRect('animate', 0, 0, 416, 416, '#000000');
core.strokeRect('ui', 66, 2, 284, 60, "#FFD700", 4); core.strokeRect('ui', 66, 2, 284, 60, "#FFD700", 4);
core.strokeRect('ui', 2, 66, 60, 284); core.strokeRect('ui', 2, 66, 60, 284);
@ -1752,7 +1744,6 @@ ui.prototype.drawMaps = function (index, x, y) {
} }
core.clearMap('animate'); core.clearMap('animate');
core.setOpacity('animate', 1);
var damage = (core.status.event.data||{}).damage, paint = (core.status.event.data||{}).paint; var damage = (core.status.event.data||{}).damage, paint = (core.status.event.data||{}).paint;
var all = (core.status.event.data||{}).all; var all = (core.status.event.data||{}).all;
@ -1793,17 +1784,14 @@ ui.prototype.drawMaps = function (index, x, y) {
} }
core.clearMap('data'); core.clearMap('data');
core.setOpacity('data', 0.2);
core.canvas.data.textAlign = 'left'; core.canvas.data.textAlign = 'left';
core.setFont('data', '16px Arial'); core.setFont('data', '16px Arial');
var text = core.status.maps[floorId].title; var text = core.status.maps[floorId].title;
if (!all && (mw>13 || mh>13)) text+=" ["+(x-6)+","+(y-6)+"]"; if (!all && (mw>13 || mh>13)) text+=" ["+(x-6)+","+(y-6)+"]";
var textX = 16, textY = 18, width = textX + core.canvas.data.measureText(text).width + 16, height = 42; var textX = 16, textY = 18, width = textX + core.canvas.data.measureText(text).width + 16, height = 42;
core.fillRect('data', 5, 5, width, height, '#000'); core.fillRect('data', 5, 5, width, height, 'rgba(0,0,0,0.4)');
core.setOpacity('data', 0.4); core.fillText('data', text, textX + 5, textY + 15, 'rgba(255,255,255,0.6)');
core.fillText('data', text, textX + 5, textY + 15, '#fff');
} }
////// 绘制道具栏 ////// ////// 绘制道具栏 //////
@ -2603,7 +2591,6 @@ ui.prototype.drawPaint = function () {
core.clearMap('route'); core.clearMap('route');
core.setAlpha('route', 1); core.setAlpha('route', 1);
core.setOpacity('route', 1);
// 将已有的内容绘制到route上 // 将已有的内容绘制到route上
var value = core.paint[core.status.floorId]; var value = core.paint[core.status.floorId];