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

Project1

 找回密码
 注册会员
搜索

请求修改脚本移动血条位置

查看数: 1347 | 评论数: 3 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2012-4-13 21:10

正文摘要:

本帖最后由 zxc3838507 于 2012-4-13 21:11 编辑 唔……因为太小白了不懂这个脚本,下面贴上图和脚本的说 所以请求前辈们帮忙修改(翻滚) 大概就是把红色位置的HP和SP移动到绿色位置~ # HP/SP/ゲージアニメー ...

回复

zxc3838507 发表于 2012-4-14 12:15:30
腐琴琴 发表于 2012-4-14 08:32
额……似乎……不是在你的脚本上面动刀子。
(在下也脚本无能,你就随意听听吧……)

原来如此~这次子连去除那个名字也一并解决了呢
感谢感谢~
腐琴琴 发表于 2012-4-14 08:32:57
本帖最后由 腐琴琴 于 2012-4-14 08:36 编辑

额……似乎……不是在你的脚本上面动刀子。
(在下也脚本无能,你就随意听听吧……)

找到这个,这个是专门处理战斗状态的
Window_BattleStatus


这里就是名字和HP  SP 什么的啦。然后对着他们动刀子就好了。
  1.       actor_x = i * 160 + 4
  2.       draw_actor_name(actor, actor_x, 0)
  3.       draw_actor_hp(actor, actor_x, 32 , 120)
  4.       draw_actor_sp(actor, actor_x, 64 , 120)
  5.       if @level_up_flags[i]
  6.         self.contents.font.color = normal_color
  7.         self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
  8.       else
  9.         draw_actor_state(actor, actor_x, 96)
复制代码
然后我简单改了下……你可以自己再改改数字什么的
  1.       actor_x = i * 160 + 4  #这里当然是一切的X坐标啦
  2.       draw_actor_name(actor, actor_x, 0)  #这个是名字,0是Y坐标
  3.       draw_actor_hp(actor, actor_x, 32 +30, 120) #我在这里+30,Y就向下了
  4.       draw_actor_sp(actor, actor_x, 64 +30, 120) #这里同理
  5.       if @level_up_flags[i]
  6.         self.contents.font.color = normal_color
  7.         self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
  8.       else
  9.         draw_actor_state(actor, actor_x, 96)  #这个应该是状态君,96就是Y坐标啦
复制代码

