查看: 2936|回复: 3

[有事请教] 有关MOG_LimitedVisibility手电效果的旋转速度

[复制链接]
梦石
26
星屑
10805
在线时间
1289 小时
注册时间
2019-5-21
回帖
641

极短28获奖极短27参与MZ评测员极短26获奖极短25获奖极短24参与极短21参与

发表于 2020-8-1 17:02:03 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
因为想获得手电筒的效果所以使用了Drill大佬优化过的MOG插件,MOG_LimitedVisibility
但是如果设置光源跟随角色朝向旋转的话,感觉旋转速度略慢……不知道能否实现瞬间转向x
脚本里含有speed的部分看不太懂,有大佬帮忙康康吗orz
  1. //=============================================================================
  2. // MOG_LimitedVisibility.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc (v1.0)[v1.3]  地图 - 简单光源精灵
  6. * @author Moghunter (Drill_up翻译+优化)
  7. *
  8. * @param 平移-光源 X
  9. * @desc 以光源的点为基准,x轴方向平移,单位像素。(可为负数)
  10. * @default 0
  11. *
  12. * @param 平移-光源 Y
  13. * @desc 以光源的点为基准,y轴方向平移,单位像素。(可为负数)
  14. * @default -24
  15. *
  16. * @param 光源旋转半径
  17. * @type number
  18. * @min 0
  19. * @desc Area de movimento do círculo.
  20. * @default 60
  21. *
  22. * @param 是否根据玩家朝向变化
  23. * @type boolean
  24. * @on 变化
  25. * @off 不变化
  26. * @desc true - 变化,false - 不变化。只能变化四方向,对角方向不支持。
  27. * @default true
  28. *
  29. * @param 平移-精灵 X
  30. * @desc 以精灵的点为基准,x轴方向平移,单位像素。(可为负数)
  31. * @default 0
  32. *
  33. * @param 平移-精灵 Y
  34. * @desc 以精灵的点为基准,y轴方向平移,单位像素。(可为负数)
  35. * @default 0
  36. *
  37. * @param 精灵动画帧
  38. * @type number
  39. * @min 1
  40. * @desc 1表示不使用gif动画。帧数设置为4,会把资源分割成4份,然后依次循环播放。
  41. * @default 3
  42. *
  43. * @param 精灵帧播放速度
  44. * @type number
  45. * @min 1
  46. * @desc 速度为帧/每张图。设置10表示每10帧跳转至下一帧图片。(1秒60帧)
  47. * @default 6
  48. *
  49. * @param --精灵组--
  50. * @default
  51. *
  52. * @param 精灵-1
  53. * @parent --精灵组--
  54. * @desc 精灵的图片资源。
  55. * @default
  56. * @require 1
  57. * @dir img/Map__ui/
  58. * @type file
  59. *
  60. * @param 精灵-2
  61. * @parent --精灵组--
  62. * @desc 精灵的图片资源。
  63. * @default
  64. * @require 1
  65. * @dir img/Map__ui/
  66. * @type file
  67. *
  68. * @param 精灵-3
  69. * @parent --精灵组--
  70. * @desc 精灵的图片资源。
  71. * @default
  72. * @require 1
  73. * @dir img/Map__ui/
  74. * @type file
  75. *
  76. * @param 精灵-4
  77. * @parent --精灵组--
  78. * @desc 精灵的图片资源。
  79. * @default
  80. * @require 1
  81. * @dir img/Map__ui/
  82. * @type file
  83. *
  84. * @param 精灵-5
  85. * @parent --精灵组--
  86. * @desc 精灵的图片资源。
  87. * @default
  88. * @require 1
  89. * @dir img/Map__ui/
  90. * @type file
  91. *
  92. * @param 精灵-6
  93. * @parent --精灵组--
  94. * @desc 精灵的图片资源。
  95. * @default
  96. * @require 1
  97. * @dir img/Map__ui/
  98. * @type file
  99. *
  100. * @param 精灵-7
  101. * @parent --精灵组--
  102. * @desc 精灵的图片资源。
  103. * @default
  104. * @require 1
  105. * @dir img/Map__ui/
  106. * @type file
  107. *
  108. * @param 精灵-8
  109. * @parent --精灵组--
  110. * @desc 精灵的图片资源。
  111. * @default
  112. * @require 1
  113. * @dir img/Map__ui/
  114. * @type file
  115. *
  116. * @param 精灵-9
  117. * @parent --精灵组--
  118. * @desc 精灵的图片资源。
  119. * @default
  120. * @require 1
  121. * @dir img/Map__ui/
  122. * @type file
  123. *
  124. * @param 精灵-10
  125. * @parent --精灵组--
  126. * @desc 精灵的图片资源。
  127. * @default
  128. * @require 1
  129. * @dir img/Map__ui/
  130. * @type file
  131. *
  132. * @param 精灵-11
  133. * @parent --精灵组--
  134. * @desc 精灵的图片资源。
  135. * @default
  136. * @require 1
  137. * @dir img/Map__ui/
  138. * @type file
  139. *
  140. * @param 精灵-12
  141. * @parent --精灵组--
  142. * @desc 精灵的图片资源。
  143. * @default
  144. * @require 1
  145. * @dir img/Map__ui/
  146. * @type file
  147. *
  148. * @param 精灵-13
  149. * @parent --精灵组--
  150. * @desc 精灵的图片资源。
  151. * @default
  152. * @require 1
  153. * @dir img/Map__ui/
  154. * @type file
  155. *
  156. * @param 精灵-14
  157. * @parent --精灵组--
  158. * @desc 精灵的图片资源。
  159. * @default
  160. * @require 1
  161. * @dir img/Map__ui/
  162. * @type file
  163. *
  164. * @param 精灵-15
  165. * @parent --精灵组--
  166. * @desc 精灵的图片资源。
  167. * @default
  168. * @require 1
  169. * @dir img/Map__ui/
  170. * @type file
  171. *
  172. * @param 精灵-16
  173. * @parent --精灵组--
  174. * @desc 精灵的图片资源。
  175. * @default
  176. * @require 1
  177. * @dir img/Map__ui/
  178. * @type file
  179. *
  180. * @param 精灵-17
  181. * @parent --精灵组--
  182. * @desc 精灵的图片资源。
  183. * @default
  184. * @require 1
  185. * @dir img/Map__ui/
  186. * @type file
  187. *
  188. * @param 精灵-18
  189. * @parent --精灵组--
  190. * @desc 精灵的图片资源。
  191. * @default
  192. * @require 1
  193. * @dir img/Map__ui/
  194. * @type file
  195. *
  196. * @param 精灵-19
  197. * @parent --精灵组--
  198. * @desc 精灵的图片资源。
  199. * @default
  200. * @require 1
  201. * @dir img/Map__ui/
  202. * @type file
  203. *
  204. * @param 精灵-20
  205. * @parent --精灵组--
  206. * @desc 精灵的图片资源。
  207. * @default
  208. * @require 1
  209. * @dir img/Map__ui/
  210. * @type file
  211. *
  212. *
  213. * @param --阴影组--
  214. * @default
  215. *
  216. * @param 阴影-1
  217. * @parent --阴影组--
  218. * @desc 阴影的图片资源。
  219. * @default
  220. * @require 1
  221. * @dir img/Map__ui/
  222. * @type file
  223. *
  224. * @param 阴影-2
  225. * @parent --阴影组--
  226. * @desc 阴影的图片资源。
  227. * @default
  228. * @require 1
  229. * @dir img/Map__ui/
  230. * @type file
  231. *
  232. * @param 阴影-3
  233. * @parent --阴影组--
  234. * @desc 阴影的图片资源。
  235. * @default
  236. * @require 1
  237. * @dir img/Map__ui/
  238. * @type file
  239. *
  240. * @param 阴影-4
  241. * @parent --阴影组--
  242. * @desc 阴影的图片资源。
  243. * @default
  244. * @require 1
  245. * @dir img/Map__ui/
  246. * @type file
  247. *
  248. * @param 阴影-5
  249. * @parent --阴影组--
  250. * @desc 阴影的图片资源。
  251. * @default
  252. * @require 1
  253. * @dir img/Map__ui/
  254. * @type file
  255. *
  256. * @param 阴影-6
  257. * @parent --阴影组--
  258. * @desc 阴影的图片资源。
  259. * @default
  260. * @require 1
  261. * @dir img/Map__ui/
  262. * @type file
  263. *
  264. * @param 阴影-7
  265. * @parent --阴影组--
  266. * @desc 阴影的图片资源。
  267. * @default
  268. * @require 1
  269. * @dir img/Map__ui/
  270. * @type file
  271. *
  272. * @param 阴影-8
  273. * @parent --阴影组--
  274. * @desc 阴影的图片资源。
  275. * @default
  276. * @require 1
  277. * @dir img/Map__ui/
  278. * @type file
  279. *
  280. * @param 阴影-9
  281. * @parent --阴影组--
  282. * @desc 阴影的图片资源。
  283. * @default
  284. * @require 1
  285. * @dir img/Map__ui/
  286. * @type file
  287. *
  288. * @param 阴影-10
  289. * @parent --阴影组--
  290. * @desc 阴影的图片资源。
  291. * @default
  292. * @require 1
  293. * @dir img/Map__ui/
  294. * @type file
  295. *
  296. * @param 阴影-11
  297. * @parent --阴影组--
  298. * @desc 阴影的图片资源。
  299. * @default
  300. * @require 1
  301. * @dir img/Map__ui/
  302. * @type file
  303. *
  304. * @param 阴影-12
  305. * @parent --阴影组--
  306. * @desc 阴影的图片资源。
  307. * @default
  308. * @require 1
  309. * @dir img/Map__ui/
  310. * @type file
  311. *
  312. * @param 阴影-13
  313. * @parent --阴影组--
  314. * @desc 阴影的图片资源。
  315. * @default
  316. * @require 1
  317. * @dir img/Map__ui/
  318. * @type file
  319. *
  320. * @param 阴影-14
  321. * @parent --阴影组--
  322. * @desc 阴影的图片资源。
  323. * @default
  324. * @require 1
  325. * @dir img/Map__ui/
  326. * @type file
  327. *
  328. * @param 阴影-15
  329. * @parent --阴影组--
  330. * @desc 阴影的图片资源。
  331. * @default
  332. * @require 1
  333. * @dir img/Map__ui/
  334. * @type file
  335. *
  336. * @param 阴影-16
  337. * @parent --阴影组--
  338. * @desc 阴影的图片资源。
  339. * @default
  340. * @require 1
  341. * @dir img/Map__ui/
  342. * @type file
  343. *
  344. * @param 阴影-17
  345. * @parent --阴影组--
  346. * @desc 阴影的图片资源。
  347. * @default
  348. * @require 1
  349. * @dir img/Map__ui/
  350. * @type file
  351. *
  352. * @param 阴影-18
  353. * @parent --阴影组--
  354. * @desc 阴影的图片资源。
  355. * @default
  356. * @require 1
  357. * @dir img/Map__ui/
  358. * @type file
  359. *
  360. * @param 阴影-19
  361. * @parent --阴影组--
  362. * @desc 阴影的图片资源。
  363. * @default
  364. * @require 1
  365. * @dir img/Map__ui/
  366. * @type file
  367. *
  368. * @param 阴影-20
  369. * @parent --阴影组--
  370. * @desc 阴影的图片资源。
  371. * @default
  372. * @require 1
  373. * @dir img/Map__ui/
  374. * @type file
  375. *
  376. * @help  
  377. * =============================================================================
  378. * +++ MOG - Limited Visibility (v1.0) +++
  379. * By Moghunter
  380. * [url]https://atelierrgss.wordpress.com/[/url]
  381. * =============================================================================
  382. * 你可以通过阴影图片资源来制造简单黑暗效果。
  383. *
  384. * -----------------------------------------------------------------------------
  385. * ----设定注意事项
  386. * 1.插件的作用域:地图界面。
  387. *   只有围绕玩家一个光源。
  388. * 2.阴影图片资源多大,阴影就有多大。
  389. * 3.该插件与 TerraxLighting.js  地图–多光源特效 的功能是一样的。
  390. *   (二者可以叠加使用,但是效果差强人意。)
  391. *
  392. * -----------------------------------------------------------------------------
  393. * ----关联文件
  394. * 资源路径:img/Map__ui (Map后面有两个下划线)
  395. * 先确保项目img文件夹下是否有Map__ui文件夹。
  396. * 配置没有固定顺序,可以随机配置在组中。
  397. * 但是关键字设置要与配置的文件名相互匹配!
  398. *
  399. * -----------------------------------------------------------------------------
  400. * ----激活条件
  401. * 需要通过插件指令来开启光源精灵,一次只能设置一个光源精灵:
  402. * (注意,插件的冒号两边都有一个空格)
  403. *
  404. * 插件指令(启用):limitedvisibility : A : B : C : D
  405. * 插件指令(关闭):clearvisibility
  406. *
  407. * 参数A:移动方式
  408. *        0 - 保持不动, 1 - 环绕
  409. * 参数B:精灵图片资源
  410. *        不需要.png后缀,但是要确保和配置的文件名一致。
  411. *        如果没有图片,可以填写"无"。
  412. * 参数C:阴影图片资源
  413. *        不需要.png后缀,但是要确保和配置的文件名一致。
  414. * 参数D:阴影亮度
  415. *        0为全亮,255为全黑。
  416. *
  417. * 光源需要根据你自定义的阴影图片来控制光线,如果阴影图片是一个长方形的
  418. * 完全透明的图片,那么地图上会显示一个长方形的可见区域。
  419. * 注意,阴影图片的中心也就是光源的中心。
  420. *
  421. * 示例:
  422. * 插件指令:limitedvisibility : 0 : 无 : 光源精灵-阴影3 : 255
  423. * 插件指令:limitedvisibility : 1 : 光源精灵-精灵1 : 光源精灵-阴影2 : 255
  424. * 插件指令:clearvisibility
  425. *
  426. * -----------------------------------------------------------------------------
  427. * ----插件性能
  428. * 测试仪器:   4G 内存,Intel Core i5-2520M CPU 2.5GHz 处理器
  429. *              Intel(R) HD Graphics 3000 集显 的垃圾笔记本
  430. *              (笔记本的3dmark综合分:571,鲁大师综合分:48456)
  431. * 总时段:     20000.00ms左右
  432. * 对照表:     0.00ms  - 40.00ms (几乎无消耗)
  433. *              40.00ms - 80.00ms (低消耗)
  434. *              80.00ms - 120.00ms(中消耗)
  435. *              120.00ms以上      (高消耗)
  436. * 工作类型:   持续执行
  437. * 时间复杂度: 未估计
  438. * 测试方法:   仅仅是去光源管理层跑了一趟。
  439. * 测试结果:   20个事件的地图中,平均消耗为:【66.54ms】
  440. *
  441. * 1.插件只在自己作用域下工作消耗性能,在其它作用域下是不工作的。
  442. *   测试结果并不是精确值,范围在给定值的10ms范围内波动。
  443. *   更多了解插件性能,可以去看看"关于插件性能.docx"。
  444. * 2.相比多光源特效而言,该插件的消耗要少得多,但是只有玩家的光源。
  445. *
  446. * -----------------------------------------------------------------------------
  447. * ----关于Drill_up优化:
  448. * [v1.1]
  449. * 使得该插件支持关联资源的打包、加密。
  450. * 部署时勾选去除无关文件,本插件中相关的文件不会被去除。
  451. * [v1.2]
  452. * 添加了根据玩家朝向变化光线的功能。
  453. * [v1.3]
  454. * 修改了插件关联的资源文件夹。添加了插件性能测试说明。
  455. */

  456. //=============================================================================
  457. // ** PLUGIN PARAMETERS
  458. //=============================================================================
  459.   var Imported = Imported || {};
  460.   Imported.MOG_LimitedVisibility = true;
  461.   var Moghunter = Moghunter || {};

  462.    Moghunter.parameters = PluginManager.parameters('MOG_LimitedVisibility');  
  463.     Moghunter.lightSphereX = Number(Moghunter.parameters['平移-光源 X'] || 0);
  464.     Moghunter.lightSphereY = Number(Moghunter.parameters['平移-光源 Y'] || -24);
  465.         Moghunter.lightSphereObjectR = Number(Moghunter.parameters['光源旋转半径'] || 60);
  466.         Moghunter.lightSphereObjectF = Number(Moghunter.parameters['精灵动画帧'] || 1);
  467.         Moghunter.lightSphereObjectA = Number(Moghunter.parameters['精灵帧播放速度'] || 6);
  468.     Moghunter.lightSphereObjectX = Number(Moghunter.parameters['平移-精灵 X'] || 0);
  469.     Moghunter.lightSphereObjectY = Number(Moghunter.parameters['平移-精灵 Y'] || 0);       
  470.     Moghunter.lightSphere_is_change = String(Moghunter.parameters['是否根据玩家朝向变化'] || "true");       
  471.        
  472.        
  473. //=============================================================================
  474. // ** 资源文件夹
  475. //=============================================================================
  476. ImageManager.load_MapUi = function(filename) {
  477.     return this.loadBitmap('img/Map__ui/', filename, 0, true);
  478. };

  479. //=============================================================================
  480. // ** Game_Interpreter
  481. //=============================================================================       
  482. //==============================
  483. // * PluginCommand
  484. //==============================
  485. var _mog_sphLight_pluginCommand = Game_Interpreter.prototype.pluginCommand
  486. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  487.         _mog_sphLight_pluginCommand.call(this,command, args)
  488.     if (command === "limitedvisibility")  {
  489.                 type = Number(args[1]);
  490.                 fileName1 = String(args[3]);
  491.                 if(fileName1==="无"){fileName1 = ""};
  492.                 fileName2 = String(args[5]);
  493.                 opc = String(args[7]);
  494.         $gameSystem._lsphereData = [true,type,0,null,fileName1,fileName2,opc];
  495.         } else if (command === "clearvisibility")  {
  496.                  $gameSystem._lsphereData = [true,-1,0,null,"","",255];
  497.         };
  498.         return true;
  499. };

  500. //=============================================================================
  501. // ** Game System
  502. //=============================================================================

  503. //==============================
  504. // * Initialize
  505. //==============================
  506. var _mog_SpLight_Gsys_initialize = Game_System.prototype.initialize;
  507. Game_System.prototype.initialize = function() {
  508.     _mog_SpLight_Gsys_initialize.call(this);
  509.         this._lsphereData = [false,-1,0,null,"","",255];
  510. };       
  511.        
  512. //=============================================================================
  513. // ** Scene Map
  514. //=============================================================================

  515. //==============================
  516. // * Terminate
  517. //==============================
  518. var _mog_Splight_scMap_terminate = Scene_Map.prototype.terminate;
  519. Scene_Map.prototype.terminate = function() {
  520.         if (this._spriteset) {this._spriteset.recordSphereData()};
  521.     _mog_Splight_scMap_terminate.call(this);
  522. };

  523. //=============================================================================
  524. // ** Spriteset Map
  525. //=============================================================================

  526. //==============================
  527. // * create Lower Layer
  528. //==============================
  529. var _mog_spLight_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
  530. Spriteset_Map.prototype.createLowerLayer = function() {
  531.     _mog_spLight_createLowerLayer.call(this);
  532.         this.createSphereLight();
  533. };

  534. //==============================
  535. // * create Sphere Light
  536. //==============================
  537. Spriteset_Map.prototype.createSphereLight = function() {
  538.          if ($gameSystem._lsphereData[3]) {$gameSystem._lsphereData[0] = true};
  539.      this._sphereLight = new SpriteSphereLight();
  540.          this.addChild(this._sphereLight);
  541. };

  542. //==============================
  543. // * Record Particles Data
  544. //==============================
  545. Spriteset_Map.prototype.recordSphereData = function() {
  546.      if (this._sphereLight._Sphere.bitmap) {this._sphereLight.recordSphereData()};
  547. };       

  548. //=============================================================================
  549. // ** SpriteSphereLight
  550. //=============================================================================
  551. function SpriteSphereLight() {
  552.     this.initialize.apply(this, arguments);
  553. };
  554. SpriteSphereLight.prototype = Object.create(Sprite.prototype);
  555. SpriteSphereLight.prototype.constructor = SpriteSphereLight;

  556. //==============================
  557. // * Initialize
  558. //==============================
  559. SpriteSphereLight.prototype.initialize = function() {
  560.     Sprite.prototype.initialize.call(this);
  561.         this.opacity = 0;
  562.         this._data = [false,0,0,0,0];
  563.         this._pi = 2.0 * Math.PI;
  564.         this._np = [0,0,0,0];
  565.         this._rol_range = Moghunter.lightSphereObjectR;
  566.         this.createBlackField();
  567.     this.createLight();
  568.         this.createSphere();
  569.         this.updatePosition();
  570. };

  571. //==============================
  572. // * record Sphere Data
  573. //==============================
  574. SpriteSphereLight.prototype.recordSphereData = function() {
  575.    $gameSystem._lsphereData[3] = [];
  576.    $gameSystem._lsphereData[3][0] = this.opacity;
  577.    $gameSystem._lsphereData[3][1] = this.x;
  578.    $gameSystem._lsphereData[3][2] = this.y;
  579.    $gameSystem._lsphereData[3][3] = this._Sphere.x;
  580.    $gameSystem._lsphereData[3][4] = this._Sphere.y;
  581.    $gameSystem._lsphereData[3][5] = this._np;
  582.    $gameSystem._lsphereData[3][6] = this._SphereData;
  583.    $gameSystem._lsphereData[3][7] = this._data;
  584. };
  585.    
  586. //==============================
  587. // * Load Sphere Data
  588. //==============================
  589. SpriteSphereLight.prototype.loadSphereData = function() {
  590.    this.opacity = $gameSystem._lsphereData[3][0];
  591.    this.x = $gameSystem._lsphereData[3][1];
  592.    this.y = $gameSystem._lsphereData[3][2];
  593.    this._Sphere.x = $gameSystem._lsphereData[3][3];
  594.    this._Sphere.y = $gameSystem._lsphereData[3][4];
  595.    this._np = $gameSystem._lsphereData[3][5];
  596.    this._SphereData = $gameSystem._lsphereData[3][6];
  597.    this._data = $gameSystem._lsphereData[3][7];
  598.    $gameSystem._lsphereData[3] = null;
  599. };

  600. //==============================
  601. // * create Black Field
  602. //==============================
  603. SpriteSphereLight.prototype.createBlackField = function() {
  604.     this._blackField = new Sprite();
  605.         this.addChild(this._blackField);
  606. };

  607. //==============================
  608. // * createLight
  609. //==============================
  610. SpriteSphereLight.prototype.createLight = function() {
  611.         this._lightSprite = new Sprite();
  612.         this._lightSprite.anchor.x = 0.5;
  613.         this._lightSprite.anchor.y = 0.5;
  614.         this.addChild(this._lightSprite);
  615. };

  616. //==============================
  617. // * createSphere
  618. //==============================
  619. SpriteSphereLight.prototype.createSphere = function() {
  620.         this._Sphere = new Sprite();
  621.         this._SphereData = [-10,0,0,0,0,0];
  622.         this.addChild(this._Sphere);
  623. };

  624. //==============================
  625. // * Refresh Bitmap
  626. //==============================
  627. SpriteSphereLight.prototype.refreshBitmap = function() {
  628.         this._blackField.bitmap = new Bitmap(this.screenCW()*2,this.screenCH()*2);
  629.         this._blackField.bitmap.fillAll('black');       
  630.         this._blackField.anchor.x = 0.5;
  631.         this._blackField.anchor.y = 0.5;
  632.     this._Sphere.bitmap = ImageManager.load_MapUi($gameSystem._lsphereData[4]);
  633.         this._lightSprite.bitmap = ImageManager.load_MapUi($gameSystem._lsphereData[5]);
  634. };

  635. //==============================
  636. // * Clear
  637. //==============================
  638. SpriteSphereLight.prototype.clearBitmap = function() {
  639.         this.opacity = 0;
  640.     this._Sphere.bitmap = null;
  641.         this._lightSprite.bitmap = null;
  642. };

  643. //==============================
  644. // * refreshSphere
  645. //==============================
  646. SpriteSphereLight.prototype.refreshSphere = function() {
  647.     var wd = this._SphereData[0] * this._SphereData[2];
  648.     this._Sphere.setFrame(wd,0,this._SphereData[0],this._SphereData[1]);
  649.         this._SphereData[2]++;
  650.         if (this._SphereData[2] > Moghunter.lightSphereObjectF-1) {this._SphereData[2] = 0};
  651. };

  652. //==============================
  653. // * updateSphere
  654. //==============================
  655. SpriteSphereLight.prototype.updateSphere = function() {
  656.         this._SphereData[3]++;
  657.         if (this._SphereData[3] < this._SphereData[4]) {return};
  658.         this._SphereData[3] = 0;
  659.     this.refreshSphere();
  660. };

  661. //==============================
  662. // * Mode
  663. //==============================
  664. SpriteSphereLight.prototype.mode = function() {
  665.     return $gameSystem._lsphereData[1];
  666. };

  667. //==============================
  668. // * screen CW
  669. //==============================
  670. SpriteSphereLight.prototype.screenCW = function() {
  671.      return  Math.floor(Graphics.boxWidth * 2) + 64;
  672. };

  673. //==============================
  674. // * screen CH
  675. //==============================
  676. SpriteSphereLight.prototype.screenCH = function() {
  677.      return  Math.floor(Graphics.boxHeight * 2) + 64;
  678. };

  679. //==============================
  680. // * posX
  681. //==============================
  682. SpriteSphereLight.prototype.posX = function() {
  683.      return $gamePlayer.screenX() + this._data[1] + Moghunter.lightSphereX - Math.floor(this.screenCW() / 2);
  684. };

  685. //==============================
  686. // * posY
  687. //==============================
  688. SpriteSphereLight.prototype.posY = function() {
  689.      return $gamePlayer.screenY() + this._data[2] + Moghunter.lightSphereY - Math.floor(this.screenCH() / 2);
  690. };

  691. //==============================
  692. // * Reset Bitmap
  693. //==============================
  694. SpriteSphereLight.prototype.resetBitmap = function() {
  695.     this._data = [false,0,0,0,0];
  696.     this._np = [0,0,0,0];
  697.     this._SphereData = [-10,0,0,0,0,0];
  698.         $gameSystem._lsphereData[0] = false;
  699.         if ($gameSystem._lsphereData[1] === -1) {
  700.                  this.clearBitmap();
  701.                  this._data[0] = true;
  702.         } else {
  703.                  this.refreshBitmap();
  704.         };
  705. };

  706. //==============================
  707. // * refresh Rect
  708. //==============================
  709. SpriteSphereLight.prototype.refreshRect = function() {
  710.         if ($gameSystem._lsphereData[0]) {this.resetBitmap();return};
  711.         if (!this._Sphere.bitmap) {this.refreshBitmap()};
  712.         if (!this._Sphere.bitmap.isReady() || !this._lightSprite.bitmap.isReady()) {return};
  713.         this._SphereData = [this._Sphere.bitmap.width / Moghunter.lightSphereObjectF,this._Sphere.bitmap.height,0,0,
  714.                              Moghunter.lightSphereObjectF,Moghunter.lightSphereObjectA];
  715.         this.refreshSphere();
  716.         var w = this._lightSprite.bitmap.width ;
  717.         var h = this._lightSprite.bitmap.height;
  718.         var b_x = (this._blackField.bitmap.width /2) - (w/2);
  719.         var b_y = (this._blackField.bitmap.height /2) - (h/2);
  720.         var cx = Math.floor((this.screenCW() / 2));
  721.         var cy = Math.floor((this.screenCH() / 2));
  722.         //var x1 = cx -  Math.floor((w / 2));
  723.         //var y1 = cy -  Math.floor((h / 2));
  724.         var x2 = cx -  Math.floor((this._SphereData[0] / 2));
  725.         var y2 = cy -  Math.floor((this._SphereData[1] / 2));       
  726.         this._lightSprite.x = cx;
  727.         this._lightSprite.y = cy;
  728.         this._blackField.x = cx;
  729.         this._blackField.y = cy;
  730.         this._blackField.bitmap.clearRect(b_x, b_y, w, h);
  731.         if( Moghunter.lightSphere_is_change === "true" ){
  732.                 if( $gamePlayer.direction() === 2 ){        //下
  733.                         this._target_rotation = 0;
  734.                 }
  735.                 if( $gamePlayer.direction() === 4 ){        //左
  736.                         this._target_rotation = Math.PI / 2;
  737.                 }
  738.                 if( $gamePlayer.direction() === 6 ){        //右
  739.                         this._target_rotation = Math.PI + Math.PI / 2;
  740.                 }
  741.                 if( $gamePlayer.direction() === 8 ){        //上
  742.                         this._target_rotation = Math.PI;
  743.                 }
  744.         }
  745.         this._Sphere.x = x2;
  746.         this._Sphere.y = y2;
  747.         if ($gameSystem._lsphereData[3]) {
  748.            this.loadSphereData();
  749.         } else {
  750.            //this.opacity = 0;       
  751.         };
  752.         this._data[0] = true;       
  753. };

  754. //==============================
  755. // * moveTo
  756. //==============================
  757. SpriteSphereLight.prototype.moveToP = function(value,real_value,speed) {
  758.         if (value == real_value) {return value};
  759.         var dnspeed = 5 + (Math.abs(value - real_value) / speed);
  760.         if (value > real_value) {value -= dnspeed;
  761.             if (value < real_value) {value = real_value};}
  762.     else if (value < real_value) {value  += dnspeed;
  763.             if (value  > real_value) {value  = real_value};               
  764.     };
  765.         return Math.floor(value);
  766. };

  767. //==============================
  768. // * update Animation
  769. //==============================
  770. SpriteSphereLight.prototype.updateAnimation = function() {
  771.    if (this.mode() === 1) {
  772.            this.updateCircle();
  773.    } else {
  774.            this._data[1] = 0;
  775.            this._data[2] = 0;
  776.    };
  777. };

  778. //==============================
  779. // * Update Ring
  780. //==============================
  781. SpriteSphereLight.prototype.updateCirclePosition = function() {
  782.           var rol_index = 1 / 160;
  783.           var si = 0;
  784.           var i = this._np[2];
  785.           this._np[2]++
  786.           if (this._np[2] > 160) {this._np[2] = 0}
  787.       var now_p = rol_index * (si - i);
  788.       var r_p = this._pi * -now_p;
  789.       this._np[0] = Math.floor(this._rol_range * Math.sin(r_p));
  790.       this._np[1] = -Math.floor(this._rol_range * Math.cos(r_p));
  791. };

  792. //==============================
  793. // * update Circle
  794. //==============================
  795. SpriteSphereLight.prototype.updateCircle = function() {
  796.    this.updateCirclePosition();
  797.    this._data[1] = this.moveToP(this._data[1],this._np[0],10);
  798.    this._data[2] = this.moveToP(this._data[2],this._np[1],10);
  799. };

  800. //==============================
  801. // * update Position
  802. //==============================
  803. SpriteSphereLight.prototype.updatePosition = function() {
  804.         this.x = this.posX();
  805.         this.y = this.posY();
  806. };

  807. //==============================
  808. // * max Opacity
  809. //==============================
  810. SpriteSphereLight.prototype.maxOpacity = function() {
  811.         return $gameSystem._lsphereData[6];
  812. };
  813.        
  814. //==============================
  815. // * Update
  816. //==============================
  817. SpriteSphereLight.prototype.update = function() {
  818.     Sprite.prototype.update.call(this);
  819.         if (this.needRefresh ()) {this.refreshRect()};
  820.         if (!this._lightSprite.bitmap) {return};
  821.         if (!this._lightSprite.bitmap.isReady()) {return};
  822.         if (this.opacity < this.maxOpacity()) {this.opacity += 5};
  823.         this.rotateByDirection();
  824.         this.updateSphere();
  825.         this.updateAnimation();
  826.     this.updatePosition();
  827. };

  828. //==============================
  829. // * need Refresh
  830. //==============================
  831. SpriteSphereLight.prototype.needRefresh = function() {
  832.      if (!this._data[0] && this._lightSprite.bitmap && this._lightSprite.bitmap.isReady()) {return true};
  833.          if ($gameSystem._lsphereData[0]) {return true};
  834.      return false;
  835. };

  836. //==============================
  837. // * rotate by direction
  838. //==============================
  839. SpriteSphereLight.prototype.rotateByDirection = function() {
  840.         if ($gameSystem._lsphereData[0]) {this.resetBitmap();return};
  841.         if (!this._Sphere.bitmap) {this.refreshBitmap()};
  842.         if (!this._Sphere.bitmap.isReady() || !this._lightSprite.bitmap.isReady()) {return};
  843.         if( Moghunter.lightSphere_is_change === "true" ){
  844.        
  845.                 var pi = Math.PI;
  846.                 if (this._direction != $gamePlayer.direction()){
  847.                         this._direction = $gamePlayer.direction();
  848.                         if( $gamePlayer.direction() === 2 ){        //下
  849.                                 this._target_rotation = 0;
  850.                         }
  851.                         if( $gamePlayer.direction() === 4 ){        //左
  852.                                 this._target_rotation = pi / 2;
  853.                         }
  854.                         if( $gamePlayer.direction() === 6 ){        //右
  855.                                 this._target_rotation = pi + pi / 2;
  856.                         }
  857.                         if( $gamePlayer.direction() === 8 ){        //上
  858.                                 this._target_rotation = pi;
  859.                         }
  860.                         var angle =  this._target_rotation - this._blackField.rotation;
  861.                         if( angle >= pi ){
  862.                                 this._rotate_dir = -1;        //顺时针
  863.                         }else if( angle <= pi*-1 ){
  864.                                 this._rotate_dir = 1;        //逆时针
  865.                         }else if( angle > 0 ){
  866.                                 this._rotate_dir = 1;
  867.                         }else{
  868.                                 this._rotate_dir = -1;
  869.                         }
  870.                 }
  871.                 if( this._target_rotation != this._blackField.rotation ){
  872.                         var angle = this._blackField.rotation - this._target_rotation;
  873.                         if( Math.abs(angle) < 0.1 ){
  874.                                 this._blackField.rotation = this._target_rotation;
  875.                                 this._lightSprite.rotation = this._target_rotation;
  876.                                 this._rotate_dir = 0;
  877.                         }else{
  878.                                 this._blackField.rotation += 0.09 * this._rotate_dir;
  879.                                 this._lightSprite.rotation += 0.09 * this._rotate_dir;
  880.                         }
  881.                         if(this._blackField.rotation >= pi*2){
  882.                                 this._blackField.rotation -= pi*2;
  883.                                 this._lightSprite.rotation -= pi*2;
  884.                         }
  885.                         if(this._blackField.rotation < 0){
  886.                                 this._blackField.rotation += pi*2;
  887.                                 this._lightSprite.rotation += pi*2;
  888.                         }
  889.                 }
  890.         }
  891. }
复制代码
梦石
0
星屑
3930
在线时间
1198 小时
注册时间
2016-8-9
回帖
2355

开拓者

发表于 2020-8-1 19:17:14 | 显示全部楼层
可以私信或者艾特大佬 工程文件里有群号 着急的话加群呼叫

点评

666  发表于 2020-8-1 21:16
草(日语意味)有道理啊我这就去翻!  发表于 2020-8-1 20:09
酸酸甜甜就④哇噢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部