查看: 4725|回复: 2

[有事请教] 我想知道脚本怎么左右翻转图片?

[复制链接]
梦石
0
星屑
2044
在线时间
758 小时
注册时间
2013-7-3
回帖
117
发表于 2019-3-8 21:35:59 | 显示全部楼层 |阅读模式
悬赏3星屑未解决
左右反转图片各位大佬是怎么实现的?提问区居然没人问过这个问题,然后我网上找到这个标题插件,一阵研究之后果然没找着这段代码,额大佬们帮帮小弟呀
  1. //=============================================================================
  2. // MOG_TitleHimawari.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc (v1.0) 标题界面显示角色动画场景.
  6. * @author Moghunter
  7. *
  8. * @param Char Number
  9. * @desc Definição da quantidade de imagens dos personagens.
  10. * @default 4
  11. *  
  12. * @param Char X-Axis
  13. * @desc Definição X-axis da imagem dos personagens.
  14. * @default 0
  15. *
  16. * @param Char Y-Axis
  17. * @desc Definição Y-axis da imagem dos personagens.
  18. * @default 0
  19. *
  20. * @param Flower X-Axis
  21. * @desc Definição X-axis da imagem das flores.
  22. * @default 0
  23. *
  24. * @param Flower Y-Axis
  25. * @desc Definição Y-axis da imagem das flores.
  26. * @default 0
  27. *
  28. * @param Rotation
  29. * @desc Ativar rotação.
  30. * @default true
  31. *
  32. * @param Rotation Time
  33. * @desc Tempo para ativar a rotação.
  34. * @default 300
  35. *
  36. * @help  
  37. * =============================================================================
  38. * +++ MOG - Title Screen Himawari (v1.0) +++
  39. * By Moghunter
  40. * [url]https://atelierrgss.wordpress.com/[/url]
  41. * =============================================================================
  42. * 角色动画场景
  43. * =============================================================================
  44. * 角色的图像必须保存在文件夹 /img/titles1/
  45. *
  46. * 人物图像的命名应遵循以下形式
  47. *
  48. * Char_ +ID.png
  49. *
  50. * Char_1.png
  51. * Char_2.png
  52. * Char_3.png
  53. * ...
  54. * 需要/img/titles1/Background_X.png
  55. * 需要/img/titles1/Flower.png
  56. * 建议使用屏幕高度的字符图像
  57. * (624 像素)
  58. *
  59. */

  60. //=============================================================================
  61. // ** PLUGIN PARAMETERS
  62. //=============================================================================
  63.   var Imported = Imported || {};
  64.   Imported.MOG_TitleHimawari = true;
  65.   var Moghunter = Moghunter || {};

  66.    Moghunter.parameters = PluginManager.parameters('MOG_TitleHimawari');
  67.     Moghunter.himawari_char_number = Number(Moghunter.parameters['Char Number'] || 4);
  68.     Moghunter.himawari_char_x = Number(Moghunter.parameters['Char X-Axis'] || 0);
  69.         Moghunter.himawari_char_y = Number(Moghunter.parameters['Char Y-Axis'] || 0);
  70.     Moghunter.himawari_flower_x = Number(Moghunter.parameters['Flower X-Axis'] || 0);
  71.         Moghunter.himawari_flower_y = Number(Moghunter.parameters['Flower Y-Axis'] || 0);       
  72.     Moghunter.himawari_rotation = String(Moghunter.parameters['Rotation'] || "true");
  73.     Moghunter.himawari_rotation_duration = Number(Moghunter.parameters['Rotation Time'] || 300);


  74. //=============================================================================
  75. // ** Scene Title
  76. //=============================================================================       

  77. //==============================
  78. // * Initialize
  79. //==============================
  80. var _alia_mog_himawari_initialize = Scene_Title.prototype.initialize;
  81. Scene_Title.prototype.initialize = function() {       
  82.     _alia_mog_himawari_initialize.call(this);
  83.         this._scenarioField = new Sprite();
  84.         this._scenarioField.x = Graphics.boxWidth / 2;
  85.         this._scenarioField.y = Graphics.boxHeight / 2;
  86.         this._scenarioField.scale.x = 1.00;
  87.         this._scenarioField.scale.y = this._scenarioField.scale.x;
  88.         this.addChild(this._scenarioField);
  89.         this._duration = [[],[],[]];
  90.         this._side = [0,0,0];
  91.         this._rt = [0,0,0];
  92.         this._zt = [1.00,0,0];
  93.         this._char_number = Math.min(Math.max(Moghunter.himawari_char_number,1),999);
  94.         this._char_number += 1;
  95.         this._rotation = false;
  96.         this._rotation_time = Math.min(Math.max(Moghunter.himawari_rotation_duration,60),999);
  97.         if (String(Moghunter.himawari_rotation) === "true") {this._rotation = true};
  98.         this._firstRefresh = true;
  99.         this.loadImages();       
  100. };

  101. //==============================
  102. // * Load Images
  103. //==============================
  104. Scene_Title.prototype.loadImages = function() {
  105.         this._back_img = [ImageManager.loadTitle1("Background_1"),
  106.                            ImageManager.loadTitle1("Background_2"),
  107.                                           ];
  108.         this._flower_img = ImageManager.loadTitle1("Flower");
  109.         this._char_img = [];
  110.         for (var i = 1; i < this._char_number ; i++) {
  111.              this._char_img.push(ImageManager.loadTitle1("Char_" + i));
  112.         };
  113. };

  114. //==============================
  115. // * Create Background
  116. //==============================
  117. var _alias_mog_himawari_createBackground = Scene_Title.prototype.createBackground;
  118. Scene_Title.prototype.createBackground = function() {       
  119.     _alias_mog_himawari_createBackground.call(this);
  120.         this.removeChild(this._backSprite1);
  121.         this.removeChild(this._backSprite2);
  122.         this.createHimariSprites();
  123. };

  124. //==============================
  125. // * Create Himawari Sprites
  126. //==============================
  127. Scene_Title.prototype.createHimariSprites = function() {
  128.         this.createHbackground();
  129.         this.createFlowers();
  130.         this.createCharacters();
  131. };

  132. //==============================
  133. // * Create Background
  134. //==============================
  135. Scene_Title.prototype.createHbackground = function() {
  136.         var width = Graphics.boxWidth * 2;
  137.         var height = Graphics.boxHeight * 2;
  138.         this._background = [];
  139.         for (var i = 0; i < 2 ; i++) {
  140.                  this._background[i] = new TilingSprite(this._back_img[i]);
  141.                  this._background[i].move(0,0, width, height);
  142.              this._background[i].anchor.x = 0.5;
  143.                  this._background[i].anchor.y = 0.5;
  144.                  this._scenarioField.addChild(this._background[i]);
  145.         }
  146.         this._background[1].y = Graphics.boxHeight / 2;
  147.         this._background[1].scale.x = 1.5;
  148.         this._background[1].scale.y = 1.5;
  149. };

  150. //==============================
  151. // * Sp D
  152. //==============================
  153. Scene_Title.prototype.sp_d = function() {
  154.         return 120;
  155. };

  156. //==============================
  157. // * Obj Zoom Speed
  158. //==============================
  159. Scene_Title.prototype.objZoomSpeed = function() {
  160.         return 0.003;
  161. };

  162. //==============================
  163. // * Rt Time
  164. //==============================
  165. Scene_Title.prototype.rt_time = function() {
  166.         return this._rotation_time;
  167. };

  168. //==============================
  169. // * Rotation Speed
  170. //==============================
  171. Scene_Title.prototype.rotationSpeed = function() {
  172.         return 0.004;
  173. };

  174. //==============================
  175. // * Create Flowers
  176. //==============================
  177. Scene_Title.prototype.createFlowers = function() {
  178.         this._flowers = [];
  179.         for (var i = 0; i < 6 ; i++) {
  180.                  this._flowers[i] = new Sprite(this._flower_img);
  181.                  this._flowers[i].anchor.x = 0.5;
  182.                  this._flowers[i].anchor.y = 1;
  183.                  this._flowers[i].y = Graphics.boxHeight / 2;
  184.                  this._duration[0][i] = this.sp_d() * i;
  185.         };
  186. };

  187. //==============================
  188. // * Create Characters
  189. //==============================
  190. Scene_Title.prototype.createCharacters = function() {
  191.         this._char_index = 0;
  192.         this._chars = [];
  193.         for (var i = 0; i < 6 ; i++) {
  194.                  this._chars[i] = new Sprite();
  195.                  this._chars[i].anchor.x = 0.5;
  196.              this._chars[i].anchor.y = 1;
  197.                  this._chars[i].y = Graphics.boxHeight / 2;
  198.                  this._duration[1][i] = (this.sp_d() / 2) + (this.sp_d() * i);
  199.         };
  200. };

  201. //==============================
  202. // * First Refresh
  203. //==============================
  204. Scene_Title.prototype.firstRefresh = function() {
  205.          this._firstRefresh = false;
  206.          for (var i = 0; i < this._char_img.length  ; i++) {       
  207.         this._chars[0].bitmap = this._char_img[i];
  208.          };
  209.          this._background[1].y = Graphics.boxHeight / 2 + (this._back_img[1].height * 18 / 100);
  210. };

  211. //==============================
  212. // * Refresh Characters
  213. //==============================
  214. Scene_Title.prototype.update_rotation = function(sprite) {
  215.         if (this._rt[0] === this._scenarioField.rotation) {this._rt[1] += 1};
  216.         if (this._rt[1] >= this.rt_time()) {
  217.                 if (this._rt[2] === 0) {this._rt[2] = 1} else {this._rt[2] = 0};
  218.                 var ran_rot = (Math.randomInt(4) * 0.1)
  219.                 if (this._rt[2] === 0) {this._rt[0] = ran_rot;
  220.             } else {this._rt[0] = -ran_rot};
  221.                 this._rt[1] = 0;
  222.         };
  223.     this._scenarioField.rotation = this.sprite_move_to(this._scenarioField.rotation,this._rt[0],this.rotationSpeed());
  224.         if (this._zt[0] === this._scenarioField.scale.x) {this._zt[1] += 1};
  225.         if (this._zt[1] >= this.rt_time()) {
  226.                 if (this._zt[2] === 0) {this._zt[2] = 1} else {this._zt[2] = 0};
  227.                 var ran_zt = (Math.randomInt(1) * 0.1)
  228.                 if (this._zt[2] === 0) {this._zt[0] = 1.20;
  229.             } else {this._zt[0] = 1.00};
  230.                 this._zt[1] = 0;
  231.         };
  232.     this._scenarioField.scale.x = this.sprite_move_to(this._scenarioField.scale.x,this._zt[0],this.rotationSpeed());
  233.         this._scenarioField.scale.y = this._scenarioField.scale.x;
  234. };

  235. //==============================
  236. // * Sprite Move To
  237. //==============================
  238. Scene_Title.prototype.sprite_move_to = function(value,real_value,speed) {
  239.         if (value == real_value) {return value};
  240.         var dnspeed = speed;
  241.         if (value > real_value) {value -= dnspeed;
  242.             if (value < real_value) {value = real_value};}
  243.     else if (value < real_value) {value  += dnspeed;
  244.             if (value  > real_value) {value  = real_value};               
  245.     };
  246.         return value;
  247. };

  248. //==============================
  249. // * Refresh Characters
  250. //==============================
  251. Scene_Title.prototype.refreshCharacters = function(sprite) {
  252.      sprite.bitmap = this._char_img[this._char_index];
  253.          this._char_index += 1;
  254.          if (this._char_index >= this._char_img.length) {this._char_index = 0}         
  255. };

  256. //==============================
  257. // * RefreshSprite
  258. //==============================
  259. Scene_Title.prototype.refreshSprite = function(sprite,index,type) {
  260.         this.setOrder(sprite,index,type);
  261.     this.setInitialEffect(sprite,index,type);
  262. };

  263. //==============================
  264. // * SetOrder
  265. //==============================
  266. Scene_Title.prototype.setOrder = function(sprite,index,type) {
  267.         var d = 0;
  268.         for (var i = 0; i < this._duration[type].length ; i++) {
  269.             if (d < this._duration[type][i]) {d = this._duration[type][i]};
  270.     };
  271.     this._duration[type][index] = d + this.sp_d();
  272.         this._scenarioField.removeChild(sprite);
  273.         this._scenarioField.addChild(sprite);
  274. };

  275. //==============================
  276. // * SetInitialEffect
  277. //==============================
  278. Scene_Title.prototype.setInitialEffect = function(sprite,index,type) {
  279.         sprite.rotation = 0;
  280.         if (this._side[type] === 0) {
  281.             sprite.x = (Graphics.boxWidth / 2);
  282.             sprite.scale.x = -1.3;
  283.                 if (type === 0) {sprite.rotation -= (Math.random() * 0.7)};
  284.                 this._side[type] = 1
  285.         } else {
  286.                 sprite.x = -(Graphics.boxWidth / 2);
  287.                 sprite.scale.x = 1.3;
  288.                 if (type === 0) {sprite.rotation += (Math.random() * 0.7)};
  289.             this._side[type] = 0
  290.         };       
  291.         if (type === 1) {this.refreshCharacters(sprite)};
  292.         sprite.opacity = 0;
  293.         sprite.y = Graphics.boxHeight / 2 + sprite.bitmap.height * 18 / 100;
  294.         if (type === 0) {
  295.        sprite.x += Moghunter.himawari_flower_x;
  296.            sprite.y += Moghunter.himawari_flower_y;
  297.         } else {
  298.        sprite.x += Moghunter.himawari_char_x;
  299.            sprite.y += Moghunter.himawari_char_y;
  300.         };       
  301. };

  302. //==============================
  303. // * Update Sprites
  304. //==============================
  305. Scene_Title.prototype.updateSprites = function(sprite,index,type) {
  306.         this._duration[type][index] -= 1
  307.     if (Math.abs(sprite.scale.x) > 0.2) {sprite.opacity += 10;
  308.     } else {sprite.opacity -= 25;
  309.         };
  310.         if (sprite.scale.x < 0) {sprite.scale.x += this.objZoomSpeed();       
  311.     } else {sprite.scale.x -= this.objZoomSpeed();
  312.         };
  313.         if (type === 1) {
  314.           if (sprite.scale.x < 0) {sprite.x -= 2} else {sprite.x += 2};
  315.     };
  316.         sprite.scale.y = Math.abs(sprite.scale.x);
  317.         if (this.needRefreshSprite(type,index)) {this.refreshSprite(sprite,index,type)};
  318. };

  319. //==============================
  320. // * Need Refresh Sprite
  321. //==============================
  322. Scene_Title.prototype.needRefreshSprite = function(type,index) {
  323.         if (this._duration[type][index] <= 0) {return true}
  324.         return false;
  325. };

  326. //==============================
  327. // * Update Himawari
  328. //==============================
  329. Scene_Title.prototype.update_himawari = function() {
  330.         if (this._firstRefresh && this._char_img[0].isReady()) {this.firstRefresh()};
  331.         if (this._firstRefresh) {return};
  332.         for (var i = 0; i < 6 ; i++) {
  333.                 this.updateSprites(this._flowers[i],i,0);
  334.                 this.updateSprites(this._chars[i],i,1);
  335.         };
  336.         this.update_background_effects();
  337.         if (this._rotation) {this.update_rotation()};
  338. };

  339. //==============================
  340. // * Update Background Effects
  341. //==============================
  342. Scene_Title.prototype.update_background_effects = function() {
  343.         this._background[0].origin.x += 1;
  344.         this._background[0].origin.y += 1;
  345.         this._background[1].origin.x += 1;       
  346. };

  347. //==============================
  348. // * Update
  349. //==============================
  350. var _alias_mog_title_himawari_update = Scene_Title.prototype.update;
  351. Scene_Title.prototype.update = function() {
  352.     _alias_mog_title_himawari_update.call(this);
  353.         this.update_himawari();
  354. };
复制代码

签名什么的?呵呵
头像被屏蔽
梦石
0
星屑
15793
在线时间
38 小时
注册时间
2019-6-12
回帖
19
发表于 2019-6-12 14:01:03 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

梦石
0
星屑
3053
在线时间
318 小时
注册时间
2015-4-30
回帖
92
发表于 2019-6-12 15:38:38 | 显示全部楼层
精灵.scale.x *= -1;
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部