因为你的脚本我也没见过,大概就是这样了……
然后那个状态君放在那里的确不太和谐,你改96什么的就好了。
PS:如果有问题的话回复就好,我再想想……���
he11120 发表于 2012-4-14 02:19:04
  1. # HP/SP/ゲージアニメーション表示スクリプト Ver 1.04
  2. # 配布元・サポートURL
  3. # http://members.jcom.home.ne.jp/cogwheel/

  4. #==============================================================================
  5. # ■ Game_Actor
  6. #------------------------------------------------------------------------------
  7. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  8. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  9. #==============================================================================

  10. class Game_Actor < Game_Battler
  11.   def now_exp
  12.     return @exp - @exp_list[@level]
  13.   end
  14.   def next_exp
  15.     return (@exp_list[@level+1] > 0 ?
  16.       @exp_list[@level+1] - @exp_list[@level] : 0)
  17.   end
  18. end

  19. #==============================================================================
  20. # ■ Window_Base
  21. #------------------------------------------------------------------------------
  22. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  23. #==============================================================================

  24. class Window_Base < Window
  25.   #--------------------------------------------------------------------------
  26.   # ● オブジェクト初期化
  27.   #     x      : ウィンドウの X 座標
  28.   #     y      : ウィンドウの Y 座標
  29.   #     width  : ウィンドウの幅
  30.   #     height : ウィンドウの高さ
  31.   #--------------------------------------------------------------------------
  32.   alias :initialize_gauge :initialize
  33.   def initialize(x, y, width, height)
  34.     initialize_gauge(x, y, width, height)
  35.     # HP, SP ゲージの初期化
  36.     @hp_gauge = {}
  37.     @sp_gauge = {}
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 解放
  41.   #--------------------------------------------------------------------------
  42.   alias :dispose_gauge :dispose
  43.   def dispose
  44.     # ゲージの削除
  45.     gauge_delete
  46.     # オリジナルの解放処理
  47.     dispose_gauge
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● ゲージの初期化
  51.   #--------------------------------------------------------------------------
  52.   def gauge_delete
  53.     # HP ゲージの消去
  54.     for gauge in @hp_gauge.values
  55.       gauge[0].bitmap.dispose
  56.       gauge[0].dispose
  57.     end
  58.     # SP ゲージの更新
  59.     for gauge in @sp_gauge.values
  60.       gauge[0].bitmap.dispose
  61.       gauge[0].dispose
  62.     end
  63.     @hp_gauge = {}
  64.     @sp_gauge = {}
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● フレーム更新
  68.   #--------------------------------------------------------------------------
  69.   alias :update_gauge :update
  70.   def update
  71.     update_gauge
  72.     # HP ゲージの更新
  73.     for gauge in @hp_gauge.values
  74.       gauge_refresh(gauge, 0)
  75.     end
  76.     # SP ゲージの更新
  77.     for gauge in @sp_gauge.values
  78.       gauge_refresh(gauge, 1)
  79.     end
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● HP ゲージの描画
  83.   #--------------------------------------------------------------------------
  84.   # オリジナルのHP描画を draw_actor_hp_hpsp と名前変更
  85.   alias :draw_actor_hp_hpsp :draw_actor_hp
  86.   def draw_actor_hp(actor, x, y, width = 144)
  87.     #==========================================================
  88.      # 描绘字符串 "HP"
  89.     self.contents.font.color = system_color
  90.     self.contents.draw_text(x, y + 35, 32, 32, $data_system.words.hp)
  91.     # 计算描绘 MaxHP 所需的空间
  92.     if width - 32 >= 108
  93.       hp_x = x + width - 108
  94.       flag = true
  95.     elsif width - 32 >= 48
  96.       hp_x = x + width - 48
  97.       flag = false
  98.     end
  99.     # 描绘 HP
  100.     self.contents.font.color = actor.hp == 0 ? knockout_color :
  101.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  102.     self.contents.draw_text(hp_x, y + 35, 48, 32, actor.hp.to_s, 2)
  103.     # 描绘 MaxHP
  104.     if flag
  105.       self.contents.font.color = normal_color
  106.       self.contents.draw_text(hp_x + 48, y + 35, 12, 32, "/", 1)
  107.       self.contents.draw_text(hp_x + 60, y + 35, 48, 32, actor.maxhp.to_s)
  108.     end
  109.     #===========================================================================
  110.     # 初描画の場合
  111.     if @hp_gauge[actor] == nil
  112.       # ゲージ高
  113.       height = 10
  114.       # 色設定。color1:外枠,color2:中枠
  115.       # color3:空ゲージダークカラー,color4:空ゲージライトカラー
  116.       color1 = Color.new(0, 0, 0, 192)
  117.       color2 = Color.new(255, 255, 192, 192)
  118.       color3 = Color.new(64, 0, 0, 192)
  119.       color4 = Color.new(0, 0, 0, 192)
  120.       # 空ゲージの描画
  121.       @hp_frame = gauge_rect(width, height, color1, color2, color3, color4)
  122.       sprite = Sprite.new(self.viewport)
  123.       sprite.bitmap = Bitmap.new(width, height)
  124.       sprite.x = self.x + x + 16
  125.       sprite.y = self.y + y + 42 - height
  126.       sprite.z = self.z + 1
  127.       count = rand(400)
  128.       # 変数rateに 現在のHP/MHPを代入
  129.       if actor.maxhp != 0
  130.         rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil
  131.       else
  132.         rate = width - 4
  133.       end
  134.       # 位置等情報の記憶
  135.       @hp_gauge[actor] = [sprite, actor, rate, count, x, y - height + 35]
  136.       # ゲージ描画
  137.       gauge_refresh(@hp_gauge[actor], 0)
  138.       # ターゲットウィンドウの場合、初期状態は非表示
  139.       @hp_gauge[actor][0].visible = false if self.is_a?(Window_Target)
  140.     end
  141.     # 変数rateに 現在のHP/MHPを代入
  142.     if actor.maxhp != 0
  143.       rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil
  144.     else
  145.       rate = width - 4
  146.     end
  147.     @hp_gauge[actor][2] = rate
  148.     # オリジナルのHP描画処理を呼び出し
  149.     draw_actor_hp_hpsp(actor, x, y, width)
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● SP ゲージの描画
  153.   #--------------------------------------------------------------------------
  154.   # オリジナルのSP描画を draw_actor_sp_hpsp と名前変更
  155.   alias :draw_actor_sp_hpsp :draw_actor_sp
  156.   def draw_actor_sp(actor, x, y, width = 144)
  157.     #----------------------------------------------------------------------
  158.      # 描绘字符串 "SP"
  159.     self.contents.font.color = system_color
  160.     self.contents.draw_text(x, y + 35, 32, 32, $data_system.words.sp)
  161.     # 计算描绘 MaxSP 所需的空间
  162.     if width - 32 >= 108
  163.       sp_x = x + width - 108
  164.       flag = true
  165.     elsif width - 32 >= 48
  166.       sp_x = x + width - 48
  167.       flag = false
  168.     end
  169.     # 描绘 SP
  170.     self.contents.font.color = actor.sp == 0 ? knockout_color :
  171.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  172.     self.contents.draw_text(sp_x, y + 35, 48, 32, actor.sp.to_s, 2)
  173.     # 描绘 MaxSP
  174.     if flag
  175.       self.contents.font.color = normal_color
  176.       self.contents.draw_text(sp_x + 48, y + 35, 12, 32, "/", 1)
  177.       self.contents.draw_text(sp_x + 60, y + 35, 48, 32, actor.maxsp.to_s)
  178.     end
  179.     #-----------------------------------------------------------------------
  180.     # 初描画の場合
  181.     if @sp_gauge[actor] == nil
  182.       # ゲージ高
  183.       height = 10
  184.       # 色設定。color1:外枠,color2:中枠
  185.       # color3:空ゲージダークカラー,color4:空ゲージライトカラー
  186.       color1 = Color.new(0, 0, 0, 192)
  187.       color2 = Color.new(255, 255, 192, 192)
  188.       color3 = Color.new(0, 64, 64, 192)
  189.       color4 = Color.new(0, 0, 0, 192)
  190.       # 空ゲージの描画
  191.       @sp_frame = gauge_rect(width, height, color1, color2, color3, color4)
  192.       sprite = Sprite.new(self.viewport)
  193.       sprite.bitmap = Bitmap.new(width, height)
  194.       sprite.x = self.x + x + 16
  195.       sprite.y = self.y + y + 42 - height
  196.       sprite.z = self.z + 1
  197.       count = rand(400)
  198.       # 変数rateに 現在のHP/MHPを代入
  199.       if actor.maxsp != 0
  200.         rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil
  201.       else
  202.         rate = width - 4
  203.       end
  204.       # 位置等情報の記憶
  205.       @sp_gauge[actor] = [sprite, actor, rate, count, x, y - height + 35]
  206.       # ゲージ描画
  207.       gauge_refresh(@sp_gauge[actor], 1)
  208.       # ターゲットウィンドウの場合、初期状態は非表示
  209.       @sp_gauge[actor][0].visible = false if self.is_a?(Window_Target)
  210.     end
  211.     # 変数rateに 現在のHP/MHPを代入
  212.     if actor.maxsp != 0
  213.       rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil
  214.     else
  215.       rate = width - 4
  216.     end
  217.     @sp_gauge[actor][2] = rate
  218.     # オリジナルのHP描画処理を呼び出し
  219.     draw_actor_sp_hpsp(actor, x, y, width)
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 空ゲージの描画
  223.   #--------------------------------------------------------------------------
  224.   def gauge_rect(width, height, color1, color2, color3, color4)
  225.     bitmap = Bitmap.new(width, height)
  226.     # 枠描画
  227.     bitmap.fill_rect(0, 0, width, height, color1)
  228.     bitmap.fill_rect(1, 1, width - 2, height - 2, color2)
  229.     # 空ゲージの描画
  230.     bitmap.gradation_rect(2, 2, width-4, height-4, color3, color4, 1)
  231.     return bitmap
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● 実ゲージの更新
  235.   #--------------------------------------------------------------------------
  236.   def gauge_refresh(gauge, type)
  237.     # タイプにより分岐
  238.     case type
  239.     when 0 # HPゲージの場合
  240.       graphic = RPG::Cache.system("Gauge_HP")
  241.       rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)
  242.       point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)
  243.       frame = @hp_frame
  244.     when 1 # SPゲージの場合
  245.       graphic = RPG::Cache.system("Gauge_SP")
  246.       rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)
  247.       point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)
  248.       frame = @sp_frame
  249.     end
  250.     # カウントの更新
  251.     gauge[3] = (gauge[3] - 2) % 400
  252.     # 空ゲージのの描画
  253.     gauge[0].bitmap.fill_rect(0, 0, gauge[0].bitmap.width,
  254.       gauge[0].bitmap.height, Color.new(0, 0, 0, 0))
  255.     gauge[0].bitmap.blt(0, 0, frame, frame.rect)
  256.     # ゲージの中身を描画可能な場合
  257.     if gauge[2] > 0
  258.       # 実ゲージの描画
  259.       gauge[0].bitmap.blt(2, 2, graphic,
  260.         Rect.new(gauge[3], point, gauge[2], gauge[0].bitmap.height - 4), 192)
  261.       gauge[0].bitmap.fill_rect(3, 3, gauge[2] - 2,
  262.         gauge[0].bitmap.height - 6,Color.new(0, 0, 0, 0))
  263.       gauge[0].bitmap.blt(3, 3, graphic,
  264.         Rect.new(gauge[3]+1,point+1,gauge[2]-2,gauge[0].bitmap.height- 6), 128)
  265.     end
  266.     # ゲージ座標の更新
  267.     gauge[0].x = [self.x - self.ox + gauge[4] + 16, self.x + 16].max
  268.     gauge[0].y = [self.y - self.oy + gauge[5] + 42, self.y + 16].max
  269.     gauge[0].src_rect = Rect.new([self.ox - gauge[4], 0].max,
  270.       [self.oy - gauge[5] - 26, 0].max,
  271.       [self.ox + self.width - gauge[4] - 32, gauge[0].bitmap.width].min,
  272.       [self.oy + self.height - gauge[5] - 32, gauge[0].bitmap.height].min)
  273.     gauge[0].visible = self.visible
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● ウィンドウ X 座標の更新
  277.   #--------------------------------------------------------------------------
  278.   def x=(new_x)
  279.     super(new_x)
  280.     if @hp_gauge != nil
  281.       # HP ゲージの更新
  282.       for gauge in @hp_gauge.values + @sp_gauge.values
  283.         gauge[0].x = self.x + gauge[4] + 16
  284.       end
  285.     end
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● ウィンドウ Y 座標の更新
  289.   #--------------------------------------------------------------------------
  290.   def y=(new_y)
  291.     super(new_y)
  292.     if @hp_gauge != nil
  293.       # HP ゲージの更新
  294.       for gauge in @hp_gauge.values + @sp_gauge.values
  295.         gauge[0].y = self.y + gauge[5] + 42
  296.       end
  297.     end
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● ウィンドウ Z 座標の更新
  301.   #--------------------------------------------------------------------------
  302.   def z=(new_z)
  303.     super(new_z)
  304.     if @hp_gauge != nil
  305.       # HP ゲージの更新
  306.       for gauge in @hp_gauge.values + @sp_gauge.values
  307.         gauge[0].z = self.z + 1
  308.       end
  309.     end
  310.   end
  311. end

  312. #==============================================================================
  313. # ■ Window_Help
  314. #------------------------------------------------------------------------------
  315. #  スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。
  316. #==============================================================================

  317. class Window_Help < Window_Base
  318.   #--------------------------------------------------------------------------
  319.   # ● テキスト設定
  320.   #     text  : ウィンドウに表示する文字列
  321.   #     align : アラインメント (0..左揃え、1..中央揃え、2..右揃え)
  322.   #--------------------------------------------------------------------------
  323.   alias :gauge_set_text :set_text
  324.   def set_text(text, align = 0)
  325.     # テキストとアラインメントの少なくとも一方が前回と違っている場合
  326.     if text != @text or align != @align
  327.       # ゲージの削除
  328.       gauge_delete
  329.       # オリジナルの処理
  330.       gauge_set_text(text, align)
  331.     end
  332.     self.visible = true
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ● アクター設定
  336.   #     actor : ステータスを表示するアクター
  337.   #--------------------------------------------------------------------------
  338.   alias :gauge_set_actor :set_actor
  339.   def set_actor(actor)
  340.     if actor != @actor
  341.       # ゲージの削除
  342.       gauge_delete
  343.       # オリジナルの処理
  344.       gauge_set_actor(actor)
  345.     end
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● エネミー設定
  349.   #     enemy : 名前とステートを表示するエネミー
  350.   #--------------------------------------------------------------------------
  351.   alias :gauge_set_enemy :set_enemy
  352.   def set_enemy(enemy)
  353.     # ゲージの削除
  354.     gauge_delete
  355.     # オリジナルの処理
  356.     gauge_set_enemy(enemy)
  357.   end
  358. end

  359. #==============================================================================
  360. # ■ Window_BattleStatus
  361. #------------------------------------------------------------------------------
  362. #  バトル画面でパーティメンバーのステータスを表示するウィンドウです。
  363. #==============================================================================

  364. class Window_BattleStatus < Window_Base
  365.   #--------------------------------------------------------------------------
  366.   # ● オブジェクト初期化
  367.   #--------------------------------------------------------------------------
  368.   alias :initialize_btgauge :initialize
  369.   def initialize
  370.     initialize_btgauge
  371.     self.z += 10
  372.   end
  373. end

  374. #==============================================================================
  375. # ■ Spriteset_Battle
  376. #------------------------------------------------------------------------------
  377. #  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
  378. # スの内部で使用されます。
  379. #==============================================================================

  380. class Spriteset_Battle
  381.   #--------------------------------------------------------------------------
  382.   # ● オブジェクト初期化
  383.   #--------------------------------------------------------------------------
  384.   def initialize
  385.     # ビューポートを作成
  386.     @viewport1 = Viewport.new(0, 0, 640, 320)
  387.     @viewport2 = Viewport.new(0, 0, 640, 480)
  388.     @viewport3 = Viewport.new(0, 0, 640, 480)
  389.     @viewport4 = Viewport.new(0, 0, 640, 480)
  390.     @viewport5 = Viewport.new(0, 0, 640, 480)
  391.     @viewport2.z = 120
  392.     @viewport3.z = 200
  393.     @viewport4.z = 5000
  394.     @viewport5.z = 110
  395.     # バトルバックスプライトを作成
  396.     @battleback_sprite = Sprite.new(@viewport1)
  397.     # エネミースプライトを作成
  398.     @enemy_sprites = []
  399.     for enemy in $game_troop.enemies.reverse
  400.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  401.     end
  402.     # アクタースプライトを作成
  403.     @actor_sprites = []
  404.     @actor_sprites.push(Sprite_Battler.new(@viewport5))
  405.     @actor_sprites.push(Sprite_Battler.new(@viewport5))
  406.     @actor_sprites.push(Sprite_Battler.new(@viewport5))
  407.     @actor_sprites.push(Sprite_Battler.new(@viewport5))
  408.     # 天候を作成
  409.     @weather = RPG::Weather.new(@viewport1)
  410.     # ピクチャスプライトを作成
  411.     @picture_sprites = []
  412.     for i in 51..100
  413.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  414.         $game_screen.pictures[i]))
  415.     end
  416.     # タイマースプライトを作成
  417.     @timer_sprite = Sprite_Timer.new
  418.     # フレーム更新
  419.     update
  420.   end
  421. end

  422. #==============================================================================
  423. # ■ Bitmap
  424. #------------------------------------------------------------------------------
  425. #  Bitmapクラスに新たな機能を追加します。
  426. #==============================================================================

  427. class Bitmap
  428.   #--------------------------------------------------------------------------
  429.   # ● 矩形をグラデーション表示
  430.   #     color1 : スタートカラー
  431.   #     color2 : エンドカラー
  432.   #     align  :  0:横にグラデーション
  433.   #               1:縦にグラデーション
  434.   #               2:斜めにグラデーション(激重につき注意)
  435.   #--------------------------------------------------------------------------
  436.   def gradation_rect(x, y, width, height, color1, color2, align = 0)
  437.     if align == 0
  438.       for i in x...x + width
  439.         red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
  440.         green = color1.green +
  441.                 (color2.green - color1.green) * (i - x) / (width - 1)
  442.         blue  = color1.blue +
  443.                 (color2.blue - color1.blue) * (i - x) / (width - 1)
  444.         alpha = color1.alpha +
  445.                 (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  446.         color = Color.new(red, green, blue, alpha)
  447.         fill_rect(i, y, 1, height, color)
  448.       end
  449.     elsif align == 1
  450.       for i in y...y + height
  451.         red   = color1.red +
  452.                 (color2.red - color1.red) * (i - y) / (height - 1)
  453.         green = color1.green +
  454.                 (color2.green - color1.green) * (i - y) / (height - 1)
  455.         blue  = color1.blue +
  456.                 (color2.blue - color1.blue) * (i - y) / (height - 1)
  457.         alpha = color1.alpha +
  458.                 (color2.alpha - color1.alpha) * (i - y) / (height - 1)
  459.         color = Color.new(red, green, blue, alpha)
  460.         fill_rect(x, i, width, 1, color)
  461.       end
  462.     elsif align == 2
  463.       for i in x...x + width
  464.         for j in y...y + height
  465.           red   = color1.red + (color2.red - color1.red) *
  466.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  467.           green = color1.green + (color2.green - color1.green) *
  468.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  469.           blue  = color1.blue + (color2.blue - color1.blue) *
  470.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  471.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  472.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  473.           color = Color.new(red, green, blue, alpha)
  474.           set_pixel(i, j, color)
  475.         end
  476.       end
  477.     elsif align == 3
  478.       for i in x...x + width
  479.         for j in y...y + height
  480.           red   = color1.red + (color2.red - color1.red) *
  481.             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  482.           green = color1.green + (color2.green - color1.green) *
  483.             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  484.           blue  = color1.blue + (color2.blue - color1.blue) *
  485.             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  486.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  487.             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  488.           color = Color.new(red, green, blue, alpha)
  489.           set_pixel(i, j, color)
  490.         end
  491.       end
  492.     end
  493.   end
  494. end

  495. #==============================================================================
  496. # ■ Spriteモジュール
  497. #------------------------------------------------------------------------------
  498. #  アニメーションの管理を行うモジュールです。
  499. #==============================================================================

  500. module RPG
  501.   class Sprite < ::Sprite
  502.     def damage(value, critical)
  503.       dispose_damage
  504.       if value.is_a?(Numeric)
  505.         damage_string = value.abs.to_s
  506.       else
  507.         damage_string = value.to_s
  508.       end
  509.       bitmap = Bitmap.new(160, 48)
  510.       bitmap.font.name = "Arial Black"
  511.       bitmap.font.size = 32
  512.       bitmap.font.color.set(0, 0, 0)
  513.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  514.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  515.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  516.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  517.       if value.is_a?(Numeric) and value < 0
  518.         bitmap.font.color.set(176, 255, 144)
  519.       else
  520.         bitmap.font.color.set(255, 255, 255)
  521.       end
  522.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  523.       if critical
  524.         bitmap.font.size = 20
  525.         bitmap.font.color.set(0, 0, 0)
  526.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  527.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  528.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  529.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  530.         bitmap.font.color.set(255, 255, 255)
  531.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  532.       end
  533.       @_damage_sprite = ::Sprite.new
  534.       @_damage_sprite.bitmap = bitmap
  535.       @_damage_sprite.ox = 80 + self.viewport.ox
  536.       @_damage_sprite.oy = 20 + self.viewport.oy
  537.       @_damage_sprite.x = self.x + self.viewport.rect.x
  538.       @_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
  539.       @_damage_sprite.z = 3000
  540.       @_damage_duration = 40
  541.     end
  542.     def animation(animation, hit)
  543.       dispose_animation
  544.       @_animation = animation
  545.       return if @_animation == nil
  546.       @_animation_hit = hit
  547.       @_animation_duration = @_animation.frame_max
  548.       animation_name = @_animation.animation_name
  549.       animation_hue = @_animation.animation_hue
  550.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  551.       if @@_reference_count.include?(bitmap)
  552.         @@_reference_count[bitmap] += 1
  553.       else
  554.         @@_reference_count[bitmap] = 1
  555.       end
  556.       @_animation_sprites = []
  557.       if @_animation.position != 3 or not @@_animations.include?(animation)
  558.         for i in 0..15
  559.           sprite = ::Sprite.new
  560.           sprite.bitmap = bitmap
  561.           sprite.visible = false
  562.           @_animation_sprites.push(sprite)
  563.         end
  564.         unless @@_animations.include?(animation)
  565.           @@_animations.push(animation)
  566.         end
  567.       end
  568.       update_animation
  569.     end
  570.     def loop_animation(animation)
  571.       return if animation == @_loop_animation
  572.       dispose_loop_animation
  573.       @_loop_animation = animation
  574.       return if @_loop_animation == nil
  575.       @_loop_animation_index = 0
  576.       animation_name = @_loop_animation.animation_name
  577.       animation_hue = @_loop_animation.animation_hue
  578.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  579.       if @@_reference_count.include?(bitmap)
  580.         @@_reference_count[bitmap] += 1
  581.       else
  582.         @@_reference_count[bitmap] = 1
  583.       end
  584.       @_loop_animation_sprites = []
  585.       for i in 0..15
  586.         sprite = ::Sprite.new
  587.         sprite.bitmap = bitmap
  588.         sprite.visible = false
  589.         @_loop_animation_sprites.push(sprite)
  590.       end
  591.       update_loop_animation
  592.     end
  593.     def animation_set_sprites(sprites, cell_data, position)
  594.       for i in 0..15
  595.         sprite = sprites[i]
  596.         pattern = cell_data[i, 0]
  597.         if sprite == nil or pattern == nil or pattern == -1
  598.           sprite.visible = false if sprite != nil
  599.           next
  600.         end
  601.         sprite.visible = true
  602.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  603.         if position == 3
  604.           if self.viewport != nil
  605.             sprite.x = self.viewport.rect.width / 2
  606.             sprite.y = self.viewport.rect.height - 160
  607.           else
  608.             sprite.x = 320
  609.             sprite.y = 240
  610.           end
  611.         else
  612.           sprite.x = self.x + self.viewport.rect.x -
  613.                       self.ox + self.src_rect.width / 2
  614.           sprite.y = self.y + self.viewport.rect.y -
  615.                       self.oy + self.src_rect.height / 2
  616.           sprite.y -= self.src_rect.height / 4 if position == 0
  617.           sprite.y += self.src_rect.height / 4 if position == 2
  618.         end
  619.         sprite.x += cell_data[i, 1]
  620.         sprite.y += cell_data[i, 2]
  621.         sprite.z = 2000
  622.         sprite.ox = 96
  623.         sprite.oy = 96
  624.         sprite.zoom_x = cell_data[i, 3] / 100.0
  625.         sprite.zoom_y = cell_data[i, 3] / 100.0
  626.         sprite.angle = cell_data[i, 4]
  627.         sprite.mirror = (cell_data[i, 5] == 1)
  628.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  629.         sprite.blend_type = cell_data[i, 7]
  630.       end
  631.     end
  632.   end
  633. end


  634. #==============================================================================
  635. # ■ RPG
  636. #------------------------------------------------------------------------------
  637. #  基本モジュールです
  638. #==============================================================================

  639. module RPG
  640.   #============================================================================
  641.   # ■ Cache
  642.   #----------------------------------------------------------------------------
  643.   #  画像処理を行うモジュールです。
  644.   #============================================================================
  645.   module Cache
  646.     def self.system(filename)
  647.       self.load_bitmap("Graphics/Pictures/", filename)
  648.     end
  649.   end
  650. end
复制代码
看看是不是,我也新手。

点评

唔……不行呢~  发表于 2012-4-14 07:51
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2025-7-19 20:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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