liqunsz 发表于 2010-6-12 20:10:08

关于【鼠标响应图片】的使用问题~

脚本方面傻了吧唧的问题已经解决,现在是事件的问题……







使用了【鼠标响应图片】这个脚本制作游戏(当然基础的鼠标脚本已经加了PIA~废话)
我用它来制作标题,鼠标移上去,会有鼠标经过的图片的变化,而且已经把图片按照格式写好了
原图:cmd公共事件编号_名字
鼠标经过:cmd公共事件编号_名字_02
既然鼠标经过会有反应,那么为什么公共事件设好了却没有反应呢?即使我把公共事件内的事件只设置了一个打开开关的操作也没有用……
望高人解答!
附我使用的脚本(从AVG精装版1.05中提取的,小白啊……因为也是要做AVG类的,所以原封不动的拷了过来,但是在那里面的范例中是管用的,我也全部按照范例的格式做的):
发现用鼠标做游戏很好用额……PS:我用的这个鼠标脚本好像没有调用DLL


●鼠标响应图片
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#格式:显示的cmd图片的命名格式为:
#    cmd调用公共事件编号_名字
#    cmd调用公共事件编号_名字_02 # 此为鼠标经过的图片
#
#即,带有cmd的为可以点击的图片,点击后执行相应的公共事件.....
#不带cmd的图片没任何影响。。。
#==============================================================================
class Game_Picture
def name=(str)
   @name = str
end
end

class Sprite_Picture
alias update_old update
def update
   update_old
   begin
   return if@picture_name.nil? or @picture_name == ""
rescue
   return
   end
   mx,my = Mouse.get_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(/_/)+"_"+@picture.name.split(/_/)
   return
   end
   if @picture.name.split(/_/).nil?
   picname = @picture.name + "_02"
   #第2张图片不存在的时候不显示
   if FileTest.exist?("Graphics/Pictures/#{picname}.png")
       @picture.name = picname
       picname2 = @picture.name.split(/_/) + "map"
       if FileTest.exist?("Graphics/Pictures/#{picname2}.png")
         $mapname = picname2
       end
   end
   end
   #对话框存在的时候不启动事件
   if Mouse.trigger?(Mouse::LEFT) and !$game_system.map_interpreter.running?
       @picture.name.split(/_/).sub(/cmd(+)/,"")
         $game_temp.common_event_id = $1.to_i
   end
end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

liqunsz 发表于 2010-6-12 20:11:34

鼠标脚本是这个:(所调用的图片素材一应俱全啊!)
不知道跟被#掉的脚本有无关系?


#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

#=================以下两个用来调整战斗时的手感问题,可以自己试试。
$敌人选框扩大 = 20
$角色选框扩大 = 30


#==============================================================================
# API调用
#==============================================================================
$ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
$GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
$ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
$GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
$Window_HWND = $GetActiveWindow.call
$GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
#$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
#$HookStart= Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
#$HookEnd= Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
#$GetMouseStatus= Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
#$Window_HWND = $FindWindow.call(nil, 'mousetry')

module Mouse
LEFT = 0x01
RIGHT = 0x02

def self.init(sprite = nil)
#   $HookStart.call($Window_HWND)
    $ShowCursor.call(0)
   
    @show_cursor = false
   
    @mouse_sprite = Sprite.new
    @mouse_sprite.z = 99999
    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标.png')
    #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))

    @left_press = false
    @right_press = false
    @left_trigger = false
    @right_trigger = false
    @left_repeat = false
    @right_repeat = false
    @click_lock = false
   
    update
end
def self.exit
    @mouse_sprite.bitmap.dispose
    @mouse_sprite.dispose
    @show_cursor = true
#    $HookEnd.call
    $ShowCursor.call(1)
end
def self.mouse_debug
    return @mouse_debug.bitmap
