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

Project1

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

[已经解决] Feng_人物行走优化脚本问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
96
在线时间
81 小时
注册时间
2015-6-30
帖子
48
跳转到指定楼层
1
发表于 2015-7-1 13:53:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 丿梁丶小柒 于 2015-7-4 13:32 编辑

RUBY 代码复制
  1. #使用方法:在角色行走图片名中添加"[s5][m8]",则表示静止时每方向5张图片,移动时8张。
  2. #图片命名中如果有"[s5]"或者"[m8]"这样的字符串,则按给出的数字划分行走图,
  3. #否则按程序默认的方式划分         ---By 风宥雪
  4. #静止站立图也支持动态效果。
  5. class Sprite_Character < Sprite_Base
  6.   #--------------------------------------------------------------------------
  7.   # ● 设置角色的位图
  8.   #--------------------------------------------------------------------------
  9.   alias old_set_character_bitmap set_character_bitmap
  10.   def set_character_bitmap
  11.     @character.frame_total = 0         #记住要归零化
  12.     @character.change = false
  13.     if @character_name =~ /\[s(\d+)\]/i
  14.       @character.frame_s = $1.to_i     #匹配静止帧数
  15.       @character.change = true
  16.       @character.frame_total += @character.frame_s
  17.     else
  18.       @character.frame_s = 0
  19.     end
  20.     if @character_name =~ /\[m(\d+)\]/i
  21.       @character.frame_m = $1.to_i     #匹配移动帧数
  22.       @character.change = true
  23.       @character.frame_total += @character.frame_m
  24.     else
  25.       @character.frame_m  = 0
  26.     end
  27.     if @character.change
  28.       if @character.frame_total == 0
  29.         msgbox("你的人物行走图命名有问题,请仔细检查!用[s5][m8]表示静止5帧,行走8帧!")
  30.         return
  31.       else
  32.         self.bitmap = Cache.character(@character_name)
  33.         @cw = bitmap.width / @character.frame_total
  34.         @ch = bitmap.height / 4
  35.         self.ox = @cw / 2
  36.         self.oy = @ch
  37.       end
  38.     else #沿用原来的情况
  39.       old_set_character_bitmap
  40.       @character.frame_s = 3
  41.     end
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 更新源矩形
  45.   #--------------------------------------------------------------------------
  46.   alias old_update_src_rect update_src_rect
  47.   def update_src_rect
  48.     if @character.change
  49.       if @tile_id == 0
  50.       index = @character.character_index
  51.       pattern = @character.pattern
  52.       sx = pattern * @cw
  53.       sy = (@character.direction - 2) / 2 * @ch
  54.       self.src_rect.set(sx, sy, @cw, @ch)
  55.       end
  56.     else
  57.     old_update_src_rect
  58.     end
  59.   end
  60. end
  61.  
  62. class Game_CharacterBase
  63.   attr_accessor   :move_speed               # 移动速度
  64.   attr_accessor   :frame_m                  # 移动图片帧数(默认每个方向3张)
  65.   attr_accessor   :frame_s                  # 静止图片动态帧数(0表示没动态)
  66.   attr_accessor   :frame_total              # 更改总帧数
  67.   attr_accessor   :change                   # 是否更改默认
  68.   alias old_init initialize
  69.   def initialize
  70.     old_init
  71.     @move_speed = 4
  72.     @frame_m = 3
  73.     @frame_s = 0
  74.     @frame_total = 0
  75.     @change = false
  76.     @original_pattern = 0
  77.   end
  78.  
  79.   alias old_set_graphic set_graphic
  80.   def set_graphic(character_name, character_index)
  81.     old_set_graphic(character_name, character_index)
  82.     @original_pattern = 0
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 更改方向,不需要重置stop_count
  86.   #--------------------------------------------------------------------------
  87.   def set_direction(d)
  88.     @direction = d if !@direction_fix && d != 0
  89.   end
  90. end
  91.  
  92. class Game_Character < Game_CharacterBase
  93.   #--------------------------------------------------------------------------
  94.   # ● 更新动画图案
  95.   #--------------------------------------------------------------------------
  96.   def update_anime_pattern
  97.     #1.静止时,有无动态图
  98.     if (!@step_anime && @stop_count > 0)
  99.       if @frame_s == 0 #无动态图,则采用行走图
  100.         @pattern = (@pattern + 1) % @frame_m
  101.       else             #有动态图
  102.         @pattern = (@pattern + 1) % @frame_s
  103.       end
  104.     #踏步动画或移动中时
  105.     else
  106.       if @frame_m == 0 #无行走图,则采用静止动态图
  107.         @pattern = (@pattern + 1) % @frame_s
  108.       else             #有行走图则采用行走图
  109.         @pattern = @frame_s + (@pattern - @frame_s + 1) % @frame_m
  110.       end
  111.     end
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 更新动画计数
  115.   #--------------------------------------------------------------------------
  116.   def update_anime_count
  117.     if moving? && @walk_anime
  118.       @anime_count += 1.5
  119.     elsif @step_anime || @pattern != @original_pattern || @frame_s > 1 || @walk_anime#静止有动态图时也要更新计数
  120.       @anime_count += 0.75
  121.     end
  122.   end
  123. end
  124.  
  125. #~ #==============================================================================
  126. #~ # ■ Game_Player
  127. #~ #------------------------------------------------------------------------------
  128. #~ #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
  129. #~ #   本类的实例请参考 $game_player 。
  130. #~ #==============================================================================
  131. #~ class Game_Player < Game_Character
  132. #~   #--------------------------------------------------------------------------
  133. #~   # ● 更新动画图案,添加了玩家移动时的脚步声。
  134. #~   #--------------------------------------------------------------------------
  135. #~   def update_anime_pattern
  136. #~     super
  137. #~       Audio.me_play("Audio/ME/脚步声") unless (!@step_anime && @stop_count > 0)
  138. #~   end
  139. #~ end



游戏中我不想人物在静止时也有行走动作该怎么更改?求大神指点

Lv2.观梦者

永无止境的旅程

梦石
0
星屑
503
在线时间
1552 小时
注册时间
2012-6-19
帖子
1226

开拓者贵宾

2
发表于 2015-7-4 13:33:23 | 只看该作者
[url=https://rpg.blue/thread-389697-1-1.html]https://rpg.blue/https://rpg.blue/data/attachment/forum/201602/26/220128cfbxxs47xth4xkz4.jpg[/url]
&lt;font size=&quot;5&quot;&gt;[color=Green][url=https://rpg.blue/forum.php?mod=viewthread&amp;tid=396208&amp;extra=page%3D1][color=DeepSkyBlue]全新配套ACT系统,每周末一大更新,尽请期待。[/color][/url][/color]
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 18:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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