设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3695|回复: 3
打印 上一主题 下一主题

[已经解决] 关于人物移动的插件命令的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
126 小时
注册时间
2016-3-24
帖子
9
跳转到指定楼层
1
发表于 2016-4-17 12:09:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  1. MovePlayer Down
  2. MovePlayer Left
  3. MovePlayer Right
  4. MovePlayer Up
复制代码
以及
TriggerButton Ok
TriggerButton Cancel
TriggerButton Dash
TriggerButton PageUp
TriggerButton PageDown
TriggerButton Left
TriggerButton Up
TriggerButton Right
TriggerButton Down
这些插件命令使用起来,确定取消按键功能是可以,但人物移动不行,代码盲求解{:2_257:}

Lv1.梦旅人

梦石
0
星屑
50
在线时间
126 小时
注册时间
2016-3-24
帖子
9
2
 楼主| 发表于 2016-4-18 13:23:33 | 只看该作者
额,是大家都不屑回答,还是都有这样的问题啊?

点评

根本不知道你在說甚麼  发表于 2016-4-18 14:48
完全不知道在说什么…… 怎么回答  发表于 2016-4-18 14:32
我猜是你说的太模糊,插件又不贴出来,就有调用指令,这样谁看得懂  发表于 2016-4-18 13:42
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
126 小时
注册时间
2016-3-24
帖子
9
3
 楼主| 发表于 2016-4-21 00:57:20 | 只看该作者
本帖最后由 十分绅士 于 2016-4-22 00:35 编辑

