查看: 3464|回复: 2

[RMVA发布] 鼠标系统

[复制链接]
梦石
0
星屑
1902
在线时间
959 小时
注册时间
2012-7-5
回帖
225
发表于 2016-11-2 13:47:57 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
简易的鼠标系统,就写了一会,滋瓷的功能有限,敬请期待更新(


请在Graphics/mouse下放入normal.png 作为光标的图案
  已经滋瓷:
    ·鼠标启动事件
        在允许鼠标启动的事件,事件页第一页,执行方式自动执行,内容
          脚本: $game_map.events[@event_id].mouse_start = true
          独立开关A = on
        第二页开始真正的事件内容
    ·鼠标点击寻路
        可配合我的spfa四方向寻路系统使用,如果没有这个脚本请把
          USE_SPFA_FINDPATH设置为false。寻路系统地址
          https://rpg.blue/forum.php?mod=viewthread&tid=389467
   
  未滋瓷:
    ·选项窗口还不滋瓷鼠标操作
    ·多种光标图案

需要 http://rpg.blue/thread-133018-1-1.html 这个脚本才能正常使用

寻路系统脚本 https://rpg.blue/forum.php?mod=viewthread&tid=389467

事件点击执行栗子:
tiezi1.png tiezi2.png

脚本如下

[pre lang="ruby" file="mouse.rb"]=begin
  鼠标系统V1.0 by 浮云半仙
  
  需要 http://rpg.blue/thread-133018-1-1.html 这个脚本
  
  请在Graphics/mouse下放入normal.png 作为光标的图案

  已经滋瓷:
    ·鼠标启动事件
        在允许鼠标启动的事件,事件页第一页,执行方式自动执行,内容
          脚本: $game_map.events[@event_id].mouse_start = true
          独立开关A = on
        第二页开始真正的事件内容
    ·鼠标点击寻路
        可配合我的spfa四方向寻路系统使用,如果没有这个脚本请把
          USE_SPFA_FINDPATH设置为false。寻路系统地址
          https://rpg.blue/forum.php?mod=viewthread&tid=389467
   
  未滋瓷:
    ·选项窗口还不滋瓷鼠标操作
    ·多种光标图案
   
    敬请期待更新
=end

#命名空间
module FYBX
#

USE_SPFA_FINDPATH = true   #是否使用鼠标自动寻路(配合我的spfa四方向寻路系统)

class Mouse
  attr_accessor :cur_img
  attr_accessor :x, :y
  attr_accessor :map_x, :map_y
  attr_reader :left_lock, :right_lock
  
  GetCursorPos = Win32API.new("user32", "GetCursorPos", "p", "i")
  ScreenToClient = Win32API.new("user32", "ScreenToClient", "lp", "i")
  GetCursor = Win32API.new("user32", "GetCursor", "", "l")
  DestroyCursor = Win32API.new("user32", "DestroyCursor", "l", "i")
  ShowCursor = Win32API.new("user32", "ShowCursor", "i", "i")
  GetKeyState = Win32API.new("user32", "GetKeyState", "i", "i")
  
  HWND = get_hWnd
  BUF = "\0"*8
  PRESS_STATE = [-127, -128]
  def initialize
      ShowCursor.call 0
      @x = @y = @map_x = @map_y = 0
      @left_lock = @right_lock = false
  end
  def update_pos
    GetCursorPos.call BUF
    ScreenToClient.call HWND, BUF
    @x, @y = BUF.unpack("ll")
    @map_x = $game_map.display_x + @x/32
    @map_y = $game_map.display_y + @y/32
  end
  def update_image
    @cur_img.dispose if @cur_img
    @cur_img = Sprite.new
    @cur_img.bitmap = Bitmap.new("Graphics/mouse/normal.png")
    @cur_img.x = @x
    @cur_img.y = @y
    @cur_img.z = 9999
  end
  def update_state
    @left_lock = @right_lock = false
    @left_lock = true if PRESS_STATE.include?(GetKeyState.call 0x01)
    @right_lock = true if PRESS_STATE.include?(GetKeyState.call 0x02)
  end
  def update_events
    if @left_lock
      $game_map.events_xy(@map_x, @map_y).each {|e| e.start if e.mouse_start}
      $game_map.update(true)
    end
  end
  def update_findpath
    if @left_lock
      SceneManager.scene.fybx_force_player_stop_findpath if SceneManager.scene.is_a?(Scene_Map) rescue nil
      FYBX::FindPath.find_path :target_x => @map_x, :target_y => @map_y
    end
  end
  def update
    update_state
    update_pos
    update_image
   
    update_events
    update_findpath if USE_SPFA_FINDPATH
  end
end

#名字空间结束
end
#-----------

class Game_Event
  attr_accessor :mouse_start
end

$mouse = FYBX::Mouse.new
module Graphics
  Graphics.instance_eval do
      alias :old_update :update
  end
  def self.update
    self.old_update
    $mouse.update
  end
end
[/pre]

评分

参与人数 2星屑 +72 收起 理由
zaiy2863 + 42 /w\
唯道集虚 + 30 才发现竟然没人塞糖?!

查看全部评分

tan(pi/2)

漾夕☽星化残月☾

梦石
0
星屑
8604
在线时间
3858 小时
注册时间
2015-5-12
回帖
2021

剧作品鉴家

发表于 2016-11-2 15:54:24 | 显示全部楼层
{:2_249:}半仙还是那么触啊
回复

使用道具 举报

梦石
0
星屑
3105
在线时间
741 小时
注册时间
2015-2-28
回帖
784

开拓者

发表于 2016-11-7 22:24:31 | 显示全部楼层
膜~简短精炼
半仙果然是触呢~
器识为先,文艺其从。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部