查看: 1812|回复: 3

[已经过期] Npc头上显示姓名得姓名文字如何赋Z值

[复制链接]
梦石
0
星屑
50
在线时间
70 小时
注册时间
2014-10-11
回帖
38
发表于 2015-2-12 21:49:38 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 风晴生 于 2015-2-12 22:39 编辑

RT 我用了头上显示姓名的脚本  出现了这种情况

制作历程29 ——图标分类.png   大家看 上面 "士兵" 两个字把路易斯的身体遮住了  这样是不是很奇怪呢?

我希望 姓名和行走图一样 有一个 z 坐标 为所处屏幕的z坐标  

我记得以前实现过 后来又忘了该怎么办了 忘大神们赐教。

附上脚本
[pre lang="ruby"]#==============================================================================
# ■ Game_Event
#------------------------------------------------------------------------------
#  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
# 在 Game_Map 类的内部使用。
#==============================================================================
class Game_Event < Game_Character
#——————————————————————————————————————
# 用来返回名称
#——————————————————————————————————————
def name
   return @event.name
end   
def name=(newname)
   @event.name = newname
end
end

class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
attr_accessor :character                # 角色

  def initialize(viewport, character = nil)
    name = character.name
   # @character = character
    super(viewport)
    @showsprite = Sprite.new
    @showsprite.bitmap = Bitmap.new(100, 48)
    @showsprite.bitmap.font.name = (["微软雅黑"])
    @showsprite.bitmap.font.size = 16
    @showsprite.bitmap.font.bold = true
    @character = character
   @actor = $game_party.actors[0]
        if not  @character.is_a?(Game_Player)
    @arpg_hp = character.arpg_hp
    @arpg_hpmax = character.arpg_hpmax
  else
    @arpg_hp = @actor.hp
    @arpg_hpmax = @actor.maxhp
   
    @arpg_sp = @actor.sp
    @arpg_spmax = @actor.maxsp
    end
    @evname = name

    if @character.is_a?(Game_Player)
      @old_hp = @actor.hp
      else
      @old_hp = character.arpg_hp# @arpg_hp#@actor.hp
      end
      @old_sp = @actor.sp
      @old_level = @actor.level
      draw_character_bar
#   end
    @showsprite.x = self.x-76
    @showsprite.y = self.y-self.oy-45
    @showsprite.z = self.y
    @showsprite.visible = true#@character.is_a?(Game_Player) ? (@actor.dead? ?
                        #false : true) : false
    update
  end
  
  def draw_character_bar
    @character = character
        if not  @character.is_a?(Game_Player)
    @arpg_hp = character.arpg_hp
    @arpg_hpmax = character.arpg_hpmax
  else
    @arpg_hp = @actor.hp
    @arpg_hpmax = @actor.maxhp

    @arpg_sp = @actor.sp
    @arpg_spmax = @actor.maxsp
    end

    @showsprite = Sprite.new
    @showsprite.bitmap = Bitmap.new(150, 148)# 100 48
    @showsprite.bitmap.font.name = (["微软雅黑"])
    @showsprite.bitmap.font.size = 17  
    @showsprite.bitmap.font.bold = true
    #self.z = @showsprite.z
     if not  @character.is_a?(Game_Player)
    txt =  @evname#@actor.name
  else
    txt =  @actor.name
    end