end
def self.update
    left_down = $GetKeyState.call(0x01)
    right_down = $GetKeyState.call(0x02)
   
    @click_lock = false
    mouse_x, mouse_y = self.get_mouse_pos
    if @mouse_sprite != nil
      @mouse_sprite.x = mouse_x
      @mouse_sprite.y = mouse_y
    end
    if left_down == 1
      @left_repeat = (not @left_repeat)
      @left_trigger = (not @left_press)
      @left_press = true
    else
      @left_press = false
      @left_trigger = false
      @left_repeat = false
    end
    if right_down == 1
      @right_repeat = (not @right_repeat)
      @right_trigger = (not @right_press)
      @right_press = true
    else
      @right_press = false
      @right_trigger = false
      @right_repeat = false
    end
end
def self.get_mouse_pos
    point_var = .pack('ll')
    if $GetCursorPos.call(point_var) != 0
      if $ScreenToClient.call($Window_HWND, point_var) != 0
      x, y = point_var.unpack('ll')
      if (x < 0) or (x > 10000) then x = 0 end
      if (y < 0) or (y > 10000) then y = 0 end
      if x > 640 then x = 640 end
      if y > 480 then y = 480 end
      return x, y
      else
      return 0, 0
      end
    else
      return 0, 0
    end
end
def self.press?(mouse_code)
    if mouse_code == LEFT
      if @click_lock
      return false
      else
      return @left_press
      end
    elsif mouse_code == RIGHT
      return @right_press
    else
      return false
    end
end
def self.trigger?(mouse_code)
    if mouse_code == LEFT
      if @click_lock
      return false
      else
      return @left_trigger
      end
    elsif mouse_code == RIGHT
      return @right_trigger
    else
      return false
    end
end
def self.repeat?(mouse_code)
    if mouse_code == LEFT
      if @click_lock
      return false
      else
      return @left_repeat
      end
    elsif mouse_code == RIGHT
      return @right_repeat
    else
      return false
    end
end
def self.click_lock?
    return @click_lock
end
def self.click_lock
    @click_lock = true
end
def self.click_unlock
    @click_lock = false
end
end
module Input
if @self_update == nil
    @self_update = method('update')
    @self_press = method('press?')
    @self_trigger = method('trigger?')
    @self_repeat = method('repeat?')
end
def self.update
    @self_update.call
    Mouse.update
end
def self.press?(key_code)
    if @self_press.call(key_code)
      return true
    end
    if key_code == C
      return Mouse.press?(Mouse::LEFT)
    elsif key_code == B
      return Mouse.press?(Mouse::RIGHT)
    else
      return @self_press.call(key_code)
    end
end
def self.trigger?(key_code)
    if @self_trigger.call(key_code)
      return true
    end
    if key_code == C
      return Mouse.trigger?(Mouse::LEFT)
    elsif key_code == B
      return Mouse.trigger?(Mouse::RIGHT)
    else
      return @self_trigger.call(key_code)
    end
end
def self.repeat?(key_code)
    if @self_repeat.call(key_code)
      return true
    end
    if key_code == C
      return Mouse.repeat?(Mouse::LEFT)
    elsif key_code == B
      return Mouse.repeat?(Mouse::RIGHT)
    else
      return @self_repeat.call(key_code)
    end
end
end
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.get_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
      update_cursor_rect
      Mouse.click_lock
      else
      Mouse.click_unlock               
      end
    end
end
end
class Window_NameInput
if @self_alias == nil
    alias self_update update
    @self_alias = true
end
def update
    #self.cursor_rect.empty
    self_update
    if self.active
      index_var = @index
      mouse_x, mouse_y = Mouse.get_mouse_pos
      mouse_not_in_rect = true
      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
      @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
          break
      end
      end
      if mouse_not_in_rect
      @index = index_var
      update_cursor_rect
      Mouse.click_lock
      else
      Mouse.click_unlock
      end
    end
end
end
class Window_InputNumber
if @self_alias == nil
    alias self_update update
    @self_alias = true
