更新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("heroMoving", true, this._animationFrame_heroMoving);
|
||||
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("checkConsoleOpened", true, this._animationFrame_checkConsoleOpened);
|
||||
// --- 注册系统的replay
|
||||
@ -285,38 +285,31 @@ control.prototype._animationFrame_weather_fog = function () {
|
||||
}
|
||||
}
|
||||
|
||||
control.prototype._animateFrame_tips = function (timestamp) {
|
||||
var tips = core.animateFrame.tips;
|
||||
if (timestamp - tips.time <= 30) return;
|
||||
var delta = timestamp - tips.time;
|
||||
tips.time = timestamp;
|
||||
if (tips.list.length == 0) return;
|
||||
control.prototype._animateFrame_tip = function (timestamp) {
|
||||
if (core.animateFrame.tip == null) return;
|
||||
var tip = core.animateFrame.tip;
|
||||
if (timestamp - tip.time <= 30) return;
|
||||
var delta = timestamp - tip.time;
|
||||
tip.time = timestamp;
|
||||
|
||||
var currentOffset = Math.max(tips.offset - 5, 0), firstOffset = null;
|
||||
var currList = [];
|
||||
core.setFont('data', "16px Arial");
|
||||
core.setTextAlign('data', 'left');
|
||||
core.clearMap('data', 0, 0, this.PIXEL, tips.lastSize * 50);
|
||||
tips.lastLength = tips.list.length;
|
||||
|
||||
while (tips.list.length > 0) {
|
||||
var one = tips.list.shift();
|
||||
core.ui._drawTip_drawOne(one, currentOffset);
|
||||
if (one.stage == 1) {
|
||||
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;
|
||||
core.clearMap('data', 0, 0, this.PIXEL, 50);
|
||||
core.ui._drawTip_drawOne(tip);
|
||||
if (tip.stage == 1) {
|
||||
tip.opacity += 0.05;
|
||||
if (tip.opacity >= 0.6) {
|
||||
tip.stage = 2;
|
||||
tip.displayTime = 0;
|
||||
}
|
||||
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) {
|
||||
|
||||
@ -47,12 +47,7 @@ function core() {
|
||||
'data': null,
|
||||
'fog': null,
|
||||
},
|
||||
"tips": {
|
||||
'time': 0,
|
||||
'offset': 0,
|
||||
'list': [],
|
||||
'lastSize': 0,
|
||||
},
|
||||
"tip": {},
|
||||
"asyncId": {}
|
||||
}
|
||||
this.musicStatus = {
|
||||
|
||||
@ -368,7 +368,7 @@ events.prototype.battle = function (id, x, y, force, callback) {
|
||||
if (!id) return core.clearContinueAutomaticRoute(callback);
|
||||
// 非强制战斗
|
||||
if (!core.enemys.canBattle(id, x, y) && !force && !core.status.event.id) {
|
||||
core.drawTip("你打不过此怪物!", null, true);
|
||||
core.drawTip("你打不过此怪物!");
|
||||
return core.clearContinueAutomaticRoute(callback);
|
||||
}
|
||||
// 自动存档
|
||||
@ -433,7 +433,7 @@ events.prototype._openDoor_check = function (id, x, y, needKey) {
|
||||
var keyInfo = doorInfo[0];
|
||||
if (needKey) {
|
||||
if (keyInfo == null) {
|
||||
core.drawTip("无法开启此门", null, true);
|
||||
core.drawTip("无法开启此门");
|
||||
return clearAndReturn();
|
||||
}
|
||||
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) {
|
||||
this.clearTip();
|
||||
ui.prototype.drawTip = function (text, id, frame) {
|
||||
var one = {
|
||||
text: text,
|
||||
textX: 21,
|
||||
width: 26 + core.calWidth('data', text, "16px Arial"),
|
||||
opacity: 0.1,
|
||||
stage: 1,
|
||||
frame: frame || 0,
|
||||
time: 0
|
||||
};
|
||||
if (id != null) {
|
||||
@ -475,7 +475,7 @@ ui.prototype.drawTip = function (text, id, clear) {
|
||||
if (info == null || !info.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;
|
||||
}
|
||||
@ -488,27 +488,18 @@ ui.prototype.drawTip = function (text, id, clear) {
|
||||
one.width += 24;
|
||||
}
|
||||
}
|
||||
core.animateFrame.tips.list.push(one);
|
||||
if (core.animateFrame.tips.list.length > 3) {
|
||||
core.animateFrame.tips.list.shift();
|
||||
}
|
||||
core.animateFrame.tip = one;
|
||||
}
|
||||
|
||||
ui.prototype._drawTip_drawOne = function (one, offset) {
|
||||
core.setAlpha('data', one.opacity);
|
||||
core.fillRect('data', 5, offset+ 5, one.width, 42, '#000000');
|
||||
if (one.image)
|
||||
core.drawImage('data', one.image, one.posX * 32, one.posY * one.height, 32, 32, 10, offset + 10, 32, 32);
|
||||
core.fillText('data', one.text, one.textX, offset + 33, '#FFFFFF');
|
||||
ui.prototype._drawTip_drawOne = function (tip) {
|
||||
core.setAlpha('data', tip.opacity);
|
||||
core.fillRect('data', 5, 5, tip.width, 42, '#000000');
|
||||
if (tip.image)
|
||||
core.drawImage('data', tip.image, (tip.posX + tip.frame) * 32, tip.posY * tip.height, 32, 32, 10, 10, 32, 32);
|
||||
core.fillText('data', tip.text, tip.textX, 33, '#FFFFFF');
|
||||
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) {
|
||||
if (contents != null) return this._drawText_setContent(contents, callback);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user