#if $game_switches[9] == false
#   txt = ""
#   end
    if txt != "" and @evname[0, 2]!="EV" and @evname[0, 2]!="Cs"
   #   txt += " (Lv " + @actor.level.to_s + ")"   
   #  if not  @character.is_a?(Game_Player) and character.arpg_hp > 0
         txt = character.name #+ " L.v.5"  #$data_enemies[@event.id].name
   #    else
     #    txt = ""
    #   end
      @showsprite.bitmap.font.color.set(255, 255, 255)
   if character.name.split(/,/)[1] != nil   #name.split(/,/)[0]
     case character.name.split(/,/)[1]   # g绿 y黄 r红
     when "g"
        @showsprite.bitmap.font.color.set(50, 255, 50)
      when "y"
        @showsprite.bitmap.font.color.set(255, 255, 50)     
       when "r"
        @showsprite.bitmap.font.color.set(255, 0, 0)        
      end
     end
      @showsprite.bitmap.draw_text2(-5, 85, 160, 36, txt.split(/,/)[0], 1)
     # @sprite.bitmap.draw_text2(-5, 85, 160, 36, txt.split(/,/)[0], 1)
    end

   
   if @arpg_hp > 0   #and 1==2# @wait_count > 0an
     if    @character.is_a?(Game_Player) #and 1==2
    @showsprite.bitmap.fill_rect(55, 30, 42, 1, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(55, 30, 1, 5, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(55, 34, 42, 1, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(96, 30, 1, 5, Color.new(0, 0, 0,230))
    w = @arpg_hp  * 4000 / (@arpg_hpmax) / 100
    @showsprite.bitmap.fill_rect(56, 31, 40, 3, Color.new(0, 0, 0))
    @showsprite.bitmap.fill_rect(56, 31, w, 3, Color.new(0, 255, 20))
              else
                if @character.Jzjs > 0 #$game_variables[50] == @character.id  and @character.Jzjs > 0
    @showsprite.bitmap.fill_rect(55, 30, 42, 1, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(55, 30, 1, 5, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(55, 34, 42, 1, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(96, 30, 1, 5, Color.new(0, 0, 0,230))      
                  w = @arpg_hp  * 4000 / (@arpg_hpmax) / 100
                  @showsprite.bitmap.fill_rect(56, 31, 40, 3, Color.new(0, 0, 0))      
                  @showsprite.bitmap.fill_rect(56, 31, w, 3, Color.new(0, 255, 20))     
                 # txt =  @character.name
                 #  @showsprite.bitmap.font.color.set(0, 255, 0)
                #@showsprite.bitmap.draw_text(40, 10, 160, 12, txt, 1)        
                  end
          end
            #    @showsprite.bitmap.font.color.set(255, 255, 255)
            #    @showsprite.bitmap.draw_text(0, 30, 160, 12, "123", 1)
      if   @character.is_a?(Game_Player) #and 1==
       w = @arpg_sp  * 4000 / (@arpg_spmax) / 100
    @showsprite.bitmap.fill_rect(55, 36, 42, 1, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(55, 36, 1, 5, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(55, 40, 42, 1, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(96, 36, 1, 5, Color.new(0, 0, 0,230))
    @showsprite.bitmap.fill_rect(56, 37, w, 3, Color.new(20, 0, 255))
    end
  end
  end
  #--------------------------------------------------------------------------

  #--------------------------------------------------------------------------
  def update
    super
    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
        @character = character
        if not  @character.is_a?(Game_Player)
         @arpg_hp = character.arpg_hp
        @wait_count = character.wait_count
          else
       @arpg_hp = @actor.hp
       @arpg_sp = @actor.sp
        @wait_count = 1
      end
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # 记忆元件 ID 与文件名、色相
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # 元件 ID 为有效值的情况下
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # 元件 ID 为无效值的情况下
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        @cw = bitmap.width / 4
        @ch = bitmap.height / 4
      if  @character_name.include?("one")
        @cw = bitmap.width
        @ch = bitmap.height
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # 设置可视状态
    self.visible = (not @character.transparent)
    # 图形是角色的情况下
    if @tile_id == 0
      # 设置传送目标的矩形
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
  #  if @character.is_a?(Game_Player)
     if  @old_hp != @arpg_hp  or ( @character.is_a?(Game_Player) and @old_sp != @arpg_sp)
        @showsprite.dispose
        @actor = $game_party.actors[0]
        if not  @character.is_a?(Game_Player)
    @arpg_hp = character.arpg_hp
    @arpg_hpmax = character.arpg_hpmax
  else
    @arpg_hp = @actor.hp
    @arpg_hpmax = @actor.maxhp
  end
        #@old_hp = @actor.hp
        @old_sp = @actor.sp
        @old_level = @actor.level
        draw_character_bar
       # update
      end
#  end
    @showsprite.x = self.x-76
    @showsprite.y = self.y-100
   # if !@character.is_a?(Game_Player)
      #  @showsprite.x = 350
    #    @showsprite.y = 180
    #  end
       if @character.name[0, 2]!="EV"  #and @arpg_hp > 0 @evname
   @showsprite.visible = true
   #   if (not  @character.is_a?(Game_Player)) and @character.Jzjs <= 0#($game_variables[50] != @character.id)
   #       @showsprite.visible = false   
  #      end
else
   @showsprite.visible = false
   end
  
  #  @showsprite.visible = true#@character.is_a?(Game_Player) ? (@actor.dead? ?
                          #false : true) : false
                        
    # 设置脚本的坐标
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # 设置不透明度、合成方式、茂密
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # 动画
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end
#==============================================================================
class Game_Player < Game_Character
def name
   return $game_party.actors[0].name# "afa"
end
end [/pre]

梦石
0
星屑
34462
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2015-2-13 16:15:51 | 显示全部楼层
在 219 行后面加一句试试:
  1. @showsprite.z = self.y + 1
复制代码
xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

梦石
0
星屑
50
在线时间
70 小时
注册时间
2014-10-11
回帖
38
 楼主| 发表于 2015-2-13 17:59:27 | 显示全部楼层
芯☆淡茹水 发表于 2015-2-13 16:15
在 219 行后面加一句试试:

没用............
回复

使用道具 举报

梦石
0
星屑
34462
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2015-2-13 18:59:19 | 显示全部楼层
那就改成:
  1. @showsprite.z = self.z
复制代码
xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部