Project1

标题: XP行走图自动适配到VA中的脚本 [打印本页]

作者: 晴兰    时间: 2012-12-5 01:47
提示: 作者被禁止或删除 内容自动屏蔽
作者: 896409879    时间: 2012-12-5 05:38
晴兰大人终于发了点我看得懂的东西了~
不过现在没几个人用xp的行走图了吧~即使感觉va默认不爽也会用tekepon的。。。。
作者: satgo1546    时间: 2012-12-5 19:13
XP行走图的一大亮点就是有4列,VA只有3列。我还是觉得自己PS一下……然后编辑器里也方便多了。

作者: c248611    时间: 2012-12-5 19:17
本帖最后由 c248611 于 2012-12-5 19:19 编辑


RUBY 代码复制
  1. #==============================================================================
  2. # ■ XP行走方式
  3. #------------------------------------------------------------------------------
  4. #    适用于:RPG Maker VX Ace
  5. #    说明:把脚本放在Main的前面。
  6. #    所需素材:RPG Maker XP 的行走图,例如:001-Fighter01.PNG
  7. #==============================================================================
  8.  
  9. #==============================================================================
  10. # ■ Sprite_Character
  11. #------------------------------------------------------------------------------
  12. #  角色显示用脚本。监视 Game_Character 类的实例、
  13. # 自动变化脚本状态。
  14. #==============================================================================
  15.  
  16. class Sprite_Character < Sprite_Base
  17.   #--------------------------------------------------------------------------
  18.   # ● 定量
  19.   #--------------------------------------------------------------------------
  20.   BALLOON_WAIT = 12                  # 表情最后帧的等待时间
  21.   #--------------------------------------------------------------------------
  22.   # ● 定义实例变量
  23.   #--------------------------------------------------------------------------
  24.   attr_accessor :character                # 角色
  25.   #--------------------------------------------------------------------------
  26.   # ● 初始化对像
  27.   #     viewport  : 查看端口
  28.   #     character : 角色 (Game_Character)
  29.   #--------------------------------------------------------------------------
  30.   def initialize(viewport, character = nil)
  31.     super(viewport)
  32.     @character = character
  33.     @balloon_duration = 0
  34.     update
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 释放
  38.   #--------------------------------------------------------------------------
  39.   def dispose
  40.     dispose_balloon
  41.     super
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 刷新画面
  45.   #--------------------------------------------------------------------------
  46.   def update
  47.     super
  48.     update_bitmap
  49.     self.visible = (not @character.transparent)
  50.     update_src_rect
  51.     self.x = @character.screen_x
  52.     self.y = @character.screen_y
  53.     self.z = @character.screen_z
  54.     self.opacity = @character.opacity
  55.     self.blend_type = @character.blend_type
  56.     self.bush_depth = @character.bush_depth
  57.     update_balloon
  58.     if @character.animation_id != 0
  59.       animation = $data_animations[@character.animation_id]
  60.       start_animation(animation)
  61.       @character.animation_id = 0
  62.     end
  63.     if @character.balloon_id != 0
  64.       @balloon_id = @character.balloon_id
  65.       start_balloon
  66.       @character.balloon_id = 0
  67.     end
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 获取图块图像的指定图块
  71.   #     tile_id : 图块 ID
  72.   #--------------------------------------------------------------------------
  73.   def tileset_bitmap(tile_id)
  74.     set_number = tile_id / 256
  75.     return Cache.system("TileB") if set_number == 0
  76.     return Cache.system("TileC") if set_number == 1
  77.     return Cache.system("TileD") if set_number == 2
  78.     return Cache.system("TileE") if set_number == 3
  79.     return nil
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● 更新画面
  83.   #--------------------------------------------------------------------------
  84.   def update_bitmap
  85.     if @tile_id != @character.tile_id or
  86.        @character_name != @character.character_name or
  87.        @character_index != @character.character_index
  88.       @tile_id = @character.tile_id
  89.       @character_name = @character.character_name
  90.       @character_index = @character.character_index
  91.       if @tile_id > 0
  92.         self.bitmap = Cache.tile($game_map.tileset_name,
  93.           @tile_id)
  94.         self.src_rect.set(0, 0, 32, 32)
  95.         self.ox = 16
  96.         self.oy = 32
  97.       # 元件 ID 为无效值的情况下
  98.       else
  99.         self.bitmap = Cache.character(@character.character_name)
  100.         @cw = bitmap.width / 4
  101.         @ch = bitmap.height / 4
  102.         self.ox = @cw / 2
  103.         self.oy = @ch
  104.      end
  105.    end
  106. end
  107.   #--------------------------------------------------------------------------
  108.   # ● 刷新传送的矩形数据
  109.   #--------------------------------------------------------------------------
  110.   def update_src_rect
  111.     if @tile_id == 0
  112. #     index = @character.character_index
  113. #     pattern = @character.pattern < 3 ? @character.pattern : 1
  114. #     sx = (pattern * 32) #* @cw
  115. #     #sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  116. #     sy = @character.direction * 32
  117. #     self.src_rect.set(sx, sy, @cw, @ch)
  118.       sx = @character.pattern * @cw
  119.       sy = (@character.direction - 2) / 2 * @ch
  120.       self.src_rect.set(sx, sy, @cw, @ch)
  121.     end
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● 开始显示表情图标
  125.   #--------------------------------------------------------------------------
  126.   def start_balloon
  127.     dispose_balloon
  128.     @balloon_duration = 8 * 8 + BALLOON_WAIT
  129.     @balloon_sprite = ::Sprite.new(viewport)
  130.     @balloon_sprite.bitmap = Cache.system("Balloon")
  131.     @balloon_sprite.ox = 16
  132.     @balloon_sprite.oy = 32
  133.     update_balloon
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 刷新表情图标
  137.   #--------------------------------------------------------------------------
  138.   def update_balloon
  139.     if @balloon_duration > 0
  140.       @balloon_duration -= 1
  141.       if @balloon_duration == 0
  142.         dispose_balloon
  143.       else
  144.         @balloon_sprite.x = x
  145.         @balloon_sprite.y = y - height
  146.         @balloon_sprite.z = z + 200
  147.         if @balloon_duration < BALLOON_WAIT
  148.           sx = 7 * 32
  149.         else
  150.           sx = (7 - (@balloon_duration - BALLOON_WAIT) / 8) * 32
  151.         end
  152.         sy = (@balloon_id - 1) * 32
  153.         @balloon_sprite.src_rect.set(sx, sy, 32, 32)
  154.       end
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 释放表情图标
  159.   #--------------------------------------------------------------------------
  160.   def dispose_balloon
  161.     if @balloon_sprite != nil
  162.       @balloon_sprite.dispose
  163.       @balloon_sprite = nil
  164.     end
  165.   end
  166. end

作者: a886qqsd    时间: 2012-12-6 18:53
4楼,你什么意思,你寓意何在




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1