查看: 1667|回复: 1

[已经过期] 这个脚本怎么改才能让图片居中显示

[复制链接]
梦石
0
星屑
219
在线时间
104 小时
注册时间
2014-2-23
回帖
29
发表于 2014-2-26 16:11:17 | 显示全部楼层 |阅读模式

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

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

×
  1. =begin
  2. ■ Information      ╒═════════════════════════════════════════════════════════╛
  3. EST - LIVING STATUS MENU v1.2
  4. by Estriole

  5. ■ License          ╒═════════════════════════════════════════════════════════╛
  6. Free to use in all project (except the one containing pornography)
  7. as long as i credited (ESTRIOLE).

  8. ■ Support          ╒═════════════════════════════════════════════════════════╛
  9. While I'm flattered and I'm glad that people have been sharing and asking
  10. support for scripts in other RPG Maker communities, I would like to ask that
  11. you please avoid posting my scripts outside of where I frequent because it
  12. would make finding support and fixing bugs difficult for both of you and me.
  13.    
  14. If you're ever looking for support, I can be reached at the following:
  15. ╔═════════════════════════════════════════════╗
  16. ║       [url=http://www.rpgmakervxace.net/]http://www.rpgmakervxace.net/[/url]         ║
  17. ╚═════════════════════════════════════════════╝
  18. pm me : Estriole.

  19. ■ Introduction     ╒═════════════════════════════════════════════════════════╛
  20. This script is requested by Furrari fullbuster from [url=http://www.rpgmakervxace.net/]http://www.rpgmakervxace.net/[/url]
  21. it change status menu to be more lively and beautiful. first... it will
  22. use potrait as the actor picture in status (you need to provide your own). if
  23. the actor didnt have pictures. then it will use rescue picture.
  24. second... you can use as many pictures of the same actor as you want to make it
  25. animated. (require the basic knowledge on how to animate pictures and graphic
  26. editing skills too). all the animating things is done with notetags (will fill
  27. your notetags if you use a lot of pictures so not recommended for symphony user).
  28. third... you can make the animation only run once or make it looped.
  29. fourth... i give you some actor sound feature too. this script will play random
  30. sound of the actor (you need to put notetags on how many sound this actor has).
  31. else it will not play sound. combination of ANIMATED and SOUND make me name this
  32. script LIVING STATUS MENU :D.
  33. last one... use background image as status menu background.

  34. also... although this script is making your status menu COOL... you have to
  35. remember that it have potential to increase your project size by quite a lot
  36. (if you animate the potrait complexly. heck. even rotating magic circle take
  37. me 12 images to make it not to choppy)

  38. so... WARNING FOR LAZY PEOPLE... don't use this script !!!!

  39. ■ Features         ╒═════════════════════════════════════════════════════════╛
  40. * use potrait
  41. * infinite number of potrait per actor to make it animated or just slideshow
  42. * can do one time only animation or looped animation
  43. * can play random sound of the actor
  44. * use image as background

  45. ■ Changelog        ╒═════════════════════════════════════════════════════════╛
  46. v1.0 2013.05.16           Initial Release
  47. v1.1 2013.05.23     add compatibility to custom resolution. just change the
  48.                      DESCRIPTION_LINE_MOD in module estriole to change where
  49.                      the description drawn. for images you just need to resize it.
  50. v1.2 2014.01.01     Happy New Year! add ability to have different background each actor
  51.                      just add another background.jpg (or .png) inside the
  52.                      living_status/actor_x/ folder
  53.                      change x to id of the actor using that background

  54. ■ Compatibility    ╒═════════════════════════════════════════════════════════╛
  55. Definitely not compatible with YANFLY status menu script. :D.
  56. tell me if another script not. since this have lots of overwrite in window_status
  57. this script is expected to not compatible with script that modify that window.

  58. ■ How to use     ╒═════════════════════════════════════════════════════════╛
  59. i will try to explain how to use this script. this is quite confusing if you
  60. don't understand basic animation.

  61. >>>>  Graphic related  <<<<<<
  62. -1) set background image.
  63. put the image of your status menu background in folder
  64. /Graphics/Pictures/living_status/
  65. name it "background"

  66. from below... it's better to use png for potraits since it contain transparency.
  67. 0) set rescue potrait (so the game won't crash when you still didn't have
  68. complete actor potrait).
  69. put the image in
  70. /graphics/pictures/living_status/
  71. name the image "rescue.png"
  72. now your game won't crash when you're developing it. so you can slowly adding
  73. potrait one by one. also when you missing some image when animating. this picture
  74. will also shown to tell you that image is missing.

  75. 1) set actor potrait
  76. create image size with the max width 325 pixel. (best result is 200 or 325 pixel)
  77. put it in folder
  78. /graphics/pictures/living_status/actor_x/
  79. (change _x to _actorid)
  80. name the image "1.png" (since png has transparency)
  81. example
  82. /graphics/pictures/living_status/actor_1/1.png
  83. will set that picture as the 'first' picture of the actor 1.

  84. by doing so you already have potrait status menu. if you want it animated
  85. another step must be done. BUT if you don't understand basic animation/frame/etc
  86. Stop at this point rather than boiling your head. your status menu is already
  87. pretty at this point if you done it right...

  88. 2) animating actor potrait
  89. basically you create another image which slightly different from first picture.
  90. name it in sequence such as 2.png, 3.png, 4.png, etc.
  91. put the images in they same folder as the 1.png.
  92. now you have to understand frames before executing this section.
  93. first define frame max for that actor potrait. by giving the actor notetags:

  94. <frame_max: 60>

  95. it will set the frame 0 to 60. so the animation will occur in 60 frames.
  96. if you don't set the notetags by default frame max is what you set in module ESTRIOLE.

  97. second define how many pictures that actor animate. give actor notetags:

  98. <anim_max: 12>

  99. it means that actor have 12 pictures to animate

  100. third set the timing of the animation change. give notetags to actor
  101. <frame_anim_1: 0, 5>
  102. means 1.png will shown from 0 to 5 frame
  103. <frame_anim_2: 5, 10>
  104. means 2.png will shown from 5 to 10 frame
  105. <frame_anim_3: 10, 15>
  106. means 3.png will shown from 10 to 15 frame
  107. <frame_anim_4: 15, 20>
  108. means 4.png will shown from 15 to 20 frame
  109. done that until all your pictures given animation set.
  110. warning... the first number in notetags must be lower than second number.
  111. also one picture can only used once. (still thinking another way to prevent that
  112. i have a way already using array and another for. but will make user hard to use).
  113. also if at that frame no image specified... it will automatically use 1.png.

  114. now you got yourself animated picture.

  115. 3) making looped animation
  116. after setting above. you could give notetags to loop animation. give the actor:
  117. <loop_to: x>
  118. x -> frame number
  119. <loop_to: 0>
  120. will loop it back to frame 0 continuosly.
  121. <loop_to: 100>
  122. will loop it back to frame 100 continuosly. useful when you want to make actor
  123. talking animation + another animation. then loop without the talking animation.

  124. >>>>  Sound related  <<<<<<
  125. 1) put the actor voice files in
  126. /Audio/SE/living_status/actor_#/
  127. name it sequentialy.
  128. ex:
  129. /Audio/SE/living_status/actor_1/1.ogg
  130. /Audio/SE/living_status/actor_1/2.ogg
  131. /Audio/SE/living_status/actor_1/3.ogg
  132. will give the actor 3 sounds.
  133. 2) set the notetags telling that this actor has three sounds
  134. <op_voices_num: 3>
  135. here you go... now your actor will tell random sound everytime you view their
  136. status menu :D.

  137. if you're confused. just look at the demo project folder.

  138. ■ Author's Notes   ╒═════════════════════════════════════════════════════════╛
  139. This script is quite hard to use. need to understand basic of animating
  140. pictures. also only one layer provided so it's limited animation.
  141. future patch plan (if i'm not busy)
  142. - sound effect in animation
  143. - tell me...
  144.    
  145. =end

  146. ###       CONFIGURATION       ##################################################
  147. module ESTRIOLE
  148.   module STATUS
  149.     USE_DESCRIPTION = true #true will show actor description   
  150.     DEFAULT_FRAME_MAX = 300 #default frame max of actor animation
  151.     DESCRIPTION_LINE_MOD = 14 #change this if you're using custom resolution.
  152.                               #if not 14 is ok. 14 means you draw the description
  153.                               #at 14th line
  154.   end
  155. end

  156. class RPG::Actor < RPG::BaseItem
  157.   def frame_max
  158.     return nil if !note[/<frame_max:(.*)>/i]
  159.     a = note[/<frame_max:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| (\w+)|(\w+),|,(\w+))/).flatten.compact
  160.     return noteargs = a[0].to_i
  161.   end
  162.   def anim_max
  163.     return 1 if !note[/<anim_max:(.*)>/i]
  164.     a = note[/<anim_max:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| (\w+)|(\w+),|,(\w+))/).flatten.compact
  165.     return noteargs = a[0].to_i
  166.   end
  167.   def frame_change(index)
  168.     return nil if !note[/<frame_anim_#{index}:(.*)>/i]
  169.     a = note[/<frame_anim_#{index}:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| (\w+)|(\w+),|,(\w+))/).flatten.compact
  170.     return noteargs = [a[0].to_i,a[1].to_i]
  171.   end
  172.   def anim_loop_to?
  173.     return nil if !note[/<loop_to:(.*)>/i]
  174.     a = note[/<loop_to:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| (\w+)|(\w+),|,(\w+))/).flatten.compact
  175.     return noteargs = a[0].to_i   
  176.   end
  177.   def voices_num
  178.     return nil if !note[/<op_voices_num:(.*)>/i]
  179.     a = note[/<op_voices_num:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| (\w+)|(\w+),|,(\w+))/).flatten.compact
  180.     return noteargs = a[0].to_i
  181.   end
  182. end

  183. class Scene_Status < Scene_MenuBase
  184.   include ESTRIOLE::STATUS
  185.   alias est_living_status_start start
  186.   def start
  187.     est_living_status_start
  188.     @frame_count = 0
  189.     play_random_actor_sound
  190.   end
  191.   alias est_living_status_next_actor next_actor
  192.   def next_actor
  193.     @status_window.actor_anim_index = 1
  194.     @frame_count = 0
  195.     est_living_status_next_actor
  196.     4.times do update end
  197.     RPG::SE.stop
  198.     play_random_actor_sound
  199.   end
  200.   alias est_living_status_prev_actor prev_actor  
  201.   def prev_actor
  202.     @status_window.actor_anim_index = 1
  203.     @frame_count = 0
  204.     est_living_status_prev_actor
  205.     4.times do update end
  206.     RPG::SE.stop
  207.     play_random_actor_sound
  208.   end
  209.   def play_random_actor_sound
  210.     return unless @actor.actor.voices_num
  211.     a = ([email]1..@actor.actor.voices_num[/email]).to_a.sample
  212.     RPG::SE.new("/living_status/actor_#{@actor.actor.id}/#{a}", 100, 100).play
  213.   end

  214.   def update
  215.     super
  216.     frame_max = DEFAULT_FRAME_MAX
  217.     frame_max = @actor.actor.frame_max if @actor.actor.frame_max
  218.     old_index = @status_window.actor_anim_index
  219.     @frame_count = @actor.actor.anim_loop_to? if @frame_count == frame_max && @actor.actor.anim_loop_to?
  220.     @frame_count += 1
  221.     @frame_count = [@frame_count,frame_max].min
  222.     @status_window.actor_anim_index = 1
  223.     anim_max = 3
  224.     anim_max = @actor.actor.anim_max if @actor.actor.anim_max
  225.     for i in 1..anim_max
  226.       @status_window.actor_anim_index = i if @actor.actor.frame_change(i) &&
  227.                                              @frame_count >= @actor.actor.frame_change(i)[0] &&
  228.                                              @frame_count <= @actor.actor.frame_change(i)[1]
  229.     end   
  230.     @status_window.refresh if old_index != @status_window.actor_anim_index
  231.   end
  232. end

  233. class Window_Status < Window_Selectable
  234.   include ESTRIOLE::STATUS
  235.   attr_accessor :actor_anim_index
  236.   attr_reader :actor_potrait
  237.   def initialize(actor)
  238.     super(0, 0, Graphics.width, Graphics.height)
  239.     @actor = actor
  240.     create_background
  241.     create_potrait
  242.     refresh
  243.     activate
  244.   end
  245.   def terminate
  246.     super
  247.     dispose_background
  248.     dispose_potrait
  249.   end
  250.   def create_potrait
  251.     @actor_potrait = Sprite.new
  252.     @actor_potrait.x = 304 - 50
  253.     @actor_potrait.y = line_height * 3
  254.     @actor_potrait.z = self.z if !USE_DESCRIPTION
  255.     @actor_anim_index = 1
  256.   end
  257.   def create_background
  258.     @background_sprite = Sprite.new
  259.     @background_sprite.bitmap = Cache.picture("/living_status/actor_#{@actor.actor.id}/background") rescue Cache.picture("/living_status/background") rescue nil
  260.     self.opacity = 0 if @background_sprite.bitmap
  261.     @background_sprite.bitmap = SceneManager.background_bitmap if @background_sprite.bitmap == nil
  262.   end
  263.   def dispose_background
  264.     @background_sprite.dispose
  265.   end  
  266.   def dispose_potrait
  267.     @actor_potrait.dispose
  268.   end
  269.   def actor=(actor)
  270.     return if @actor == actor
  271.     @actor = actor
  272.     dispose_background
  273.     create_background
  274.     refresh
  275.   end
  276.   def refresh
  277.     contents.clear
  278.     draw_block1   (line_height * 0)
  279.     draw_horz_line(line_height * 2)
  280.     draw_block2   (line_height * 3)
  281.     draw_custom_horz_line(line_height * 6,200)
  282.     draw_block3   (line_height * 7)
  283.     draw_horz_line(line_height * (DESCRIPTION_LINE_MOD-1)) if USE_DESCRIPTION
  284.     draw_block4   (line_height * DESCRIPTION_LINE_MOD) if USE_DESCRIPTION
  285.   end
  286.   def draw_actor_name(actor, x, y, width = 325)
  287.     change_color(system_color)
  288.     draw_text(x, y, width, line_height, "Name  ")   
  289.     change_color(normal_color)
  290.     draw_text(x+80, y, width-80, line_height, actor.name)
  291.   end  
  292.   def draw_actor_class(actor, x, y, width = 325)
  293.     text = actor.class.name
  294.     change_color(system_color)
  295.     draw_text(x, y, width, line_height, "Class ")
  296.     change_color(normal_color)
  297.     draw_text(x+80, y, width-80, line_height, text)
  298.   end
  299.   def draw_basic_info(x, y)
  300.     draw_actor_level(@actor, x, y + line_height * 0)
  301.     draw_actor_icons(@actor, x + 70, y + line_height * 0)
  302.     draw_actor_hp(@actor, x, y + line_height * 1,170)
  303.     draw_actor_mp(@actor, x, y + line_height * 2,170)
  304.   end  
  305.   def draw_exp_info(x, y)
  306.     s1 = @actor.max_level? ? "-------" : @actor.exp
  307.     s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
  308.     change_color(system_color)
  309.     draw_text(x, y + line_height * 0, 180, line_height, "EXP")
  310.     draw_text(x, y + line_height * 1, 180, line_height, "Next")
  311.     change_color(normal_color)
  312.     draw_text(x, y + line_height * 0, 180, line_height, s1, 2)
  313.     draw_text(x, y + line_height * 1, 180, line_height, s2, 2)
  314.   end
  315.   def draw_parameters(x, y)
  316.     6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  317.   end
  318.   def draw_actor_param(actor, x, y, param_id)
  319.     change_color(system_color)
  320.     draw_text(x, y, 120, line_height, Vocab::param(param_id))
  321.     change_color(normal_color)
  322.     draw_text(x + 100, y, 36, line_height, actor.param(param_id), 2)
  323.   end
  324.   def draw_block1(y)
  325.     draw_actor_name(@actor, 20, y)
  326.     draw_actor_class(@actor, 20, y + line_height)
  327.     draw_exp_info(304, y)
  328.   end
  329.   def draw_block2(y)
  330.     draw_basic_info(20, y)
  331.     draw_potraits(288, y)
  332.   end
  333.   def draw_potraits(x,y)
  334.     @actor_potrait.bitmap = Cache.picture("/living_status/actor_#{@actor.actor.id}/#{@actor_anim_index}") rescue rescue_potrait
  335.   end
  336.   def rescue_potrait
  337.     Cache.picture("/living_status/rescue")
  338.   end
  339.   def draw_block3(y)
  340.     draw_parameters(20, y)
  341.   end
  342.   def draw_block4(y)
  343.     draw_description(4, y)
  344.   end
  345.   def draw_horz_line(y)
  346.     line_y = y + line_height / 2 - 1
  347.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  348.   end
  349.   def draw_custom_horz_line(y,w)
  350.     line_y = y + line_height / 2 - 1
  351.     contents.fill_rect(0, line_y, w, 2, line_color)
  352.   end
  353.   def line_color
  354.     color = normal_color
  355.     color.alpha = 48
  356.     color
  357.   end
  358.   def draw_description(x, y)
  359.     draw_text_ex(x, y, @actor.description)
  360.   end
  361. end
复制代码



目前图片靠左上角,看着实在蛋疼
00000000000000000.png
梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2014-2-26 20:04:42 | 显示全部楼层
你先传个范例工程贝。

PS:脚本作者说他的脚本不能用在 H 游戏里。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部