canEquip -> equipCondition
This commit is contained in:
parent
9264e7dfe5
commit
2426c8b010
@ -224,7 +224,11 @@ function () {
|
|||||||
- 清晰明了。很容易方便知道自己修改过什么,尤其是可以和系统原有代码进行对比。
|
- 清晰明了。很容易方便知道自己修改过什么,尤其是可以和系统原有代码进行对比。
|
||||||
- 方便整理成新的插件,给其他的塔使用。
|
- 方便整理成新的插件,给其他的塔使用。
|
||||||
|
|
||||||
如果我想对xxx文件中的yyy函数进行重写,其模式一般是:`core.xxx.yyy = function (参数列表) { ... }`
|
一般而言,复写规则如下:
|
||||||
|
|
||||||
|
**对xxx文件中的yyy函数进行复写,规则是`core.xxx.yyy = function (参数列表) { ... }`。**
|
||||||
|
|
||||||
|
但是,对于`registerXXX`所注册的函数是无效的,例如直接复写`core.control._animationFrame_globalAnimate`函数是没有效果的。对于这种情况引入的函数,需要注册同名函数,可参见最下面的样例。
|
||||||
|
|
||||||
下面是几个例子,从简单到复杂。
|
下面是几个例子,从简单到复杂。
|
||||||
|
|
||||||
@ -317,6 +321,32 @@ core.maps.drawMap = function (floorId, callback) {
|
|||||||
|
|
||||||
详见[call和apply的用法](https://www.jianshu.com/p/80ea0d1c04f8)。
|
详见[call和apply的用法](https://www.jianshu.com/p/80ea0d1c04f8)。
|
||||||
|
|
||||||
|
### 复写全局动画绘制函数
|
||||||
|
|
||||||
|
全局动画绘制在`control.js`的`_animationFrame_globalAnimate`函数。
|
||||||
|
|
||||||
|
注意到此函数是由`registerAnimationFrame`注册的,因此直接复写是无效的。
|
||||||
|
|
||||||
|
其在control.js的注册的定义如下:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// 注册全局动画函数
|
||||||
|
this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate);
|
||||||
|
```
|
||||||
|
|
||||||
|
因此,可以在插件中自行注册一个**同名**的函数来覆盖原始的内容。
|
||||||
|
|
||||||
|
```js
|
||||||
|
// 插件中复写全局动画绘制函数
|
||||||
|
this.myGlobalAnimate = function (timestamp) {
|
||||||
|
// ...... 实际复写的函数内容
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册同名(globalAnimate)函数来覆盖系统原始内容
|
||||||
|
core.registerAnimationFrame("globalAnimate", true, "myGlobalAnimate");
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
==========================================================================================
|
==========================================================================================
|
||||||
|
|
||||||
[继续阅读下一章:API列表](api)
|
[继续阅读下一章:API列表](api)
|
||||||
|
|||||||
@ -81,12 +81,12 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_lint": true,
|
"_lint": true,
|
||||||
"_data": "当前能否使用该道具,仅对cls为tools或constants有效。"
|
"_data": "当前能否使用该道具,仅对cls为tools或constants有效。"
|
||||||
},
|
},
|
||||||
"canEquip": {
|
"equipCondition": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_string": true,
|
"_string": true,
|
||||||
"_lint": true,
|
"_lint": true,
|
||||||
"_data": "当前能否装备某个装备,仅对cls为equips有效。\n与canUseItemEffect不同,这里null代表可以装备。"
|
"_data": "能装备某个装备的条件,仅对cls为equips有效。\n与canUseItemEffect不同,这里null代表可以装备。"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -189,7 +189,6 @@ control.prototype._animationFrame_animate = function (timestamp) {
|
|||||||
|
|
||||||
control.prototype._animationFrame_heroMoving = function (timestamp) {
|
control.prototype._animationFrame_heroMoving = function (timestamp) {
|
||||||
if (core.status.heroMoving <= 0) return;
|
if (core.status.heroMoving <= 0) return;
|
||||||
var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'), direction = core.getHeroLoc('direction');
|
|
||||||
// 换腿
|
// 换腿
|
||||||
if (timestamp - core.animateFrame.moveTime > (core.values.moveSpeed||100)) {
|
if (timestamp - core.animateFrame.moveTime > (core.values.moveSpeed||100)) {
|
||||||
core.animateFrame.leftLeg = !core.animateFrame.leftLeg;
|
core.animateFrame.leftLeg = !core.animateFrame.leftLeg;
|
||||||
|
|||||||
@ -11,9 +11,9 @@ items.prototype._init = function () {
|
|||||||
this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip;
|
this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip;
|
||||||
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect;
|
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect;
|
||||||
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect;
|
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect;
|
||||||
if (!items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canEquip)
|
if (!items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition)
|
||||||
items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canEquip = {};
|
items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition = {};
|
||||||
this.equipCondition = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canEquip;
|
this.equipCondition = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 获得所有道具 //////
|
////// 获得所有道具 //////
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user