设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2633|回复: 2
打印 上一主题 下一主题

[RMVA发布] 鼠标系统

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1774
在线时间
950 小时
注册时间
2012-7-5
帖子
245
跳转到指定楼层
1
发表于 2016-11-2 13:47:57 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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


请在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

事件点击执行栗子:


脚本如下

RUBY 代码复制下载
  1. =begin
  2.   鼠标系统V1.0 by 浮云半仙
  3.  
  4.   需要 [url]http://rpg.blue/thread-133018-1-1.html[/url] 这个脚本
  5.  
  6.   请在Graphics/mouse下放入normal.png 作为光标的图案
  7.  
  8.   已经滋瓷:
  9.     ·鼠标启动事件
  10.         在允许鼠标启动的事件,事件页第一页,执行方式自动执行,内容
  11.           脚本: $game_map.events[@event_id].mouse_start = true
  12.           独立开关A = on
  13.         第二页开始真正的事件内容
  14.     ·鼠标点击寻路
  15.         可配合我的spfa四方向寻路系统使用,如果没有这个脚本请把
  16.           USE_SPFA_FINDPATH设置为false。寻路系统地址
  17.           [url]https://rpg.blue/forum.php?mod=viewthread&tid=389467[/url]
  18.     
  19.   未滋瓷:
  20.     ·选项窗口还不滋瓷鼠标操作
  21.     ·多种光标图案
  22.     
  23.     敬请期待更新
  24. =end
  25.  
  26. #命名空间
  27. module FYBX
  28. #
  29.  
  30. USE_SPFA_FINDPATH = true   #是否使用鼠标自动寻路(配合我的spfa四方向寻路系统)
  31.  
  32. class Mouse
  33.   attr_accessor :cur_img
  34.   attr_accessor :x, :y
  35.   attr_accessor :map_x, :map_y
  36.   attr_reader :left_lock, :right_lock
  37.  
  38.   GetCursorPos = Win32API.new("user32", "GetCursorPos", "p", "i")
  39.   ScreenToClient = Win32API.new("user32", "ScreenToClient", "lp", "i")
  40.   GetCursor = Win32API.new("user32", "GetCursor", "", "l")
  41.   DestroyCursor = Win32API.new("user32", "DestroyCursor", "l", "i")
  42.   ShowCursor = Win32API.new("user32", "ShowCursor", "i", "i")
  43.   GetKeyState = Win32API.new("user32", "GetKeyState", "i", "i")
  44.  
  45.   HWND = get_hWnd
  46.   BUF = "\0"*8
  47.   PRESS_STATE = [-127, -128]
  48.   def initialize
  49.       ShowCursor.call 0
  50.       @x = @y = @map_x = @map_y = 0
  51.       @left_lock = @right_lock = false
  52.   end
  53.   def update_pos
  54.     GetCursorPos.call BUF
  55.     ScreenToClient.call HWND, BUF
  56.     @x, @y = BUF.unpack("ll")
  57.     @map_x = $game_map.display_x + @x/32
  58.     @map_y = $game_map.display_y + @y/32
  59.   end
  60.   def update_image
  61.     @cur_img.dispose if @cur_img
  62.     @cur_img = Sprite.new
  63.     @cur_img.bitmap = Bitmap.new("Graphics/mouse/normal.png")
  64.     @cur_img.x = @x
  65.     @cur_img.y = @y
  66.     @cur_img.z = 9999
  67.   end
  68.   def update_state
  69.     @left_lock = @right_lock = false
  70.     @left_lock = true if PRESS_STATE.include?(GetKeyState.call 0x01)
  71.     @right_lock = true if PRESS_STATE.include?(GetKeyState.call 0x02)
  72.   end
  73.   def update_events
  74.     if @left_lock
  75.       $game_map.events_xy(@map_x, @map_y).each {|e| e.start if e.mouse_start}
  76.       $game_map.update(true)
  77.     end
  78.   end
  79.   def update_findpath
  80.     if @left_lock
  81.       SceneManager.scene.fybx_force_player_stop_findpath if SceneManager.scene.is_a?(Scene_Map) rescue nil
  82.       FYBX::FindPath.find_path :target_x => @map_x, :target_y => @map_y
  83.     end
  84.   end
  85.   def update
  86.     update_state
  87.     update_pos
  88.     update_image
  89.  
  90.     update_events
  91.     update_findpath if USE_SPFA_FINDPATH
  92.   end
  93. end
  94.  
  95. #名字空间结束
  96. end
  97. #-----------
  98.  
  99. class Game_Event
  100.   attr_accessor :mouse_start
  101. end
  102.  
  103. $mouse = FYBX::Mouse.new
  104. module Graphics
  105.   Graphics.instance_eval do
  106.       alias :old_update :update
  107.   end
  108.   def self.update
  109.     self.old_update
  110.     $mouse.update
  111.   end
  112. end

评分

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

查看全部评分

tan(pi/2)

Lv4.逐梦者 (版主)

漾夕☽星化残月☾

梦石
0
星屑
8487
在线时间
3848 小时
注册时间
2015-5-12
帖子
2076

剧作品鉴家

2
发表于 2016-11-2 15:54:24 | 只看该作者
{:2_249:}半仙还是那么触啊
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (版主)

梦石
0
星屑
3085
在线时间
740 小时
注册时间
2015-2-28
帖子
816

开拓者

3
发表于 2016-11-7 22:24:31 | 只看该作者
膜~简短精炼
半仙果然是触呢~
器识为先,文艺其从。
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-6 21:05

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表