end
def update
    #self.cursor_rect.empty
    self_update
    mouse_x, mouse_y = Mouse.get_mouse_pos
    if self.active and @digits_max > 0
      index_var = @index
      mouse_not_in_rect = true
      for i in 0...@digits_max
      @index = i
      update_cursor_rect
      top_x = self.cursor_rect.x + self.x + 16
      bottom_x = top_x + self.cursor_rect.width
      #
      if (mouse_x > top_x) and (mouse_x < bottom_x)
          mouse_not_in_rect = false
          break
      end
      end
      if mouse_not_in_rect
      @index = index_var
      update_cursor_rect
      Mouse.click_lock
      else
      Mouse.click_unlock
      end
    end
    if @last_mouse_y == nil
      @last_mouse_y = mouse_y
    end
    check_pos = (@last_mouse_y - mouse_y).abs
    if check_pos > 10
      $game_system.se_play($data_system.cursor_se)
      place = 10 ** (@digits_max - 1 - @index)
      n = @number / place % 10
      @number -= n * place
      n = (n + 1) % 10 if mouse_y < @last_mouse_y
      n = (n + 9) % 10 if mouse_y > @last_mouse_y
      @number += n * place
      refresh
      @last_mouse_y = mouse_y
    end
end
end
class Scene_File
if @self_alias == nil
    alias self_update update
    @self_alias = true
end
def update
    mouse_x, mouse_y = Mouse.get_mouse_pos
    Mouse.click_lock
    idx = 0
    for i in @savefile_windows
      top_x = i.x + 16
      top_y = i.y + 16
      bottom_x = top_x + i.width
      bottom_y = top_y + i.height
      if (mouse_x > top_x) and (mouse_y > top_y) and
         (mouse_x < bottom_x) and (mouse_y < bottom_y)
      i.selected = true
      if @file_index != idx
          @file_index = idx
          $game_system.se_play($data_system.cursor_se)
      end            
      Mouse.click_unlock
      else
      i.selected = false
      end
      idx += 1
    end
    self_update
end
end
class Arrow_Enemy
if @self_alias == nil
    alias self_update update
    @self_alias = true
