赞 | 0 |
VIP | 12 |
好人卡 | 5 |
积分 | 1 |
经验 | 43535 |
最后登录 | 2020-11-2 |
在线时间 | 1050 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 136
- 在线时间
- 1050 小时
- 注册时间
- 2006-5-3
- 帖子
- 774
|
3楼
楼主 |
发表于 2015-2-14 20:34:14
|
只看该作者
喵呜喵5 发表于 2015-2-14 20:32
好歹告诉别人这两个方法是什么类的方法在何时会调用吧…………
完整的是这样的- class Game_Picture
- def name=(str)
- @name = str
- end
- end
- class Sprite_Picture < Sprite
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- alias old_update update
- def update
- old_update
- picture_event_working
- updata_info
- end
- #--------------------------------------------------------------------------
- # ● 显示图片信息(行程安排用)
- #--------------------------------------------------------------------------
- def updata_info#(id="")#, game_time="", save_time=@save_time, chaptter_name="")
- return if (@picture.name[/行程底板/].nil?) or (@updata_info_switch == true)
- self.bitmap.font.name = ["黑体"]
- self.bitmap.font.outline = false
- self.bitmap.font.size = 16
- self.bitmap.font.color.set(129,81,28)
- rect = Rect.new(60, -45, 130, 130)
- self.bitmap.draw_text(rect, get_schedule_info)
- x = @picture.x
- y = @picture.y
- viewport = self.viewport
- @sprite_picture_icon = Sprite_Picture_icon.new(viewport, x, y, get_schedule_info)
- @updata_info_switch = true
- end
- #--------------------------------------------------------------------------
- # ● 获取行程图标信息
- #--------------------------------------------------------------------------
- def get_schedule_info
- num = $schedule.size
- for i in 0..(num-1)
- if self.y == (200+i*40)
- return $schedule[i]
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 判定光标是否在图片内
- #--------------------------------------------------------------------------
- def mouse_in_pic?(sprite)
- return if @name_string_sprite != nil
- lx = self.x - self.ox
- ty = self.y - self.oy
- return if @picture.name == "" or @picture.name[/pe/].nil?
- return unless sprite.bitmap.get_pixel(Mouse.x-lx,Mouse.y-ty).alpha != 0
- return unless (Mouse.x >= sprite.x) and (Mouse.x <= (sprite.x+sprite.width))
- return unless (Mouse.y >= sprite.y) and (Mouse.y <= (sprite.y+sprite.height))
- return true
- end
- #--------------------------------------------------------------------------
- # ● 图片事件开始运作
- #--------------------------------------------------------------------------
- def picture_event_working
- return if @name_string_sprite != nil
- @original_picture_name = @picture.name.clone
- if mouse_in_pic?(self)
- @picture.name = (@original_picture_name + "_2") if @changed_pic != true
- @changed_pic = true
- kick_command_event
- else
- return unless @picture.name.include?('_2')
- @picture.name[-2,2]="" if @changed_pic == true
- @changed_pic = false
- end
- end
- #--------------------------------------------------------------------------
- # ● 点击触发公共事件
- #--------------------------------------------------------------------------
- def kick_command_event
- return if @name_string_sprite != nil
- if Input.trigger?(:C)
- @picture.name.gsub(/^pe(\d{1,3})/i){ $game_temp.reserve_common_event($1.to_i) }
- end
- end
- end
复制代码 |
|