删除平滑移动镜头插件

This commit is contained in:
ckcz123 2020-07-04 20:11:55 +08:00
parent 8547e946eb
commit ffbf527892
2 changed files with 0 additions and 126 deletions

View File

@ -75,12 +75,6 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "物品分类插件"
},
"smoothCamera": {
"_leaf": true,
"_type": "textarea",
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "平滑移动镜头"
},
}
if (obj[key]) return obj[key];
return {

View File

@ -1258,125 +1258,5 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
return true;
}, 100);
},
"smoothCamera": function () {
// 此插件开启后,大地图的瞬间移动将开启平滑镜头移动,避免突兀感
// 插件作者:老黄鸡
// 是否启用本插件,默认不启用
var __enable = false;
if (!__enable) return;
this.Camera = function () {
// 下面这个变量决定本插件的开关
// 你可以在游戏中使用core.setFlag('smoothCamera',false)来关闭本插件的功能
// 同时也可以core.setFlag('smoothCamera',true)重新开启
// 此项默认为true
//
this.__switchName = 'smoothCamera';
// 初始化成员变量
this._cameraNeedRefresh = true;
this._nowOffsetX = 0;
this._nowOffsetY = 0;
this._targetOffsetX = 0;
this._targetOffsetY = 0;
this._currentFloorId = null;
// 重置镜头,在楼层变更时使用
this.resetCamera = function () {
this._targetOffsetX = core.bigmap.offsetX;
this._targetOffsetY = core.bigmap.offsetY;
this._nowOffsetX = this._targetOffsetX;
this._nowOffsetY = this._targetOffsetY;
this._cameraNeedRefresh = true;
};
// 设置焦点坐标,目前没有用
this.setTarget = function (x, y) {
this._targetOffsetX = x;
this._targetOffsetY = y;
};
// 请求镜头更新
this.requestCameraUpdate = function () {
this._cameraNeedRefresh = true;
};
// 更新焦点坐标,目前仅根据大地图偏移决定
this.updateTargetPosition = function () {
this._targetOffsetX = core.bigmap.offsetX;
this._targetOffsetY = core.bigmap.offsetY;
};
// 更新额外的刷新条件,即镜头未指向焦点时
this.updateRefreshFlag = function () {
if (this._nowOffsetX != this._targetOffsetX || this._nowOffsetY != this._targetOffsetY) {
this._cameraNeedRefresh = true;
}
};
// 判断是否禁止了弹性滚动
this.canDirectMove = function () {
return !core.getFlag(this.__switchName, true);
};
// 更新镜头坐标
this.updateCameraPosition = function () {
if (this._cameraNeedRefresh) {
this._cameraNeedRefresh = false;
var disX = this._targetOffsetX - this._nowOffsetX;
var disY = this._targetOffsetY - this._nowOffsetY;
if (Math.abs(disX) <= 2 && Math.abs(disY) <= 2 || this.canDirectMove()) {
this._nowOffsetX = this._targetOffsetX;
this._nowOffsetY = this._targetOffsetY;
} else {
this._nowOffsetX += disX / 10;
this._nowOffsetY += disY / 10;
}
var x = -Math.floor(this._nowOffsetX);
var y = -Math.floor(this._nowOffsetY);
core.bigmap.canvas.forEach(function (cn) {
core.control.setGameCanvasTranslate(cn, x, y);
});
core.relocateCanvas('route', core.status.automaticRoute.offsetX + x, core.status.automaticRoute.offsetY + y);
core.setGameCanvasTranslate('hero', x + this._targetOffsetX, y + this._targetOffsetY);
}
};
// 更新逻辑主体
this.update = function () {
this.updateTargetPosition();
this.updateRefreshFlag();
this.updateCameraPosition();
};
};
// 创建摄像机对象
this.camera = new this.Camera();
// 帧事件 更新摄像机
this.updateCameraEx = function () {
this.camera.update();
};
core.control._drawHero_updateViewport = function () {
core.control.updateViewport();
}
// 代理原本的镜头事件
core.control.updateViewport = function () {
core.plugin.camera.requestCameraUpdate();
};
// 更变楼层的行为追加,重置镜头
core.events.changingFloor = function (floorId, heroLoc) {
this.eventdata.changingFloor(floorId, heroLoc);
core.plugin.camera.resetCamera();
};
// 注册帧事件
core.registerAnimationFrame('smoothCameraFlash', true, this.updateCameraEx.bind(this));
}
}