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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2044
在线时间
758 小时
注册时间
2013-7-3
帖子
127
跳转到指定楼层
1
发表于 2019-3-8 21:35:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
3星屑
左右反转图片各位大佬是怎么实现的?提问区居然没人问过这个问题,然后我网上找到这个标题插件,一阵研究之后果然没找着这段代码,额大佬们帮帮小弟呀
JAVASCRIPT 代码复制下载
  1. //=============================================================================
  2. // MOG_TitleHimawari.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc (v1.0) 标题界面显示角色动画场景.
  7.  * @author Moghunter
  8.  *
  9.  * @param Char Number
  10.  * @desc Definição da quantidade de imagens dos personagens.
  11.  * @default 4
  12.  *  
  13.  * @param Char X-Axis
  14.  * @desc Definição X-axis da imagem dos personagens.
  15.  * @default 0
  16.  *
  17.  * @param Char Y-Axis
  18.  * @desc Definição Y-axis da imagem dos personagens.
  19.  * @default 0
  20.  *
  21.  * @param Flower X-Axis
  22.  * @desc Definição X-axis da imagem das flores.
  23.  * @default 0
  24.  *
  25.  * @param Flower Y-Axis
  26.  * @desc Definição Y-axis da imagem das flores.
  27.  * @default 0
  28.  *
  29.  * @param Rotation
  30.  * @desc Ativar rotação.
  31.  * @default true
  32.  *
  33.  * @param Rotation Time
  34.  * @desc Tempo para ativar a rotação.
  35.  * @default 300
  36.  *
  37.  * @help  
  38.  * =============================================================================
  39.  * +++ MOG - Title Screen Himawari (v1.0) +++
  40.  * By Moghunter
  41.  * [url]https://atelierrgss.wordpress.com/[/url]
  42.  * =============================================================================
  43.  * 角色动画场景
  44.  * =============================================================================
  45.  * 角色的图像必须保存在文件夹 /img/titles1/
  46.  *
  47.  * 人物图像的命名应遵循以下形式
  48.  *
  49.  * Char_ +ID.png
  50.  *
  51.  * Char_1.png
  52.  * Char_2.png
  53.  * Char_3.png
  54.  * ...
  55.  * 需要/img/titles1/Background_X.png
  56.  * 需要/img/titles1/Flower.png
  57.  * 建议使用屏幕高度的字符图像
  58.  * (624 像素)
  59.  *
  60.  */
  61.  
  62. //=============================================================================
  63. // ** PLUGIN PARAMETERS
  64. //=============================================================================
  65.   var Imported = Imported || {};
  66.   Imported.MOG_TitleHimawari = true;
  67.   var Moghunter = Moghunter || {};
  68.  
  69.    Moghunter.parameters = PluginManager.parameters('MOG_TitleHimawari');
  70.     Moghunter.himawari_char_number = Number(Moghunter.parameters['Char Number'] || 4);
  71.     Moghunter.himawari_char_x = Number(Moghunter.parameters['Char X-Axis'] || 0);
  72.         Moghunter.himawari_char_y = Number(Moghunter.parameters['Char Y-Axis'] || 0);
  73.     Moghunter.himawari_flower_x = Number(Moghunter.parameters['Flower X-Axis'] || 0);
  74.         Moghunter.himawari_flower_y = Number(Moghunter.parameters['Flower Y-Axis'] || 0);       
  75.     Moghunter.himawari_rotation = String(Moghunter.parameters['Rotation'] || "true");
  76.     Moghunter.himawari_rotation_duration = Number(Moghunter.parameters['Rotation Time'] || 300);
  77.  
  78.  
  79. //=============================================================================
  80. // ** Scene Title
  81. //=============================================================================       
  82.  
  83. //==============================
  84. // * Initialize
  85. //==============================
  86. var _alia_mog_himawari_initialize = Scene_Title.prototype.initialize;
  87. Scene_Title.prototype.initialize = function() {       
  88.     _alia_mog_himawari_initialize.call(this);
  89.         this._scenarioField = new Sprite();
  90.         this._scenarioField.x = Graphics.boxWidth / 2;
  91.         this._scenarioField.y = Graphics.boxHeight / 2;
  92.         this._scenarioField.scale.x = 1.00;
  93.         this._scenarioField.scale.y = this._scenarioField.scale.x;
  94.         this.addChild(this._scenarioField);
  95.         this._duration = [[],[],[]];
  96.         this._side = [0,0,0];
  97.         this._rt = [0,0,0];
  98.         this._zt = [1.00,0,0];
  99.         this._char_number = Math.min(Math.max(Moghunter.himawari_char_number,1),999);
  100.         this._char_number += 1;
  101.         this._rotation = false;
  102.         this._rotation_time = Math.min(Math.max(Moghunter.himawari_rotation_duration,60),999);
  103.         if (String(Moghunter.himawari_rotation) === "true") {this._rotation = true};
  104.         this._firstRefresh = true;
  105.         this.loadImages();       
  106. };
  107.  
  108. //==============================
  109. // * Load Images
  110. //==============================
  111. Scene_Title.prototype.loadImages = function() {
  112.         this._back_img = [ImageManager.loadTitle1("Background_1"),
  113.                            ImageManager.loadTitle1("Background_2"),
  114.                                           ];
  115.         this._flower_img = ImageManager.loadTitle1("Flower");
  116.         this._char_img = [];
  117.         for (var i = 1; i < this._char_number ; i++) {
  118.              this._char_img.push(ImageManager.loadTitle1("Char_" + i));
  119.         };
  120. };
  121.  
  122. //==============================
  123. // * Create Background
  124. //==============================
  125. var _alias_mog_himawari_createBackground = Scene_Title.prototype.createBackground;
  126. Scene_Title.prototype.createBackground = function() {       
  127.     _alias_mog_himawari_createBackground.call(this);
  128.         this.removeChild(this._backSprite1);
  129.         this.removeChild(this._backSprite2);
  130.         this.createHimariSprites();
  131. };
  132.  
  133. //==============================
  134. // * Create Himawari Sprites
  135. //==============================
  136. Scene_Title.prototype.createHimariSprites = function() {
  137.         this.createHbackground();
  138.         this.createFlowers();
  139.         this.createCharacters();
  140. };
  141.  
  142. //==============================
  143. // * Create Background
  144. //==============================
  145. Scene_Title.prototype.createHbackground = function() {
  146.         var width = Graphics.boxWidth * 2;
  147.         var height = Graphics.boxHeight * 2;
  148.         this._background = [];
  149.         for (var i = 0; i < 2 ; i++) {
  150.                  this._background[i] = new TilingSprite(this._back_img[i]);
  151.                  this._background[i].move(0,0, width, height);
  152.              this._background[i].anchor.x = 0.5;
  153.                  this._background[i].anchor.y = 0.5;
  154.                  this._scenarioField.addChild(this._background[i]);
  155.         }
  156.         this._background[1].y = Graphics.boxHeight / 2;
  157.         this._background[1].scale.x = 1.5;
  158.         this._background[1].scale.y = 1.5;
  159. };
  160.  
  161. //==============================
  162. // * Sp D
  163. //==============================
  164. Scene_Title.prototype.sp_d = function() {
  165.         return 120;
  166. };
  167.  
  168. //==============================
  169. // * Obj Zoom Speed
  170. //==============================
  171. Scene_Title.prototype.objZoomSpeed = function() {
  172.         return 0.003;
  173. };
  174.  
  175. //==============================
  176. // * Rt Time
  177. //==============================
  178. Scene_Title.prototype.rt_time = function() {
  179.         return this._rotation_time;
  180. };
  181.  
  182. //==============================
  183. // * Rotation Speed
  184. //==============================
  185. Scene_Title.prototype.rotationSpeed = function() {
  186.         return 0.004;
  187. };
  188.  
  189. //==============================
  190. // * Create Flowers
  191. //==============================
  192. Scene_Title.prototype.createFlowers = function() {
  193.         this._flowers = [];
  194.         for (var i = 0; i < 6 ; i++) {
  195.                  this._flowers[i] = new Sprite(this._flower_img);
  196.                  this._flowers[i].anchor.x = 0.5;
  197.                  this._flowers[i].anchor.y = 1;
  198.                  this._flowers[i].y = Graphics.boxHeight / 2;
  199.                  this._duration[0][i] = this.sp_d() * i;
  200.         };
  201. };
  202.  
  203. //==============================
  204. // * Create Characters
  205. //==============================
  206. Scene_Title.prototype.createCharacters = function() {
  207.         this._char_index = 0;
  208.         this._chars = [];
  209.         for (var i = 0; i < 6 ; i++) {
  210.                  this._chars[i] = new Sprite();
  211.                  this._chars[i].anchor.x = 0.5;
  212.              this._chars[i].anchor.y = 1;
  213.                  this._chars[i].y = Graphics.boxHeight / 2;
  214.                  this._duration[1][i] = (this.sp_d() / 2) + (this.sp_d() * i);
  215.         };
  216. };
  217.  
  218. //==============================
  219. // * First Refresh
  220. //==============================
  221. Scene_Title.prototype.firstRefresh = function() {
  222.          this._firstRefresh = false;
  223.          for (var i = 0; i < this._char_img.length  ; i++) {       
  224.         this._chars[0].bitmap = this._char_img[i];
  225.          };
  226.          this._background[1].y = Graphics.boxHeight / 2 + (this._back_img[1].height * 18 / 100);
  227. };
  228.  
  229. //==============================
  230. // * Refresh Characters
  231. //==============================
  232. Scene_Title.prototype.update_rotation = function(sprite) {
  233.         if (this._rt[0] === this._scenarioField.rotation) {this._rt[1] += 1};
  234.         if (this._rt[1] >= this.rt_time()) {
  235.                 if (this._rt[2] === 0) {this._rt[2] = 1} else {this._rt[2] = 0};
  236.                 var ran_rot = (Math.randomInt(4) * 0.1)
  237.                 if (this._rt[2] === 0) {this._rt[0] = ran_rot;
  238.             } else {this._rt[0] = -ran_rot};
  239.                 this._rt[1] = 0;
  240.         };
  241.     this._scenarioField.rotation = this.sprite_move_to(this._scenarioField.rotation,this._rt[0],this.rotationSpeed());
  242.         if (this._zt[0] === this._scenarioField.scale.x) {this._zt[1] += 1};
  243.         if (this._zt[1] >= this.rt_time()) {
  244.                 if (this._zt[2] === 0) {this._zt[2] = 1} else {this._zt[2] = 0};
  245.                 var ran_zt = (Math.randomInt(1) * 0.1)
  246.                 if (this._zt[2] === 0) {this._zt[0] = 1.20;
  247.             } else {this._zt[0] = 1.00};
  248.                 this._zt[1] = 0;
  249.         };
  250.     this._scenarioField.scale.x = this.sprite_move_to(this._scenarioField.scale.x,this._zt[0],this.rotationSpeed());
  251.         this._scenarioField.scale.y = this._scenarioField.scale.x;
  252. };
  253.  
  254. //==============================
  255. // * Sprite Move To
  256. //==============================
  257. Scene_Title.prototype.sprite_move_to = function(value,real_value,speed) {
  258.         if (value == real_value) {return value};
  259.         var dnspeed = speed;
  260.         if (value > real_value) {value -= dnspeed;
  261.             if (value < real_value) {value = real_value};}
  262.     else if (value < real_value) {value  += dnspeed;
  263.             if (value  > real_value) {value  = real_value};               
  264.     };
  265.         return value;
  266. };
  267.  
  268. //==============================
  269. // * Refresh Characters
  270. //==============================
  271. Scene_Title.prototype.refreshCharacters = function(sprite) {
  272.      sprite.bitmap = this._char_img[this._char_index];
  273.          this._char_index += 1;
  274.          if (this._char_index >= this._char_img.length) {this._char_index = 0}         
  275. };
  276.  
  277. //==============================
  278. // * RefreshSprite
  279. //==============================
  280. Scene_Title.prototype.refreshSprite = function(sprite,index,type) {
  281.         this.setOrder(sprite,index,type);
  282.     this.setInitialEffect(sprite,index,type);
  283. };
  284.  
  285. //==============================
  286. // * SetOrder
  287. //==============================
  288. Scene_Title.prototype.setOrder = function(sprite,index,type) {
  289.         var d = 0;
  290.         for (var i = 0; i < this._duration[type].length ; i++) {
  291.             if (d < this._duration[type][i]) {d = this._duration[type][i]};
  292.     };
  293.     this._duration[type][index] = d + this.sp_d();
  294.         this._scenarioField.removeChild(sprite);
  295.         this._scenarioField.addChild(sprite);
  296. };
  297.  
  298. //==============================
  299. // * SetInitialEffect
  300. //==============================
  301. Scene_Title.prototype.setInitialEffect = function(sprite,index,type) {
  302.         sprite.rotation = 0;
  303.         if (this._side[type] === 0) {
  304.             sprite.x = (Graphics.boxWidth / 2);
  305.             sprite.scale.x = -1.3;
  306.                 if (type === 0) {sprite.rotation -= (Math.random() * 0.7)};
  307.                 this._side[type] = 1
  308.         } else {
  309.                 sprite.x = -(Graphics.boxWidth / 2);
  310.                 sprite.scale.x = 1.3;
  311.                 if (type === 0) {sprite.rotation += (Math.random() * 0.7)};
  312.             this._side[type] = 0
  313.         };       
  314.         if (type === 1) {this.refreshCharacters(sprite)};
  315.         sprite.opacity = 0;
  316.         sprite.y = Graphics.boxHeight / 2 + sprite.bitmap.height * 18 / 100;
  317.         if (type === 0) {
  318.        sprite.x += Moghunter.himawari_flower_x;
  319.            sprite.y += Moghunter.himawari_flower_y;
  320.         } else {
  321.        sprite.x += Moghunter.himawari_char_x;
  322.            sprite.y += Moghunter.himawari_char_y;
  323.         };       
  324. };
  325.  
  326. //==============================
  327. // * Update Sprites
  328. //==============================
  329. Scene_Title.prototype.updateSprites = function(sprite,index,type) {
  330.         this._duration[type][index] -= 1
  331.     if (Math.abs(sprite.scale.x) > 0.2) {sprite.opacity += 10;
  332.     } else {sprite.opacity -= 25;
  333.         };
  334.         if (sprite.scale.x < 0) {sprite.scale.x += this.objZoomSpeed();       
  335.     } else {sprite.scale.x -= this.objZoomSpeed();
  336.         };
  337.         if (type === 1) {
  338.           if (sprite.scale.x < 0) {sprite.x -= 2} else {sprite.x += 2};
  339.     };
  340.         sprite.scale.y = Math.abs(sprite.scale.x);
  341.         if (this.needRefreshSprite(type,index)) {this.refreshSprite(sprite,index,type)};
  342. };
  343.  
  344. //==============================
  345. // * Need Refresh Sprite
  346. //==============================
  347. Scene_Title.prototype.needRefreshSprite = function(type,index) {
  348.         if (this._duration[type][index] <= 0) {return true}
  349.         return false;
  350. };
  351.  
  352. //==============================
  353. // * Update Himawari
  354. //==============================
  355. Scene_Title.prototype.update_himawari = function() {
  356.         if (this._firstRefresh && this._char_img[0].isReady()) {this.firstRefresh()};
  357.         if (this._firstRefresh) {return};
  358.         for (var i = 0; i < 6 ; i++) {
  359.                 this.updateSprites(this._flowers[i],i,0);
  360.                 this.updateSprites(this._chars[i],i,1);
  361.         };
  362.         this.update_background_effects();
  363.         if (this._rotation) {this.update_rotation()};
  364. };
  365.  
  366. //==============================
  367. // * Update Background Effects
  368. //==============================
  369. Scene_Title.prototype.update_background_effects = function() {
  370.         this._background[0].origin.x += 1;
  371.         this._background[0].origin.y += 1;
  372.         this._background[1].origin.x += 1;       
  373. };
  374.  
  375. //==============================
  376. // * Update
  377. //==============================
  378. var _alias_mog_title_himawari_update = Scene_Title.prototype.update;
  379. Scene_Title.prototype.update = function() {
  380.     _alias_mog_title_himawari_update.call(this);
  381.         this.update_himawari();
  382. };

签名什么的?呵呵
头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
11178
在线时间
28 小时
注册时间
2019-6-12
帖子
19
2
发表于 2019-6-12 14:01:03 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3053
在线时间
318 小时
注册时间
2015-4-30
帖子
92
3
发表于 2019-6-12 15:38:38 | 只看该作者
精灵.scale.x *= -1;
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-8 13:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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