Project1

标题: 真实按钮v1.2 [打印本页]

作者: 304475881    时间: 2008-7-28 23:06
标题: 真实按钮v1.2
所谓的[真实按钮]就是鼠标移动上图片后图片变化出现声音,鼠标左键按下的时候
图片变化出现声音,鼠标左键松了的时候图片变化出现声音。
下载dll的地址:
ftp://[email protected]/game/304475881_Dsbl.rar
([cursor]存在Icons)
([开始游戏]存在Pictures)
图片的地址:
ftp://[email protected]/resource/304475881_图片资料.zip
图片选择脚本:
class Game_Picture
  def name=(str)
    @name = str
  end
end
class Sprite_Picture
  alias update_old update
  def update
    update_old
    return if @picture_name == "" or @picture_name[/xz/].nil?
    mx,my = Mouse.pos
    lx = self.x - self.ox
    rx = lx + self.bitmap.width
    ty = self.y - self.oy
    by = ty + self.bitmap.height
    if mx < lx or mx > rx or my < ty or my > by or
      self.bitmap.get_pixel(mx-lx,my-ty).alpha == 0
      @picture.name = @picture.name.split(/_/)[0]+"_"[email protected](/_/)[1]
      return
    end
    if @picture.name.split(/_/)[2].nil?
      @picture.name = @picture.name + "_02"
      Audio.se_play("Audio/SE/选中")
    end
    if Mouse.key_down(1)
      Audio.se_play("Audio/SE/按下")
      @picture.name = @picture.name.split(/_/)[0]+"_"[email protected](/_/)[1]
      @picture.name = @picture.name + "_03"
      $sdfjlkas = 1
    elsif $sdfjlkas = 1 and Mouse.key_up(1)
      Audio.se_play("Audio/SE/弹上")
      @picture.name = @picture.name.split(/_/)[0]+"_"[email protected](/_/)[1]
      @picture.name.split(/_/)[0].sub(/xz([0-9]+)/,"")
      $game_temp.common_event_id = $1.to_i
      $sdfjlkas = 0
    end
  end
end
鼠标脚本:
unless defined? Mouse

#==============================================================================
# ■ Mouse
#------------------------------------------------------------------------------
#  鼠标核心模块。 v1.0  by 灼眼的夏娜
#==============================================================================

module Mouse
  
  #--------------------------------------------------------------------------
  # ● DLL名
  #--------------------------------------------------------------------------
  DLL             = "Dsbl/mouse"
  
  #--------------------------------------------------------------------------
  # ● 按键常量
  #--------------------------------------------------------------------------
  LBUTTON                = 0x01
  RBUTTON                = 0x02
  MBUTTON                = 0x04
  
  #--------------------------------------------------------------------------
  # ● API函数声明
  #--------------------------------------------------------------------------
  MOUSE_INIT      = Win32API.new(DLL,"_mouse_init","v","i")
  MOUSE_EXIT      = Win32API.new(DLL,"_mouse_exit","v","v")
  
  MOUES_GET_POS   = Win32API.new(DLL,"_mouse_get_pos","p","v")
  MOUSE_SET_POS   = Win32API.new(DLL,"_mouse_set_pos","ll","v")
  
  MOUSE_GET_WHEEL = Win32API.new(DLL,"_mouse_get_wheel","v","i")
  MOUSE_IS_OVER   = Win32API.new(DLL,"_mouse_is_over","v","i")
  GET_KEY_STATE   = Win32API.new(DLL,"_get_key_state","i","i")
  KEY_DOWN        = Win32API.new(DLL,"_key_down","i","i")
  KEY_UP          = Win32API.new(DLL,"_key_up","i","i")
  MOUSE_UPDATE    = Win32API.new(DLL,"_mouse_update","v","v")
  CLEAR_QUEUE     = Win32API.new(DLL,"_clear_queue","v","v")
  
  #--------------------------------------------------------------------------
  # ● 鼠标系统启动
  #--------------------------------------------------------------------------
  def self.start
    finish
   
    @spr_cursor = Sprite.new
    @spr_cursor.visible = false
    @spr_cursor.bitmap = RPG::Cache.icon("cursor")
    @spr_cursor.z = 99999
   
    @mx = 0
    @my = 0
   
    @l_last_pressed = @l_pressed = false
    @r_last_pressed = @r_pressed = false
   
    @wheel = 0
   
    raise "Init Mouse System Error..." if MOUSE_INIT.call != 0
  end
  
  #--------------------------------------------------------------------------
  # ● 返回鼠标位置
  #--------------------------------------------------------------------------
  def self.pos
    return @mx,@my
  end
  
  #--------------------------------------------------------------------------
  # ● 鼠标系统结束
  #--------------------------------------------------------------------------
  def self.finish
    if @spr_cursor != nil
      @spr_cursor.bitmap.dispose
      @spr_cursor.dispose
      @spr_cursor = nil
      
      @mx = 0
      @my = 0
      
      @l_last_pressed = @l_pressed = false
      @r_last_pressed = @r_pressed = false
      
      @wheel = 0
      
      MOUSE_EXIT.call
    end
  end
  
  #--------------------------------------------------------------------------
  # ● 键按下?
  #--------------------------------------------------------------------------
  def self.key_down(key)
    return KEY_DOWN.call(key) != 0
  end
  
  #--------------------------------------------------------------------------
  # ● 键弹起?
  #--------------------------------------------------------------------------
  def self.key_up(key)
    return KEY_UP.call(key) != 0
  end
  
  #--------------------------------------------------------------------------
  # ● 连续按键?
  #--------------------------------------------------------------------------
  def self.press?(key)
    case key
    when LBUTTON
      return @l_pressed
    when RBUTTON
      return @r_pressed
    else
      return false
    end
  end
  
  #--------------------------------------------------------------------------
  # ● 等同于:key_down
  #--------------------------------------------------------------------------
  def self.trigger?(key)
    return key_down(key)
  end
  
  #--------------------------------------------------------------------------
  # ● 滚动中?
  #--------------------------------------------------------------------------
  def self.scroll?
    return @wheel != 0
  end
  
  #--------------------------------------------------------------------------
  # ● 向上滚动?
  #--------------------------------------------------------------------------
  def self.scroll_up?
    return @wheel > 0
  end
  
  #--------------------------------------------------------------------------
  # ● 向下滚动?
  #--------------------------------------------------------------------------
  def self.scroll_down?
    return @wheel < 0
  end
  
  #--------------------------------------------------------------------------
  # ● 滚轮计数
  #--------------------------------------------------------------------------
  def self.scroll
    return @wheel
  end
  
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def self.update
    MOUSE_UPDATE.call

    pt = [0,0].pack("ll")
    MOUES_GET_POS.call(pt)
    @mx,@my = pt.unpack("ll")

    @l_last_pressed = @l_pressed
    @l_pressed = GET_KEY_STATE.call(LBUTTON) != 0
    @r_last_pressed = @r_pressed
    @r_pressed = GET_KEY_STATE.call(RBUTTON) != 0

    @wheel = MOUSE_GET_WHEEL.call

    @spr_cursor.x = @mx
    @spr_cursor.y = @my
    @spr_cursor.visible = MOUSE_IS_OVER.call != 0
  end
  
  #--------------------------------------------------------------------------
  # ● 清空队列
  #--------------------------------------------------------------------------
  def self.clear_queue
    CLEAR_QUEUE.call
  end
  
