diff --git a/_docs/api.md b/_docs/api.md index ee5fbbaf..a61be655 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -394,12 +394,12 @@ core.updateViewport() 根据大地图的偏移量来更新窗口的视野范围。 -core.nextX(n) / core.nextY(m) +core.nextX(n) / core.nextY(n) 获得勇士面对的第n个位置的横纵坐标。n可不填,默认为1。 -core.nearHero(x, y) -判定某个点是否和勇士的距离不大于1。 +core.nearHero(x, y, n) +判定某个点是否和勇士的距离不大于n。n可不填,默认为1。 core.gatherFollowers() diff --git a/libs/control.js b/libs/control.js index 0a574875..93b9bff4 100644 --- a/libs/control.js +++ b/libs/control.js @@ -856,17 +856,20 @@ control.prototype.updateViewport = function() { ////// 获得勇士面对位置的x坐标 ////// control.prototype.nextX = function(n) { - return core.getHeroLoc('x')+core.utils.scan[core.getHeroLoc('direction')].x*(n||1); + if (n == null) n = 1; + return core.getHeroLoc('x')+core.utils.scan[core.getHeroLoc('direction')].x*n; } ////// 获得勇士面对位置的y坐标 ////// control.prototype.nextY = function (n) { - return core.getHeroLoc('y')+core.utils.scan[core.getHeroLoc('direction')].y*(n||1); + if (n == null) n = 1; + return core.getHeroLoc('y')+core.utils.scan[core.getHeroLoc('direction')].y*n; } ////// 某个点是否在勇士旁边 ////// -control.prototype.nearHero = function (x, y) { - return Math.abs(x-core.getHeroLoc('x'))+Math.abs(y-core.getHeroLoc('y'))<=1; +control.prototype.nearHero = function (x, y, n) { + if (n == null) n = 1; + return Math.abs(x-core.getHeroLoc('x'))+Math.abs(y-core.getHeroLoc('y'))<=n; } ////// 聚集跟随者 ////// diff --git a/libs/events.js b/libs/events.js index 814afc2b..341bdcc8 100644 --- a/libs/events.js +++ b/libs/events.js @@ -431,6 +431,7 @@ events.prototype._sys_getItem = function (data, callback) { ////// 获得某个物品 ////// events.prototype.getItem = function (id, num, x, y, callback) { + if (num == null) num = 1; num = num || 1; var itemCls = core.material.items[id].cls; core.items.getItemEffect(id, num); diff --git a/libs/ui.js b/libs/ui.js index 9d63d8d0..2c310153 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -588,14 +588,15 @@ ui.prototype.drawTextContent = function (ctx, content, config) { ctx = core.getContextByName(ctx); if (!ctx) return; // 设置默认配置项 + var textAttribute = core.status.textAttribute || core.initStatus.textAttribute; config = core.clone(config || {}); config.left = config.left || 0; config.right = config.left + (config.maxWidth == null ? ctx.canvas.width : config.maxWidth); config.top = config.top || 0; - config.color = config.color || core.arrayToRGBA(core.status.textAttribute.text); - config.bold = config.bold || false; - config.align = config.align || core.status.textAttribute.align || "left"; - config.fontSize = config.fontSize || core.status.textAttribute.textfont; + config.color = config.color || core.arrayToRGBA(textAttribute.text); + if (config.bold == null) config.bold = textAttribute.bold; + config.align = config.align || textAttribute.align || "left"; + config.fontSize = config.fontSize || textAttribute.textfont; config.lineHeight = config.lineHeight || (config.fontSize * 1.3); config.time = config.time || 0; @@ -783,7 +784,7 @@ ui.prototype.drawTextBox = function(content, showAll) { var isWindowSkin = this.drawBackground(hPos.left, vPos.top, hPos.right, vPos.bottom, pInfo); var alpha = isWindowSkin ? 0.85 : textAttribute.background[3]; - // Step 4: 绘制标题、头像、 + // Step 4: 绘制标题、头像、动画 var content_top = this._drawTextBox_drawTitleAndIcon(titleInfo, hPos, vPos, alpha); // Step 5: 绘制正文