更新core.drawTip
This commit is contained in:
parent
763660fa04
commit
16ed7a03ef
@ -24,7 +24,7 @@ control.prototype._init = function () {
|
|||||||
this.registerAnimationFrame("animate", true, this._animationFrame_animate);
|
this.registerAnimationFrame("animate", true, this._animationFrame_animate);
|
||||||
this.registerAnimationFrame("heroMoving", true, this._animationFrame_heroMoving);
|
this.registerAnimationFrame("heroMoving", true, this._animationFrame_heroMoving);
|
||||||
this.registerAnimationFrame("weather", true, this._animationFrame_weather);
|
this.registerAnimationFrame("weather", true, this._animationFrame_weather);
|
||||||
this.registerAnimationFrame("tips", true, this._animateFrame_tips);
|
this.registerAnimationFrame("tip", true, this._animateFrame_tip);
|
||||||
this.registerAnimationFrame("parallelDo", false, this._animationFrame_parallelDo);
|
this.registerAnimationFrame("parallelDo", false, this._animationFrame_parallelDo);
|
||||||
this.registerAnimationFrame("checkConsoleOpened", true, this._animationFrame_checkConsoleOpened);
|
this.registerAnimationFrame("checkConsoleOpened", true, this._animationFrame_checkConsoleOpened);
|
||||||
// --- 注册系统的replay
|
// --- 注册系统的replay
|
||||||
@ -285,38 +285,31 @@ control.prototype._animationFrame_weather_fog = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype._animateFrame_tips = function (timestamp) {
|
control.prototype._animateFrame_tip = function (timestamp) {
|
||||||
var tips = core.animateFrame.tips;
|
if (core.animateFrame.tip == null) return;
|
||||||
if (timestamp - tips.time <= 30) return;
|
var tip = core.animateFrame.tip;
|
||||||
var delta = timestamp - tips.time;
|
if (timestamp - tip.time <= 30) return;
|
||||||
tips.time = timestamp;
|
var delta = timestamp - tip.time;
|
||||||
if (tips.list.length == 0) return;
|
tip.time = timestamp;
|
||||||
|
|
||||||
var currentOffset = Math.max(tips.offset - 5, 0), firstOffset = null;
|
|
||||||
var currList = [];
|
|
||||||
core.setFont('data', "16px Arial");
|
core.setFont('data', "16px Arial");
|
||||||
core.setTextAlign('data', 'left');
|
core.setTextAlign('data', 'left');
|
||||||
core.clearMap('data', 0, 0, this.PIXEL, tips.lastSize * 50);
|
core.clearMap('data', 0, 0, this.PIXEL, 50);
|
||||||
tips.lastLength = tips.list.length;
|
core.ui._drawTip_drawOne(tip);
|
||||||
|
if (tip.stage == 1) {
|
||||||
while (tips.list.length > 0) {
|
tip.opacity += 0.05;
|
||||||
var one = tips.list.shift();
|
if (tip.opacity >= 0.6) {
|
||||||
core.ui._drawTip_drawOne(one, currentOffset);
|
tip.stage = 2;
|
||||||
if (one.stage == 1) {
|
tip.displayTime = 0;
|
||||||
one.opacity += 0.05;
|
|
||||||
if (one.opacity >= 0.7) one.stage = 2;
|
|
||||||
} else if (one.stage == 2) {
|
|
||||||
one.time += delta;
|
|
||||||
if (one.time >= 2000) one.stage = 3;
|
|
||||||
} else one.opacity -= 0.05;
|
|
||||||
if (one.opacity > 0) {
|
|
||||||
currList.push(one);
|
|
||||||
if (firstOffset == null) firstOffset = currentOffset;
|
|
||||||
}
|
}
|
||||||
currentOffset += 50;
|
} else if (tip.stage == 2) {
|
||||||
|
tip.displayTime += delta;
|
||||||
|
if (tip.displayTime >= 1000) tip.stage = 3;
|
||||||
|
} else tip.opacity -= 0.05;
|
||||||
|
|
||||||
|
if (tip.opacity <= 0) {
|
||||||
|
core.animateFrame.tip = null;
|
||||||
}
|
}
|
||||||
tips.list = currList;
|
|
||||||
tips.offset = firstOffset || 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype._animationFrame_parallelDo = function (timestamp) {
|
control.prototype._animationFrame_parallelDo = function (timestamp) {
|
||||||
|
|||||||
@ -47,12 +47,7 @@ function core() {
|
|||||||
'data': null,
|
'data': null,
|
||||||
'fog': null,
|
'fog': null,
|
||||||
},
|
},
|
||||||
"tips": {
|
"tip": {},
|
||||||
'time': 0,
|
|
||||||
'offset': 0,
|
|
||||||
'list': [],
|
|
||||||
'lastSize': 0,
|
|
||||||
},
|
|
||||||
"asyncId": {}
|
"asyncId": {}
|
||||||
}
|
}
|
||||||
this.musicStatus = {
|
this.musicStatus = {
|
||||||
|
|||||||
@ -368,7 +368,7 @@ events.prototype.battle = function (id, x, y, force, callback) {
|
|||||||
if (!id) return core.clearContinueAutomaticRoute(callback);
|
if (!id) return core.clearContinueAutomaticRoute(callback);
|
||||||
// 非强制战斗
|
// 非强制战斗
|
||||||
if (!core.enemys.canBattle(id, x, y) && !force && !core.status.event.id) {
|
if (!core.enemys.canBattle(id, x, y) && !force && !core.status.event.id) {
|
||||||
core.drawTip("你打不过此怪物!", null, true);
|
core.drawTip("你打不过此怪物!");
|
||||||
return core.clearContinueAutomaticRoute(callback);
|
return core.clearContinueAutomaticRoute(callback);
|
||||||
}
|
}
|
||||||
// 自动存档
|
// 自动存档
|
||||||
@ -433,7 +433,7 @@ events.prototype._openDoor_check = function (id, x, y, needKey) {
|
|||||||
var keyInfo = doorInfo[0];
|
var keyInfo = doorInfo[0];
|
||||||
if (needKey) {
|
if (needKey) {
|
||||||
if (keyInfo == null) {
|
if (keyInfo == null) {
|
||||||
core.drawTip("无法开启此门", null, true);
|
core.drawTip("无法开启此门");
|
||||||
return clearAndReturn();
|
return clearAndReturn();
|
||||||
}
|
}
|
||||||
for (var keyName in keyInfo) {
|
for (var keyName in keyInfo) {
|
||||||
|
|||||||
29
libs/ui.js
29
libs/ui.js
@ -460,14 +460,14 @@ ui.prototype.clearUI = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 左上角绘制一段提示 //////
|
////// 左上角绘制一段提示 //////
|
||||||
ui.prototype.drawTip = function (text, id, clear) {
|
ui.prototype.drawTip = function (text, id, frame) {
|
||||||
this.clearTip();
|
|
||||||
var one = {
|
var one = {
|
||||||
text: text,
|
text: text,
|
||||||
textX: 21,
|
textX: 21,
|
||||||
width: 26 + core.calWidth('data', text, "16px Arial"),
|
width: 26 + core.calWidth('data', text, "16px Arial"),
|
||||||
opacity: 0.1,
|
opacity: 0.1,
|
||||||
stage: 1,
|
stage: 1,
|
||||||
|
frame: frame || 0,
|
||||||
time: 0
|
time: 0
|
||||||
};
|
};
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@ -475,7 +475,7 @@ ui.prototype.drawTip = function (text, id, clear) {
|
|||||||
if (info == null || !info.image) {
|
if (info == null || !info.image) {
|
||||||
// 检查状态栏图标
|
// 检查状态栏图标
|
||||||
if (core.statusBar.icons[id] instanceof Image) {
|
if (core.statusBar.icons[id] instanceof Image) {
|
||||||
id = {image: core.statusBar.icons[id], posX: 0, posY: 0, height: 32};
|
info = {image: core.statusBar.icons[id], posX: 0, posY: 0, height: 32};
|
||||||
}
|
}
|
||||||
else info = null;
|
else info = null;
|
||||||
}
|
}
|
||||||
@ -488,27 +488,18 @@ ui.prototype.drawTip = function (text, id, clear) {
|
|||||||
one.width += 24;
|
one.width += 24;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.animateFrame.tips.list.push(one);
|
core.animateFrame.tip = one;
|
||||||
if (core.animateFrame.tips.list.length > 3) {
|
|
||||||
core.animateFrame.tips.list.shift();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.prototype._drawTip_drawOne = function (one, offset) {
|
ui.prototype._drawTip_drawOne = function (tip) {
|
||||||
core.setAlpha('data', one.opacity);
|
core.setAlpha('data', tip.opacity);
|
||||||
core.fillRect('data', 5, offset+ 5, one.width, 42, '#000000');
|
core.fillRect('data', 5, 5, tip.width, 42, '#000000');
|
||||||
if (one.image)
|
if (tip.image)
|
||||||
core.drawImage('data', one.image, one.posX * 32, one.posY * one.height, 32, 32, 10, offset + 10, 32, 32);
|
core.drawImage('data', tip.image, (tip.posX + tip.frame) * 32, tip.posY * tip.height, 32, 32, 10, 10, 32, 32);
|
||||||
core.fillText('data', one.text, one.textX, offset + 33, '#FFFFFF');
|
core.fillText('data', tip.text, tip.textX, 33, '#FFFFFF');
|
||||||
core.setAlpha('data', 1);
|
core.setAlpha('data', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.prototype.clearTip = function () {
|
|
||||||
core.animateFrame.tips.list = [];
|
|
||||||
core.animateFrame.tips.offset = 0;
|
|
||||||
core.animateFrame.tips.lastSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////// 地图中间绘制一段文字 //////
|
////// 地图中间绘制一段文字 //////
|
||||||
ui.prototype.drawText = function (contents, callback) {
|
ui.prototype.drawText = function (contents, callback) {
|
||||||
if (contents != null) return this._drawText_setContent(contents, callback);
|
if (contents != null) return this._drawText_setContent(contents, callback);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user