end

#==============================================================================
# ■ Graphics
#------------------------------------------------------------------------------
#  图象模块,添加鼠标支持。
#==============================================================================

class << Graphics
  
  alias origin_update update
  
  def update
    Mouse.clear_queue
    origin_update
    Mouse.update
  end
  
end

#==============================================================================
# ■ Input
#------------------------------------------------------------------------------
#  按键输入模块,添加鼠标支持。
#==============================================================================

class << Input
  
  alias origin_trigger? trigger?
  
  def trigger?(key)
    if origin_trigger?(key)
      return true
    end
    case key
    when Input::C
      return Mouse.key_down(Mouse::LBUTTON)
    when Input::B
      return Mouse.key_down(Mouse::RBUTTON)
    else
      return false
    end
  end
  
end

end

Mouse.start


class Window_Selectable
  if @self_alias == nil
    alias self_update update
    @self_alias = true
  end
  def update
    #self.cursor_rect.empty
    self_update
    if self.active and @item_max > 0
      index_var = @index
      tp_index = @index
      mouse_x, mouse_y = Mouse.pos
      mouse_not_in_rect = true
      for i in 0...@item_max
        @index = i
        update_cursor_rect
        top_x = self.cursor_rect.x + self.x + 16
        top_y = self.cursor_rect.y + self.y + 16
        bottom_x = top_x + self.cursor_rect.width
        bottom_y = top_y + self.cursor_rect.height
        if (mouse_x > top_x) and (mouse_y > top_y) and
           (mouse_x < bottom_x) and (mouse_y < bottom_y)
          mouse_not_in_rect = false
          if tp_index != @index
            tp_index = @index
            $game_system.se_play($data_system.cursor_se)
          end
          break
        end
      end
      if mouse_not_in_rect
        @index = index_var
        if Mouse.scroll_up?
          # 光标向上移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
        if Mouse.scroll_down?
          # 光标向上移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
        update_cursor_rect
       #Mouse.click_lock
      else
       #Mouse.click_unlock               
      end
    end
  end
end

作者: 304475881    时间: 2008-7-28 23:18
啊!怎么没人顶啊!{/dk}{/dk}{/dk}
作者: 做游戏的新手    时间: 2008-7-29 00:15
支持下
作者: yangff    时间: 2008-7-29 00:32
杀啊!打击盗版,还我中国,还我主权
http://rpg.blue/viewthread.php?tid=88346
作者: 虚幻死神    时间: 2008-7-29 02:38
無語.......可能是類同吧~~LS不要那么激動~~~~兩人交流一下嘛~~
作者: 灯笼菜刀王    时间: 2008-7-29 02:52
以下引用yangff于2008-7-28 16:32:44的发言:

杀啊!打击盗版,还我中国,还我主权
http://rpg.blue/viewthread.php?tid=88346


笑死我了.......

好象只是撞车而已吧。没那么严重- -
作者: 莉可    时间: 2008-8-5 22:54
提示: 作者被禁止或删除 内容自动屏蔽
作者: 踏水无痕    时间: 2008-8-8 03:11
不是很实用,也许是我没看明白,真的:我一句都没看懂
作者: suicaoya123    时间: 2008-8-27 01:58
等鼠标系统完善时候在来找·······不过最好不要“考参”别人的脚本{/gg}




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1