赞 | 1 |
VIP | 127 |
好人卡 | 25 |
积分 | 5 |
经验 | 59654 |
最后登录 | 2020-12-3 |
在线时间 | 820 小时 |
Lv2.观梦者 (暗夜天使) 卑微的梦
- 梦石
- 0
- 星屑
- 523
- 在线时间
- 820 小时
- 注册时间
- 2013-2-23
- 帖子
- 1185
|
- #面向注释有“<ShowText:XXX>”的事件时,画面右下角显示“XXX”
- class Sprite_Cue < Sprite
- Padding = 2 # 设置距离屏幕边距
- OnEvent = true
- def setup_bitmap(text = " ")
- return if @text == text
- @text = text
- btmp = Bitmap.new(1, 1)
- rect = btmp.text_size(text)
- btmp.dispose#
- rect.width += 2
- rect.height += 2
- bitmap.dispose if bitmap
- self.bitmap = Bitmap.new(rect.width, rect.height)
- bitmap.draw_text(rect, text)
- self.x = Graphics.width - width / 2 - Padding
- self.y = Graphics.height - Padding
- self.ox = width / 2
- self.oy = OnEvent ? height + 32 : height
- end
- #
- def update
- event = face_event
- if event && text = cue_text(event.list)
- self.visible = true
- setup_bitmap(text)
- pos_to(event.screen_x, event.screen_y) if OnEvent
- else
- self.visible = false
- end
- end
- def pos_to(x, y)
- self.x = x
- self.y = y
- end
- def face_event
- fx = $game_map.round_x_with_direction(player.x, player.direction)
- fy = $game_map.round_y_with_direction(player.y, player.direction)
- return $game_map.events_xy(fx, fy)[0]
- end
- def cue_text(list)
- list.each {|cmd|
- next unless cmd.code == 108 || cmd.code == 408
- return $1 if cmd.parameters[0] =~ /<ShowText.(.+)>/
- };return nil
- end
- #
- def dispose
- bitmap.dispose if bitmap
- super
- end
- #
- def player
- $game_player
- end
- end
-
- class Spriteset_Map
- alias_method :create_characters_20130820, :create_characters
- alias_method :update_20130820, :update
- alias_method :dispose_20130820, :dispose
- def create_characters
- create_characters_20130820
- @cue_sprite = Sprite_Cue.new(@viewport2)
- end
- def update
- update_20130820
- @cue_sprite.update
- end
- def dispose
- dispose_20130820
- @cue_sprite.dispose
- end
- end
复制代码 |
评分
-
查看全部评分
|