额,没看到点评以为都没人回复。
  1. //=============================================================================
  2. // Yanfly Engine Plugins - Picture Common Events
  3. // YEP_PictureCommonEvents.js
  4. //=============================================================================

  5. var Imported = Imported || {};
  6. Imported.YEP_Template = true;

  7. var Yanfly = Yanfly || {};
  8. Yanfly.PCE = Yanfly.PCE || {};

  9. //=============================================================================
  10. /*:
  11. * @plugindesc v1.00 Causes common events to run when certain pictures
  12. * are clicked while on the map.
  13. * @author Yanfly Engine Plugins
  14. *
  15. * @param ---General---
  16. * @default
  17. *
  18. * @param Enable Touch Move
  19. * @desc Is touch movement enabled by default?
  20. * NO - false   YES - true   Default: true
  21. * @default true
  22. *
  23. * @param Hide Message
  24. * @desc Hide Pictures with common events during messages?
  25. * NO - false   YES - true   Default: true
  26. * @default true
  27. *
  28. * @param ---Picture 1---
  29. * @default
  30. *
  31. * @param Picture 1 Click
  32. * @desc Runs this common event when a picture with this ID is
  33. * clicked. Leave this value at 0 for no common event.
  34. * @default 0
  35. *
  36. * @param Picture 1 Repeat
  37. * @desc Runs this common event when a picture with this ID is held
  38. * every 6 frames. Leave this value at 0 for no common event.
  39. * @default 0
  40. *
  41. * @param Picture 1 Hold
  42. * @desc Runs this common event when a picture with this ID is
  43. * clicked and held. Leave this value at 0 for no common event.
  44. * @default 0
  45. *
  46. * @param Picture 1 Release
  47. * @desc Runs this common event when a picture with this ID is
  48. * released. Leave this value at 0 for no common event.
  49. * @default 0
  50. *
  51. * @param ---Picture 2---
  52. * @default
  53. *
  54. * @param Picture 2 Click
  55. * @desc Runs this common event when a picture with this ID is
  56. * clicked. Leave this value at 0 for no common event.
  57. * @default 0
  58. *
  59. * @param Picture 2 Repeat
  60. * @desc Runs this common event when a picture with this ID is held
  61. * every 6 frames. Leave this value at 0 for no common event.
  62. * @default 0
  63. *
  64. * @param Picture 2 Hold
  65. * @desc Runs this common event when a picture with this ID is
  66. * clicked and held. Leave this value at 0 for no common event.
  67. * @default 0
  68. *
  69. * @param Picture 2 Release
  70. * @desc Runs this common event when a picture with this ID is
  71. * released. Leave this value at 0 for no common event.
  72. * @default 0
  73. *
  74. * @param ---Picture 3---
  75. * @default
  76. *
  77. * @param Picture 3 Click
  78. * @desc Runs this common event when a picture with this ID is
  79. * clicked. Leave this value at 0 for no common event.
  80. * @default 0
  81. *
  82. * @param Picture 3 Repeat
  83. * @desc Runs this common event when a picture with this ID is held
  84. * every 6 frames. Leave this value at 0 for no common event.
  85. * @default 0
  86. *
  87. * @param Picture 3 Hold
  88. * @desc Runs this common event when a picture with this ID is
  89. * clicked and held. Leave this value at 0 for no common event.
  90. * @default 0
  91. *
  92. * @param Picture 3 Release
  93. * @desc Runs this common event when a picture with this ID is
  94. * released. Leave this value at 0 for no common event.
  95. * @default 0
  96. *
  97. * @param ---Picture 4---
  98. * @default
  99. *
  100. * @param Picture 4 Click
  101. * @desc Runs this common event when a picture with this ID is
  102. * clicked. Leave this value at 0 for no common event.
  103. * @default 0
  104. *
  105. * @param Picture 4 Repeat
  106. * @desc Runs this common event when a picture with this ID is held
  107. * every 6 frames. Leave this value at 0 for no common event.
  108. * @default 0
  109. *
  110. * @param Picture 4 Hold
  111. * @desc Runs this common event when a picture with this ID is
  112. * clicked and held. Leave this value at 0 for no common event.
  113. * @default 0
  114. *
  115. * @param Picture 4 Release
  116. * @desc Runs this common event when a picture with this ID is
  117. * released. Leave this value at 0 for no common event.
  118. * @default 0
  119. *
  120. * @param ---Picture 5---
  121. * @default
  122. *
  123. * @param Picture 5 Click
  124. * @desc Runs this common event when a picture with this ID is
  125. * clicked. Leave this value at 0 for no common event.
  126. * @default 0
  127. *
  128. * @param Picture 5 Repeat
  129. * @desc Runs this common event when a picture with this ID is held
  130. * every 6 frames. Leave this value at 0 for no common event.
  131. * @default 0
  132. *
  133. * @param Picture 5 Hold
  134. * @desc Runs this common event when a picture with this ID is
  135. * clicked and held. Leave this value at 0 for no common event.
  136. * @default 0
  137. *
  138. * @param Picture 5 Release
  139. * @desc Runs this common event when a picture with this ID is
  140. * released. Leave this value at 0 for no common event.
  141. * @default 0
  142. *
  143. * @param ---Picture 6---
  144. * @default
  145. *
  146. * @param Picture 6 Click
  147. * @desc Runs this common event when a picture with this ID is
  148. * clicked. Leave this value at 0 for no common event.
  149. * @default 0
  150. *
  151. * @param Picture 6 Repeat
  152. * @desc Runs this common event when a picture with this ID is held
  153. * every 6 frames. Leave this value at 0 for no common event.
  154. * @default 0
  155. *
  156. * @param Picture 6 Hold
  157. * @desc Runs this common event when a picture with this ID is
  158. * clicked and held. Leave this value at 0 for no common event.
  159. * @default 0
  160. *
  161. * @param Picture 6 Release
  162. * @desc Runs this common event when a picture with this ID is
  163. * released. Leave this value at 0 for no common event.
  164. * @default 0
  165. *
  166. * @param ---Picture 7---
  167. * @default
  168. *
  169. * @param Picture 7 Click
  170. * @desc Runs this common event when a picture with this ID is
  171. * clicked. Leave this value at 0 for no common event.
  172. * @default 0
  173. *
  174. * @param Picture 7 Repeat
  175. * @desc Runs this common event when a picture with this ID is held
  176. * every 6 frames. Leave this value at 0 for no common event.
  177. * @default 0
  178. *
  179. * @param Picture 7 Hold
  180. * @desc Runs this common event when a picture with this ID is
  181. * clicked and held. Leave this value at 0 for no common event.
  182. * @default 0
  183. *
  184. * @param Picture 7 Release
  185. * @desc Runs this common event when a picture with this ID is
  186. * released. Leave this value at 0 for no common event.
  187. * @default 0
  188. *
  189. * @param ---Picture 8---
  190. * @default
  191. *
  192. * @param Picture 8 Click
  193. * @desc Runs this common event when a picture with this ID is
  194. * clicked. Leave this value at 0 for no common event.
  195. * @default 0
  196. *
  197. * @param Picture 8 Repeat
  198. * @desc Runs this common event when a picture with this ID is held
  199. * every 6 frames. Leave this value at 0 for no common event.
  200. * @default 0
  201. *
  202. * @param Picture 8 Hold
  203. * @desc Runs this common event when a picture with this ID is
  204. * clicked and held. Leave this value at 0 for no common event.
  205. * @default 0
  206. *
  207. * @param Picture 8 Release
  208. * @desc Runs this common event when a picture with this ID is
  209. * released. Leave this value at 0 for no common event.
  210. * @default 0
  211. *
  212. * @param ---Picture 9---
  213. * @default
  214. *
  215. * @param Picture 9 Click
  216. * @desc Runs this common event when a picture with this ID is
  217. * clicked. Leave this value at 0 for no common event.
  218. * @default 0
  219. *
  220. * @param Picture 9 Repeat
  221. * @desc Runs this common event when a picture with this ID is held
  222. * every 6 frames. Leave this value at 0 for no common event.
  223. * @default 0
  224. *
  225. * @param Picture 9 Hold
  226. * @desc Runs this common event when a picture with this ID is
  227. * clicked and held. Leave this value at 0 for no common event.
  228. * @default 0
  229. *
  230. * @param Picture 9 Release
  231. * @desc Runs this common event when a picture with this ID is
  232. * released. Leave this value at 0 for no common event.
  233. * @default 0
  234. *
  235. * @param ---Picture 10---
  236. * @default
  237. *
  238. * @param Picture 10 Click
  239. * @desc Runs this common event when a picture with this ID is
  240. * clicked. Leave this value at 0 for no common event.
  241. * @default 0
  242. *
  243. * @param Picture 10 Repeat
  244. * @desc Runs this common event when a picture with this ID is held
  245. * every 6 frames. Leave this value at 0 for no common event.
  246. * @default 0
  247. *
  248. * @param Picture 10 Hold
  249. * @desc Runs this common event when a picture with this ID is
  250. * clicked and held. Leave this value at 0 for no common event.
  251. * @default 0
  252. *
  253. * @param Picture 10 Release
  254. * @desc Runs this common event when a picture with this ID is
  255. * released. Leave this value at 0 for no common event.
  256. * @default 0
  257. *
  258. * @help
  259. * ============================================================================
  260. * Introduction
  261. * ============================================================================
  262. *
  263. * Pictures can function as something other than just a visual for your game.
  264. * They can sometimes serve as UI elements or more! However, what they don't
  265. * have the ability to inherently do is to call upon common events when clicked
  266. * on by the mouse. With this plugin, the pictures bound to a common event will
  267. * become usable when clicked or touched!
  268. *
  269. * ============================================================================
  270. * Instructions
  271. * ============================================================================
  272. *
  273. * In the plugin's parameters, you can set common event ID's to each picture ID
  274. * listed from 1 to 100 (max number of pictures used in RPG Maker MV is 100).
  275. * If the picture is has even a value of 1 opacity, that picture can be used
  276. * for a common event. There are four condition types that can be bound with
  277. * the common events:
  278. *
  279. * ---
  280. *
  281. * - CLICK -
  282. * If the picture is clicked upon, this will prompt the common event to trigger
  283. * if the common event value listed is above 0. This will trigger only once
  284. * until the player releases the mouse (or stops touching the screen).
  285. *
  286. * - REPEAT -
  287. * If the mouse is clicked and then held (or if the touch screen is pushed and
  288. * held), as long as the mouse is above the picture area and the common event
  289. * value listed is above 0, then this will trigger once every 6 frames until
  290. * the player releases the mouse (or stops touching the screen) or moves the
  291. * mouse outside of the picture boundaries.
  292. *
  293. * - HOLD -
  294. * If the mouse is clicked and then held (or if the touch screen is pushed and
  295. * held), as long as the mouse is above the picture area and the common event
  296. * value listed is above 0, then this will trigger every frame until the player
  297. * releases the mouse (or stops touching the screen) or moves the mouse outside
  298. * of the picture boundaries.
  299. *
  300. * - RELEASE -
  301. * Upon releasing the clicked mouse (or the moment the player stops touching
  302. * the screen) and releases the mouse above this picture and if the picture's
  303. * common event value listed is above 0, then this will trigger upon release.
  304. *
  305. * ---
  306. *
  307. * Note that there are some behavioral changes in regards to pictures bound to
  308. * that of common events. Any picture that's bound to a common event will be
  309. * separate from the map's spriteset, and instead, bound to the scene. This is
  310. * so that in the event the screen is scrolled, zoomed in, shakes, etc., it
  311. * will NOT affect the bound pictures.
  312. *
  313. * This is because the pictures are generally to be used as UI elements and UI
  314. * elements best work under the practice that they do not change position.
  315. *
  316. * ============================================================================
  317. * Plugin Commands
  318. * ============================================================================
  319. *
  320. * The following are some plugin commands you can use should you want to add a
  321. * bit of control with the Picture Common Events.
  322. *
  323. * Plugin Command
  324. *
  325. *   EnableTouchMove
  326. *   DisableTouchMove
  327. *   - Allows the player to press a destination on the screen and move there or
  328. *   disables the player from using touch movement.
  329. *   
  330. *   HidePictureCommonEvents
  331. *   ShowPictureCommonEvents
  332. *   - Manually hide all pictures bound to common events or show them. If shown
  333. *   then pictures will return to their previous opacity value. Hidden pictures
  334. *   cannot be triggered to activate common events.
  335. *
  336. *   MovePlayer Down
  337. *   MovePlayer Left
  338. *   MovePlayer Right
  339. *   MovePlayer Up
  340. *   - Will cause the player character to move as if moving by using a 4-dir
  341. *   input (either via keyboard or controller). This is best used with 'Press'.
  342. *
  343. *   TriggerButton Ok
  344. *   TriggerButton Cancel
  345. *   TriggerButton Dash
  346. *   TriggerButton PageUp
  347. *   TriggerButton PageDown
  348. *   TriggerButton Left
  349. *   TriggerButton Up
  350. *   TriggerButton Right
  351. *   TriggerButton Down
  352. *   - This will cause the game to simulate triggering the button command of
  353. *   one of those original functions even if there is a common event bound to
  354. *   all of the keys of that original function.
  355. */
  356. //=============================================================================

  357. //=============================================================================
  358. // Parameter Variables
  359. //=============================================================================

  360. Yanfly.makePictureCommonEventSettings = function(a, b) {
  361.     Yanfly.PCE.Trigger = [null];
  362.     Yanfly.PCE.Repeated = [null];
  363.     Yanfly.PCE.Pressed = [null];
  364.     Yanfly.PCE.Released = [null];
  365.     for (var i = a; i < b + 1; ++i) {
  366.       var param = 'Picture ' + i + ' Click';
  367.       var value = Number(Yanfly.Parameters[param]);
  368.       Yanfly.PCE.Trigger.push(value);
  369.       var param = 'Picture ' + i + ' Repeat';
  370.       var value = Number(Yanfly.Parameters[param]);
  371.       Yanfly.PCE.Repeated.push(value);
  372.       var param = 'Picture ' + i + ' Hold';
  373.       var value = Number(Yanfly.Parameters[param]);
  374.       Yanfly.PCE.Pressed.push(value);
  375.       var param = 'Picture ' + i + ' Release';
  376.       var value = Number(Yanfly.Parameters[param]);
  377.       Yanfly.PCE.Released.push(value);
  378.     }
  379. };

  380. Yanfly.Parameters = PluginManager.parameters('YEP_PictureCommonEvents');
  381. Yanfly.Param = Yanfly.Param || {};

  382. Yanfly.Param.PCEMove = eval(String(Yanfly.Parameters['Enable Touch Move']));
  383. Yanfly.Param.PCEHideMsg = eval(String(Yanfly.Parameters['Hide Message']));

  384. Yanfly.makePictureCommonEventSettings(1, 100);

  385. //=============================================================================
  386. // Game_System
  387. //=============================================================================

  388. Yanfly.PCE.Game_System_initialize = Game_System.prototype.initialize;
  389. Game_System.prototype.initialize = function() {
  390.     Yanfly.PCE.Game_System_initialize.call(this);
  391.     this.initPCESettings();
  392. };

  393. Game_System.prototype.initPCESettings = function() {
  394.     this._touchMovement = Yanfly.Param.PCEMove;
  395.     this._hidePceMsg = Yanfly.Param.PCEHideMsg;
  396.     this._hidePceAll = false;
  397. };

  398. Game_System.prototype.isTouchMoveEnabled = function() {
  399.     if (this._touchMovement === undefined) this.initPCESettings();
  400.     return this._touchMovement;
  401. };

  402. Game_System.prototype.setTouchMoveEnabled = function(value) {
  403.     if (this._touchMovement === undefined) this.initPCESettings();
  404.     this._touchMovement = value;
  405. };

  406. Game_System.prototype.isPictureHiddenDuringMessage = function() {
  407.     if (this._hidePceMsg === undefined) this.initPCESettings();
  408.     return this._hidePceMsg;
  409. };

  410. Game_System.prototype.setPictureHiddenDuringMessage = function(value) {
  411.     if (this._hidePceMsg === undefined) this.initPCESettings();
  412.     this._hidePceMsg = value;
  413. };

  414. Game_System.prototype.isPictureHidden = function() {
  415.     if (this._hidePceAll === undefined) this.initPCESettings();
  416.     return this._hidePceAll;
  417. };

  418. Game_System.prototype.setPictureHidden = function(value) {
  419.     if (this._hidePceAll === undefined) this.initPCESettings();
  420.     this._hidePceAll = value;
  421. };

  422. //=============================================================================
  423. // Game_Interpreter
  424. //=============================================================================

  425. Yanfly.PCE.Game_Interpreter_pluginCommand =
  426.     Game_Interpreter.prototype.pluginCommand;
  427. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  428.     Yanfly.PCE.Game_Interpreter_pluginCommand.call(this, command, args);
  429.     if (command === 'EnableTouchMove') {
  430.       $gameSystem.setTouchMoveEnabled(true);
  431.     } else if (command === 'DisableTouchMove') {
  432.       $gameSystem.setTouchMoveEnabled(false);
  433.     } else if (command === 'MovePlayer') {
  434.       this.pictureCommonEventsMove(args);
  435.     } else if (command === 'HidePictureCommonEvents') {
  436.       $gameSystem.setPictureHidden(true);
  437.     } else if (command === 'ShowPictureCommonEvents') {
  438.       $gameSystem.setPictureHidden(false);
  439.     } else if (command === 'TriggerButton') {
  440.       this.triggerButton(args)
  441.     }
  442. };

  443. Game_Interpreter.prototype.pictureCommonEventsMove = function(args) {
  444.     var dir = args[0];
  445.     if (dir.match(/down/i)) {
  446.       $gamePlayer.moveByPictureCommonEvent(2);
  447.     } else if (dir.match(/left/i)) {
  448.       $gamePlayer.moveByPictureCommonEvent(4);
  449.     } else if (dir.match(/right/i)) {
  450.       $gamePlayer.moveByPictureCommonEvent(6);
  451.     } else if (dir.match(/up/i)) {
  452.       $gamePlayer.moveByPictureCommonEvent(8);
  453.     }
  454. };

  455. Game_Interpreter.prototype.triggerButton = function(args) {
  456.   if (!args) return;
  457.   var button = args[0].toLowerCase();
  458.   if (button === 'cancel') button = 'escape';
  459.   if (button === 'dash') button = 'shift';
  460.   Input._latestButton = button;
  461.   Input._pressedTime = 0;
  462. };

  463. //=============================================================================
  464. // Game_Player
  465. //=============================================================================

  466. Game_Player.prototype.moveByPictureCommonEvent = function(direction) {
  467.     if (!this.isMoving() && this.canMove() && direction > 0) {
  468.       Input._dir4 = direction;
  469.     }
  470. };

  471. //=============================================================================
  472. // Game_Map
  473. //=============================================================================

  474. Yanfly.PCE.Game_Map_isEventRunning = Game_Map.prototype.isEventRunning;
  475. Game_Map.prototype.isEventRunning = function() {
  476.     if ($gameTemp._commonEventId > 0) return true;
  477.     return Yanfly.PCE.Game_Map_isEventRunning.call(this);
  478. };

  479. //=============================================================================
  480. // Game_Picture
  481. //=============================================================================

  482. Game_Picture.prototype.isTriggered = function() {
  483.     if (!SceneManager._scene instanceof Scene_Map) return false;
  484.     if (this.opacity() <= 0) return false;
  485.     var sp = SceneManager._scene.getPictureSprite(this);
  486.     if (!sp) return false;
  487.     var mx = this.getLocalTouchInputX();
  488.     var my = this.getLocalTouchInputY();
  489.     //console.log('click: ' + mx + ', ' + my);
  490.     var rect = this.getSpriteRect(sp);
  491.     return mx >= rect.x &&
  492.            my >= rect.y &&
  493.            mx < (rect.x + rect.width) &&
  494.            my < (rect.y + rect.height);
  495. };

  496. Game_Picture.prototype.pictureId = function() {
  497.     return $gameScreen._pictures.indexOf(this);
  498. };

  499. Game_Picture.prototype.getLocalTouchInputX = function() {
  500.     value = TouchInput.x;
  501.     return value;
  502. };

  503. Game_Picture.prototype.getLocalTouchInputY = function() {
  504.     value = TouchInput.y;
  505.     return value;
  506. };

  507. Game_Picture.prototype.getSpriteRect = function(sp) {
  508.     var width = sp.width * Math.abs(sp.scale.x);
  509.     var height = sp.height * Math.abs(sp.scale.y);
  510.     var x = sp.x - (sp.anchor.x * width);
  511.     var y = sp.y - (sp.anchor.y * height);
  512.     if (sp.anchor.x === 0 && sp.scale.x < 0) x += sp.width * sp.scale.x;
  513.     if (sp.anchor.y === 0 && sp.scale.y < 0) y += sp.height * sp.scale.y;
  514.     //console.log('rect: ' + x + ', ' + y + ', ' + width + ', ' + height);
  515.     return new Rectangle(x, y, width, height);
  516. };

  517. Game_Picture.prototype.isRelatedPictureCommonEvent = function() {
  518.     $gameTemp._pictureCommonEvents = $gameTemp._pictureCommonEvents || [];
  519.     if ($gameTemp._pictureCommonEvents[this.pictureId()]) {
  520.       return $gameTemp._pictureCommonEvents[this.pictureId()];
  521.     }
  522.     if (Yanfly.PCE.Trigger[this.pictureId()]) {
  523.       $gameTemp._pictureCommonEvents[this.pictureId()] = true;
  524.     } else if (Yanfly.PCE.Repeated[this.pictureId()]) {
  525.       $gameTemp._pictureCommonEvents[this.pictureId()] = true;
  526.     } else if (Yanfly.PCE.Pressed[this.pictureId()]) {
  527.       $gameTemp._pictureCommonEvents[this.pictureId()] = true;
  528.     } else if (Yanfly.PCE.Released[this.pictureId()]) {
  529.       $gameTemp._pictureCommonEvents[this.pictureId()] = true;
  530.     } else {
  531.       $gameTemp._pictureCommonEvents[this.pictureId()] = false;
  532.     }
  533.     return $gameTemp._pictureCommonEvents[this.pictureId()];
  534. };

  535. Yanfly.PCE.Game_Picture_opacity = Game_Picture.prototype.opacity;
  536. Game_Picture.prototype.opacity = function() {
  537.     if ($gameMessage.isBusy() && this.isRelatedPictureCommonEvent()) {
  538.       if ($gameSystem.isPictureHidden()) return 0;
  539.       if ($gameSystem.isPictureHiddenDuringMessage()) return 0;
  540.     }
  541.     return Yanfly.PCE.Game_Picture_opacity.call(this);
  542. };

  543. //=============================================================================
  544. // Spriteset_Base
  545. //=============================================================================

  546. Yanfly.PCE.Spriteset_Base_createPictures =
  547.     Spriteset_Base.prototype.createPictures;
  548. Spriteset_Base.prototype.createPictures = function() {
  549.     var scene = SceneManager._scene;
  550.     if (scene instanceof Scene_Map) {
  551.       this.createSceneMapPictures();
  552.     } else {
  553.       Yanfly.PCE.Spriteset_Base_createPictures.call(this);
  554.     }
  555. };

  556. Spriteset_Base.prototype.createSceneMapPictures = function() {
  557.     var width = Graphics.boxWidth;
  558.     var height = Graphics.boxHeight;
  559.     var x = (Graphics.width - width) / 2;
  560.     var y = (Graphics.height - height) / 2;
  561.     this._pictureContainer = new Sprite();
  562.     this._pictureContainer.setFrame(x, y, width, height);
  563.     for (var i = 1; i <= $gameScreen.maxPictures(); i++) {
  564.       var picture = new Sprite_Picture(i);
  565.       if (picture.isRelatedPictureCommonEvent()) {
  566.         SceneManager._scene.addPictureCommonEvent(picture);
  567.       } else {
  568.         this._pictureContainer.addChild(picture);
  569.       }
  570.     }
  571.     this.addChild(this._pictureContainer);
  572. };

  573. //=============================================================================
  574. // Sprite_Picture
  575. //=============================================================================

  576. Yanfly.PCE.Sprite_Picture_loadBitmap = Sprite_Picture.prototype.loadBitmap;
  577. Sprite_Picture.prototype.loadBitmap = function() {
  578.     Yanfly.PCE.Sprite_Picture_loadBitmap.call(this);
  579.     SceneManager._scene.bindPictureSprite(this._pictureId, this);
  580. };

  581. Sprite_Picture.prototype.isRelatedPictureCommonEvent = function() {
  582.     if (Yanfly.PCE.Trigger[this._pictureId]) return true;
  583.     if (Yanfly.PCE.Repeated[this._pictureId]) return true;
  584.     if (Yanfly.PCE.Pressed[this._pictureId]) return true;
  585.     if (Yanfly.PCE.Released[this._pictureId]) return true;
  586.     return false;
  587. };

  588. //=============================================================================
  589. // Scene_Base
  590. //=============================================================================

  591. Scene_Base.prototype.bindPictureSprite = function(picture, sprite) {
  592. };

  593. //=============================================================================
  594. // Scene_Map
  595. //=============================================================================

  596. Yanfly.PCE.Scene_Map_createSpriteset = Scene_Map.prototype.createSpriteset;
  597. Scene_Map.prototype.createSpriteset = function() {
  598.     this._pictureCommonEvents = [];
  599.     Yanfly.PCE.Scene_Map_createSpriteset.call(this);
  600.     this.addPictureCommonEventChildren();
  601. };

  602. Scene_Map.prototype.addPictureCommonEvent = function(picture) {
  603.     this._pictureCommonEvents.push(picture);
  604. };

  605. Scene_Map.prototype.addPictureCommonEventChildren = function() {
  606.     var length = this._pictureCommonEvents.length;
  607.     for (var i = 0; i < length; ++i) {
  608.       var picture = this._pictureCommonEvents[i];
  609.       this.addChild(picture);
  610.     }
  611. };

  612. Scene_Map.prototype.bindPictureSprite = function(picture, sprite) {
  613.     this._pictureCommonEventsBind = this._pictureCommonEventsBind || {};
  614.     this._pictureCommonEventsBind[picture] = sprite;
  615. };

  616. Scene_Map.prototype.getPictureSprite = function(picture) {
  617.     this._pictureCommonEventsBind = this._pictureCommonEventsBind || {};
  618.     return this._pictureCommonEventsBind[picture.pictureId()];
  619. };

  620. Yanfly.PCE.Scene_Map_processMapTouch = Scene_Map.prototype.processMapTouch;
  621. Scene_Map.prototype.processMapTouch = function() {
  622.     this.updatePictureEvents();
  623.     if (this.allowProcessMapTouch()) {
  624.       Yanfly.PCE.Scene_Map_processMapTouch.call(this);
  625.     }
  626. };

  627. Scene_Map.prototype.allowProcessMapTouch = function() {
  628.     if (SceneManager.isSceneChanging()) return false;
  629.     if ($gameMap.isEventRunning()) return false;
  630.     if ($gameTemp.isCommonEventReserved()) return false;
  631.     return $gameSystem.isTouchMoveEnabled();
  632. };

  633. Scene_Map.prototype.updatePictureEvents = function() {
  634.     if (TouchInput.isTriggered()) {
  635.       this.updatePictureEventCheck(Yanfly.PCE.Trigger);
  636.     }
  637.     if (TouchInput.isRepeated()) {
  638.       this.updatePictureEventCheck(Yanfly.PCE.Repeated);
  639.     }
  640.     if (TouchInput.isPressed()) {
  641.       this.updatePictureEventCheck(Yanfly.PCE.Pressed);
  642.     }
  643.     if (TouchInput.isReleased()) {
  644.       this.updatePictureEventCheck(Yanfly.PCE.Released);
  645.     }
  646. };

  647. Scene_Map.prototype.updatePictureEventCheck = function(check) {
  648.     if (SceneManager.isSceneChanging()) return;
  649.     if ($gameMap.isEventRunning()) return;
  650.     var picture = this.getTriggeredPictureCommonEvent(check);
  651.     if (!picture) return;
  652.     $gameTemp.reserveCommonEvent(check[picture.pictureId()]);
  653.     $gameTemp.clearDestination();
  654. };

  655. Scene_Map.prototype.getTriggeredPictureCommonEvent = function(check) {
  656.     var length = check.length;
  657.     var lastpicture = null;
  658.     for (var i = 1; i < length; ++i) {
  659.       var picture = $gameScreen.picture(i);
  660.       if (!check[i]) continue;
  661.       if (!picture) continue;
  662.       var rect = picture.getSpriteRect(this.getPictureSprite(picture));
  663.       lastpicture = picture;
  664.       if (picture.isTriggered()) return picture;
  665.     }
  666.     return null;
  667. };

  668. //=============================================================================
  669. // End of File
  670. //=============================================================================
复制代码
是Yanfly的这个图片绑定公共事件的插件,做一个人物移动的公共事件,根据帮助里的那几个插件命令,想做物移动的触屏按键。
然而人物移动的都不行,为了验证插件生效,还是试了些其他的事件效果,证明是没有问题的,TriggerButton Cancel 调用会呼出主菜单,因此是可验证,证明是可以的,但是人物移动的插件命令没有效果,也找不到问题那里
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-17 00:46

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表