查看: 1746|回复: 7

[已经解决] 图片随文本一起消失

[复制链接]
梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
发表于 2022-10-29 11:01:17 | 显示全部楼层 |阅读模式

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

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

×
下面的脚本如何让地图名消失的时候,图片也一起消失,我加了个全局变量放着控制也没效果。。

[pre lang="ruby"]class Window_Map_Name < Window_Base
  def initialize
    super(1024/2-180/2, 60, 180, 64)
    self.contents = Bitmap.new(width-32, height-32)
    @showing_time = 0
    @text_color = Color.new(255,255,255,255)
  end
  def set_text(text, align = 2)
    if text != @text or align != @align
      self.contents.clear
      @showing_time = 100
      @text = text
      @align = align
      @actor = nil
      self.contents_opacity = 255
      x = 4
      y = 0
      self.contents.font.color = Color.new( 0, 0, 0, 192)
      self.contents.draw_text(x+2, y+2, self.width - 40, 32, "-"+text+"-",align=1)     
      self.contents.font.color = Color.new( 64, 64, 64, 192)
      self.contents.draw_text(x-1, y-1, self.width - 40, 32, "-"+text+"-", align=1)     
      self.contents.draw_text(x+1, y-1, self.width - 40, 32, "-"+text+"-", align=1)
      self.contents.draw_text(x-1, y+1, self.width - 40, 32, "-"+text+"-", align=1)
      self.contents.draw_text(x+1, y+1, self.width - 40, 32, "-"+text+"-", align=1)
      self.contents.font.color = @text_color
      self.contents.draw_text(x, y, self.width - 40, 32, "-"+text+"-", align=1)   
    else
      @showing_time -= 1
      if @showing_time < 100
        self.contents_opacity = @showing_time * 100
      elsif @showing_time <= 0
        self.contents.clear
        $图片消失 = true
      end
    end
      self.visible = true
    end
  end
class Scene_Map
  alias xrxs20_main main
  def main
    @map_name_window = Window_Map_Name.new
    @map_name_window.opacity = 0
   
    # 生成地图名背景图
    @map_picture = Sprite.new
    @map_picture.bitmap = Bitmap.new("Graphics/Pictures/Ui/主界面/地图名背景")
    if $图片消失 == true
      @map_picture.opacity = 100
    else
      @map_picture.opacity = 0
    end
    @map_picture.x = 1024/2-180/2
    @map_picture.y = 77
    @map_picture.z = 20
   
    xrxs20_main
    @map_name_window.dispose
   
    # 释放地图名背景图
    @map_picture.dispose
    @map_picture.bitmap.dispose
  end
  alias xrxs20_update update
  def update
    # 更新地图名
    @map_name_window.set_text($game_map.name,1)
    xrxs20_update
  end
end
class Scene_Title
  alias xrxs20_main main
  def main
    $map_infos = load_data("Data/MapInfos.rxdata")
    for key in $map_infos.keys
      $map_infos[key] = $map_infos[key].name
    end
      xrxs20_main
  end
end
class Game_Map
  def name
    $map_infos[@map_id]
  end
end
[/pre]
梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
发表于 2022-10-29 11:14:16 | 显示全部楼层
地图上设个执行并处理的事件,事件条件分歧角色在当前地图时候使用脚本class Scene_Map否者事件消失
回复

使用道具 举报

梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
回帖
81
发表于 2022-10-29 11:39:32 | 显示全部楼层
@showing_time为0的时候self.visible=false
地图刷新里@map_picture.visible=@map_name_window.visible

评分

参与人数 1星屑 +50 赞 +1 收起 理由
RyanBern + 50 + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-10-29 11:55:37 | 显示全部楼层
我为鱼肉 发表于 2022-10-29 11:39
@showing_time为0的时候self.visible=false
地图刷新里@map_picture.visible=@map_name_window.visible ...

      @showing_time -= 1
      if @showing_time < 100
        self.contents_opacity = @showing_time * 100
      elsif @showing_time <= 0
        self.contents.clear
        self.visible = false
      end
  
def update
    # 更新地图名
    @map_name_window.set_text($game_map.name,1)
    @map_picture.visible = @map_name_window.visible
    xrxs20_update
  end

我最开始是这么设置的,后来还是文字消失了,图片还在,不明所以

点评

把31行elsif改为if,对应下方加个end  发表于 2022-10-29 12:37
还是不行  发表于 2022-10-29 12:14
36行放到26行下面self.visible = true  发表于 2022-10-29 12:03
回复

使用道具 举报

梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-10-29 12:45:06 | 显示全部楼层
黑米馒头 发表于 2022-10-29 11:55
@showing_time -= 1
      if @showing_time < 100
        self.contents_opacity = @showing_t ...

可以了,感谢
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部