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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3191
在线时间
1864 小时
注册时间
2010-6-19
帖子
1205
跳转到指定楼层
1
发表于 2022-10-29 11:01:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

RUBY 代码复制
  1. class Window_Map_Name < Window_Base
  2.   def initialize
  3.     super(1024/2-180/2, 60, 180, 64)
  4.     self.contents = Bitmap.new(width-32, height-32)
  5.     @showing_time = 0
  6.     @text_color = Color.new(255,255,255,255)
  7.   end
  8.   def set_text(text, align = 2)
  9.     if text != @text or align != @align
  10.       self.contents.clear
  11.       @showing_time = 100
  12.       @text = text
  13.       @align = align
  14.       @actor = nil
  15.       self.contents_opacity = 255
  16.       x = 4
  17.       y = 0
  18.       self.contents.font.color = Color.new( 0, 0, 0, 192)
  19.       self.contents.draw_text(x+2, y+2, self.width - 40, 32, "-"+text+"-",align=1)     
  20.       self.contents.font.color = Color.new( 64, 64, 64, 192)
  21.       self.contents.draw_text(x-1, y-1, self.width - 40, 32, "-"+text+"-", align=1)     
  22.       self.contents.draw_text(x+1, y-1, self.width - 40, 32, "-"+text+"-", align=1)
  23.       self.contents.draw_text(x-1, y+1, self.width - 40, 32, "-"+text+"-", align=1)
  24.       self.contents.draw_text(x+1, y+1, self.width - 40, 32, "-"+text+"-", align=1)
  25.       self.contents.font.color = @text_color
  26.       self.contents.draw_text(x, y, self.width - 40, 32, "-"+text+"-", align=1)   
  27.     else
  28.       @showing_time -= 1
  29.       if @showing_time < 100
  30.         self.contents_opacity = @showing_time * 100
  31.       elsif @showing_time <= 0
  32.         self.contents.clear
  33.         $图片消失 = true
  34.       end
  35.     end
  36.       self.visible = true
  37.     end
  38.   end
  39. class Scene_Map
  40.   alias xrxs20_main main
  41.   def main
  42.     @map_name_window = Window_Map_Name.new
  43.     @map_name_window.opacity = 0
  44.  
  45.     # 生成地图名背景图
  46.     @map_picture = Sprite.new
  47.     @map_picture.bitmap = Bitmap.new("Graphics/Pictures/Ui/主界面/地图名背景")
  48.     if $图片消失 == true
  49.       @map_picture.opacity = 100
  50.     else
  51.       @map_picture.opacity = 0
  52.     end
  53.     @map_picture.x = 1024/2-180/2
  54.     @map_picture.y = 77
  55.     @map_picture.z = 20
  56.  
  57.     xrxs20_main
  58.     @map_name_window.dispose
  59.  
  60.     # 释放地图名背景图
  61.     @map_picture.dispose
  62.     @map_picture.bitmap.dispose
  63.   end
  64.   alias xrxs20_update update
  65.   def update
  66.     # 更新地图名
  67.     @map_name_window.set_text($game_map.name,1)
  68.     xrxs20_update
  69.   end
  70. end
  71. class Scene_Title
  72.   alias xrxs20_main main
  73.   def main
  74.     $map_infos = load_data("Data/MapInfos.rxdata")
  75.     for key in $map_infos.keys
  76.       $map_infos[key] = $map_infos[key].name
  77.     end
  78.       xrxs20_main
  79.   end
  80. end
  81. class Game_Map
  82.   def name
  83.     $map_infos[@map_id]
  84.   end
  85. end

Lv4.逐梦者

梦石
0
星屑
6306
在线时间
1105 小时
注册时间
2015-8-15
帖子
658
2
发表于 2022-10-29 11:14:16 | 只看该作者
地图上设个执行并处理的事件,事件条件分歧角色在当前地图时候使用脚本class Scene_Map否者事件消失
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
帖子
89
3
发表于 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 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3191
在线时间
1864 小时
注册时间
2010-6-19
帖子
1205
4
 楼主| 发表于 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
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3191
在线时间
1864 小时
注册时间
2010-6-19
帖子
1205
5
 楼主| 发表于 2022-10-29 12:45:06 | 只看该作者
黑米馒头 发表于 2022-10-29 11:55
@showing_time -= 1
      if @showing_time < 100
        self.contents_opacity = @showing_t ...

可以了,感谢
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-3 12:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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