赞 | 0 |
VIP | 13 |
好人卡 | 0 |
积分 | 130 |
经验 | 77844 |
最后登录 | 2024-11-29 |
在线时间 | 1050 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 13011
- 在线时间
- 1050 小时
- 注册时间
- 2007-12-15
- 帖子
- 188
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
如题,就是两种动态选择光标
光标 A
- #==============================================================================
- # □ Sprite_Cursor 选项光标类型 A by 洛克人SZ
- #==============================================================================
- class Sprite_Cursor < Sprite
- def initialize
- super
- self.visible = false
- self.bitmap = RPG::Cache.windowskin("cursor.png")
- self.z = 9999
- @count = 0
- @wait_count = 0
- update
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- #=begin
- def update
- super
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 8
- @count = 1
- end
- if @count == 0
- self.ox += 1
- @wait_count += 1
- elsif @count == 1
- self.ox -= 1
- @wait_count -= 1
- end
- end
- #=end
- #--------------------------------------------------------------------------
- # ● 半透明化
- #--------------------------------------------------------------------------
- def opacitysz(type)
- if type == 0
- self.opacity -= 8 if self.opacity > 180
- else
- self.opacity += 8 if self.opacity < 255
- end
- end
- end
复制代码
效果
光标 B
- #==============================================================================
- # □ Sprite_Cursor 选项光标类型 B by 洛克人SZ
- #==============================================================================
- class Sprite_CursorB < Sprite
- def initialize
- super
- self.visible = false
- @bitmap = RPG::Cache.windowskin("cursora.png")
- self.z = 9999
- @count = @count1 = @wait_count = @wait_count1 = 0
- @tp = false
- @ct = false
- @rect = Array.new(5)
- @rect[0] = Rect.new(0, 0, 12, 12)
- @rect[1] = Rect.new(0, 20, 12, 12)
- @rect[2] = Rect.new(20, 0, 12, 12)
- @rect[3] = Rect.new(20, 20, 12, 12)
- @utype = 0
- self.set(32, 32)
- update
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_type(@utype)
- end
- #--------------------------------------------------------------------------
- # ● 设置尺寸
- #--------------------------------------------------------------------------
- def set(width, height)
- width = 24 if width < 24
- height = 24 if height < 24
- @bitmapa.dispose if @bitmapa != nil
- @bitmapa = self.set_size(@bitmapa, width, height)
- @bitmapb.dispose if @bitmapb != nil
- @bitmapb = self.set_size(@bitmapb, width + 2, height + 2)
- @bitmapc.dispose if @bitmapc != nil
- @bitmapc = self.set_size(@bitmapc, width + 4, height + 4)
- self.bitmap.dispose if self.bitmap != nil
- self.bitmap = @bitmapa
- self.ox, self.oy = self.bitmap.width / 2, self.bitmap.height / 2
- end
- #--------------------------------------------------------------------------
- # ● 半透明化
- #--------------------------------------------------------------------------
- def opacitysz(type)
- if type == 0
- self.opacity -= 8 if self.opacity > 180
- else
- self.opacity += 8 if self.opacity < 255
- end
- end
- def set_size(bitmapcc, width, height)
- bitmapcc = Bitmap.new(width, height)
- bitmapcc.blt(0, 0, @bitmap, @rect[0])
- bitmapcc.blt(0, height - 12, @bitmap, @rect[1])
- bitmapcc.blt(width - 12, 0, @bitmap, @rect[2])
- bitmapcc.blt(width - 12, height - 12, @bitmap, @rect[3])
- @rect[4] = Rect.new(13, 0, 1, height)
- if width > 24
- for i in 1..width - 24
- bitmapcc.blt(width - 12 - i, 0, @bitmap, @rect[4])
- end
- end
- return bitmapcc
- end
- def set_update_type(type)
- @utype = type
- @ct = true
- end
- def update_type(type)
- case type
- when 0
- self.opacity = 255 if self.opacity < 255 and @ct
- self.bitmap = @bitmapa if @ct
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2 if @ct
- @count = @count1 = @wait_count = @wait_count1 = 0 if @ct
- @tp = false if @ct
- @ct = false if @ct
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 15
- @count = 1
- end
- if @count == 0
- self.opacity -= 8
- @wait_count += 1
- elsif @count == 1
- self.opacity += 8
- @wait_count -= 1
- end
- when 1
- self.opacity = 255 if self.opacity < 255 and @ct
- @count = @count1 = @wait_count = @wait_count1 = 0 if @ct
- @tp = false if @ct
- @ct = false if @ct
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 4
- @count = 1
- elsif @wait_count == 8
- @count = 2
- end
- if @count == 0
- self.bitmap = @bitmapa
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2
- @wait_count += 1
- @tp = false if @tp
- elsif @count == 1
- self.bitmap = @bitmapb
- self.ox, self.oy = self.bitmap.width / 2 - 1, self.bitmap.height / 2 - 1
- @wait_count += 1 if !@tp
- @wait_count -= 1 if @tp
- elsif @count == 2
- self.bitmap = @bitmapc
- self.ox, self.oy = self.bitmap.width / 2, self.bitmap.height / 2
- @wait_count -= 1
- @tp = true if !@tp
- end
- when 2
- self.opacity = 255 if self.opacity < 255 and @ct
- self.bitmap = @bitmapa if @ct
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2 if @ct
- @count = @count1 = @wait_count = @wait_count1 = 0 if @ct
- @tp = false if @ct
- @ct = false if @ct
- if @wait_count == 0
- @count = 0
- elsif @wait_count == 4
- @count = 1
- elsif @wait_count == 8
- @count = 2
- end
- if @wait_count1 == 0
- @count1 = 0
- elsif @wait_count1 == 15
- @count1 = 1
- end
- if @count == 0
- self.bitmap = @bitmapa
- self.ox, self.oy = self.bitmap.width / 2 - 2, self.bitmap.height / 2 - 2
- @wait_count += 1
- @tp = false if @tp
- elsif @count == 1
- self.bitmap = @bitmapb
- self.ox, self.oy = self.bitmap.width / 2 - 1, self.bitmap.height / 2 - 1
- @wait_count += 1 if !@tp
- @wait_count -= 1 if @tp
- elsif @count == 2
- self.bitmap = @bitmapc
- self.ox, self.oy = self.bitmap.width / 2, self.bitmap.height / 2
- @wait_count -= 1
- @tp = true if !@tp
- end
- if @count1 == 0
- self.opacity -= 8
- @wait_count1 += 1
- elsif @count1 == 1
- self.opacity += 8
- @wait_count1 -= 1
- end
- end
- end
- end
复制代码
效果
使用方法:http://rpg.blue/viewthread.php?t ... 1%2D19+10%3A51%3A48
实际效果见范例:http://rpg.blue/UP_PIC/200801/ProjectSZ001.rar
就这样了………… |
|