end
def update
    mouse_x, mouse_y = Mouse.get_mouse_pos
    idx = 0
    for i in $game_troop.enemies do
      if i.exist?
      top_x = i.screen_x - self.ox
      top_y = i.screen_y - self.oy
      bottom_x = top_x + self.src_rect.width
      bottom_y = top_y + self.src_rect.height
      if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
         (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
          if @index != idx
            $game_system.se_play($data_system.cursor_se)
            @index = idx
          end
      end
      end
      idx += 1
    end
    self_update
end
end
class Arrow_Actor
if @self_alias == nil
    alias self_update update
    @self_alias = true
end
def update
    mouse_x, mouse_y = Mouse.get_mouse_pos
    idx = 0
    for i in $game_party.actors do
      if i.exist?
      top_x = i.screen_x - self.ox
      top_y = i.screen_y - self.oy
      bottom_x = top_x + self.src_rect.width
      bottom_y = top_y + self.src_rect.height
      if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
         (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
          if @index != idx
            $game_system.se_play($data_system.cursor_se)
            @index = idx
          end
      end
      end
      idx += 1
    end
    self_update
end
end
class Game_Player
if @self_alias == nil
    alias self_update update
    @self_alias = true
end
def update
    mouse_x, mouse_y = Mouse.get_mouse_pos

    if @last_move_x == nil
      @last_move_x = false
    end
    if Mouse.press?(Mouse::LEFT)
      last_moving = moving?
      last_direction = @direction
      unless moving? or $game_system.map_interpreter.running? or
             @move_route_forcing or $game_temp.message_window_showing
      last_x = @x
      if @last_move_x
          @last_move_x = false
      elsif mouse_x > screen_x + 16
          move_right
      elsif mouse_x < screen_x - 16
          move_left
      end
      last_y = @y
      if last_x != @x
          @last_move_x = true
      elsif mouse_y > screen_y
          move_down
      elsif mouse_y < screen_y - 32
          move_up
      end
      if last_y != @y
          @last_move_x = false
      elsif not @last_move_x
          case last_direction
          when 2
            turn_down
          when 4
            turn_left
          when 6
            turn_right
          when 8
            turn_up
          end
      end
      end
    end
    self_update
end
end
Mouse.init
END { Mouse.exit }




#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

secondsen 发表于 2010-6-12 21:28:18

建议直接找作者

liqunsz 发表于 2010-6-12 21:41:24

………………6R关了很久了,现在依然是华丽丽的……
啊咧……换了!!字终于换了!!
有关一些最近朋友们的疑问在这里一并解答一下吧:

1、为什么关闭?——原因是多方面的,最主要的原因是2D RPG这种制作方法已经落伍得比较厉害,耗时耗力效果又难以提升,让人心灰意冷。另一个原因是和我国法规中有关网络审核与论坛24小时值守的要求有关。

2、资料怎么办?——首先感谢zh99998君保留的全部论坛文字资料,在这里:http://zh99998.vicp.net:66/index.php,可以用来查看以前的大部分论坛内容。有关以前主站的核心资料,这部分我本来打算整理,但一来我本人现在不在国内拿不到数据,二来就算整理好也没有合适渠道发布,所以大家不用太期待。

3、什么情况下会重开?——我想满足以下几个情况时,有可能会重开(或者说不一定是重开,新做一个也有可能,只是可能):
1、便捷的掌机开发模式(包括PSP、DS、Ipod系)。
2、便捷而价格适宜的好用3D单机引擎(授权价在几万RMB以内,不能更贵了)。
3、可靠的盈利模式能达到自我平衡并能召集支付工资的临时工,主要管理人员有固定的每周闲暇时间。
4、完整可行的资源储存方式,以前的FTP方式不是不行,但是彼端比较多。
5、能够保证安全,又便于使用的站点整体代码(以前6R最后时候安全问题补来补去,也是让人无奈的一个原因)。



里·66RPG人又比较少,基本没什么办法

游戏制作先行者也关闭了,现在只能来幻森了……极品官窑青花杯具ING

secondsen 发表于 2010-6-13 00:13:52

游戏制作先行者也关闭了????这是咋回事。。。我很久没去那边做客了。。。新闻OR旧事?

这个脚本是干嘛用的啊。。。

liqunsz 发表于 2010-6-13 08:44:31

版大好厉害啊,大白天也在线……
先行者论坛不是diyrpg.net 吗?不知道是不是网络原因,最近都打不开了
我记得这个脚本好像是【灼眼的夏娜】发的,作用就是当鼠标移动到某张图片时会自动更换为另一张图片
就相当于有个按钮覆盖在上面,会有鼠标经过的变化,点击了以后会执行相应的公共事件
我看AVG精装版里面是有个小人躲在树丛里,鼠标移上去会翘起来一点,点击了以后就出来了
但是我无论怎么做都没有这种效果啊………………
求助!!

secondsen 发表于 2010-6-13 08:55:32

我刚考完研。。。天天等着录取通知书呢

secondsen 发表于 2010-6-13 08:58:13

$ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
$GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
$ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
$GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
$Window_HWND = $GetActiveWindow.call
$GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
#$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
#$HookStart= Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
#$HookEnd= Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
#$GetMouseStatus= Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
#$Window_HWND = $FindWindow.call(nil, 'mousetry')

调用API 还要用DLL干什么。。。

secondsen 发表于 2010-6-13 09:07:11

我在胡言乱语

liqunsz 发表于 2010-6-13 09:24:51

引用第7楼secondsen于2010-06-13 08:58发表的:
$ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
$GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
$ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
$GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
$Window_HWND = $GetActiveWindow.call
....... images/back.gif


哦~受益匪浅!

引用第8楼secondsen于2010-06-13 08:58发表的:
要睡着的时候想起来了这个。。绝对是失误。。我要抹杀证据

不管用……不知是不是改错了,请说详细一点?
页: [1] 2 3 4
查看完整版本: 关于【鼠标响应图片】的使用问题~