Project1

标题: 如何用Sprite做显示ARPG群战的角色头像 [打印本页]

作者: 金芒芒    时间: 2023-4-8 15:58
标题: 如何用Sprite做显示ARPG群战的角色头像
用class Sprite_Character < RPG::Sprite
还是用class Sprite_map < RPG::Sprite





RUBY 代码复制
  1. class Window_kg_status < Window_Base
  2. class Sprite_Character < RPG::Sprite
  3.  
  4.   #我方  
  5.   def initialize(actor_id, window_index)
  6.     super(540 - window_index * 76 , 540, 117, 190)
  7.     @actor_id = actor_id
  8.     self.contents = Bitmap.new(width - 1, height- 1 )
  9.     self.opacity = 0
  10.     refresh
  11.   end
  12.  
  13.   def dispose
  14.     super
  15.   end
  16.  
  17.   def refresh
  18.     self.contents.clear
  19.     #draw_actor_name($game_actors[@actor_id], 0, 0)
  20.     draw_actor_picture($game_actors[@actor_id].battler_name, $game_actors[@actor_id].battler_hue, -1 ,+1)
  21.     draw_actor_hp($game_actors[@actor_id], 1, 110)
  22.     draw_actor_sp($game_actors[@actor_id], 134, 135)
  23.     draw_actor_cp($game_actors[@actor_id], 134, 160)
  24.   end
  25.  
  26.   class Window_Base < Window
  27.   #我方
  28.   def draw_actor_cp(actor, x, y, width = 90, height = 15)
  29.     w = [actor.cp, 100].min / 100 * width
  30.     self.contents.fill_rect(x, y, width,height,Color.new(0,0,0))
  31.     self.contents.fill_rect(x, y + 1 , width,height -2,Color.new(255, 255, 128))
  32.     self.contents.fill_rect(x + 1, y + 1, w, height -2,Color.new(255,255,255))
  33.   end
  34.  
  35.   def draw_actor_picture(actor_name, actor_hue, x, y)
  36.     bitmap = RPG::Cache.battler(actor_name,actor_hue)
  37.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  38.     self.contents.blt(x, y, bitmap, src_rect)
  39.   end

队标id.png (651.41 KB, 下载次数: 7)

队标id.png

完成.png (220.89 KB, 下载次数: 4)

完成.png





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