| 
 
| 赞 | 58 |  
| VIP | 37 |  
| 好人卡 | 59 |  
| 积分 | 12 |  
| 经验 | 66255 |  
| 最后登录 | 2023-5-29 |  
| 在线时间 | 1017 小时 |  
 Lv3.寻梦者 
	梦石0 星屑1232 在线时间1017 小时注册时间2011-4-30帖子1516 | 
| 本帖最后由 汪汪 于 2016-1-2 20:06 编辑 
 andrewx 发表于 2016-1-2 19:52 ![]() 其实思路很简单,你只要判断第几次按的键是不是你要求的,比如你要mi re do re mi mi mi,其实就是第一次 ...
直接修改值的话就可以越过变量只能输入数的问题了
 也就是对 $gameVariables._data[id]  进行修改
 不过不会触发 this.onChange()
 不过可以加上一句 $gameVariables.onChange()
 复制代码
//-----------------------------------------------------------------------------
// Game_Variables
// 游戏变量  $gameVariables
// The game object class for variables.
// 变量的游戏对象类
function Game_Variables() {
    this.initialize.apply(this, arguments);
}
//初始化
Game_Variables.prototype.initialize = function() {
    this.clear();
};
//清除
Game_Variables.prototype.clear = function() {
    this._data = [];
};
//值
Game_Variables.prototype.value = function(variableId) {
    return this._data[variableId] || 0;
};
//设置值
Game_Variables.prototype.setValue = function(variableId, value) {
    if (variableId > 0 && variableId < $dataSystem.variables.length) {
        if (typeof value === 'number') {
            value = Math.floor(value);
        }
        this._data[variableId] = value;
        this.onChange();
    }
};
//当改变
Game_Variables.prototype.onChange = function() {
    $gameMap.requestRefresh();
};
 | 
 |