| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2015-12-9 |
| 在线时间 | 13 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 13 小时
- 注册时间
- 2015-11-30
- 回帖
- 15
|
发表于 2015-11-30 14:46:48
|
显示全部楼层
本帖最后由 语义噪音 于 2015-12-1 11:38 编辑
我觉得对于载具的判断,最好还是使用instanceof操作符比较好。检查this._character是否是Game_Vehicle的一个实例,比起用名称来判断,这样做更加优雅。
顺手把降低移动速度和禁止冲刺加上了。另外,我把方法抽离出来形成了一个单独的对象用于调用,增加了调用方法的插件命令。
[pre lang="javascript"]
var PluginMethods;
PluginMethods = {
doScale: function(scale) {
var _Sprite_Character_prototype_update;
_Sprite_Character_prototype_update = Sprite_Character.prototype.update;
Sprite_Character.prototype.update = function() {
_Sprite_Character_prototype_update.call(this);
if (!(this._character instanceof Game_Vehicle)) {
this._character._dashing = false;
this._character._moveSpeed = scale * 4;
this.scale.x = scale;
this.scale.y = scale;
}
};
}
};
(function() {
var _Game_Interpreter_pluginCommand;
_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
return Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
switch (command) {
case 'plug-in':
switch (args[0]) {
case 'doScale':
PluginMethods.doScale(args[1]);
}
}
};
})();
[/pre] |
|