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

Project1

 找回密码
 注册会员
搜索
123
返回列表 发新帖
楼主: aq5888123
打印 上一主题 下一主题

[已经解决] 如何确定移动图片的X,Y坐标啊?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
65
在线时间
385 小时
注册时间
2007-7-27
帖子
4106

开拓者

21
发表于 2010-6-30 21:15:21 | 只看该作者
ps里面ctrl+T自由变换,把原点移到左上角,会自动吸附过去,然后显示出坐标,非常精确

评分

参与人数 1星屑 +200 收起 理由
「旅」 + 200 认可答案

查看全部评分

吸吸
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
4 小时
注册时间
2010-6-16
帖子
59
22
发表于 2010-6-30 21:24:44 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv3.寻梦者

孤独守望

梦石
0
星屑
3121
在线时间
1534 小时
注册时间
2006-10-16
帖子
4321

开拓者贵宾

23
发表于 2010-6-30 21:41:32 | 只看该作者
otz,明天写个定标脚本……晚上手机无法开rm。
菩提本非树,明镜本非台。回头自望路漫漫。不求姻缘,但求再见。
本来无一物,何处惹尘埃。风打浪吹雨不来。荒庭遍野,扶摇难接。
不知道多久更新一次的博客
回复 支持 反对

使用道具 举报

Lv1.梦旅人

剑仙·影羽

梦石
0
星屑
172
在线时间
224 小时
注册时间
2010-3-20
帖子
1580
24
发表于 2010-6-30 22:26:27 | 只看该作者
LZ我一般都用这个方法
在游戏里并行处理把角色的画面X、Y坐标代入到图片的移动位置(PS:可以用变量确定)
然后你的角色随便走,就可以看到图片和你角色也在一起动,因为是画面XY坐标,
所以图片不会离开视线\
(其实更方便的是F9的Debug,可以随便挑变量和开关:victory:)

——至今为止,谁也没能分析出他们为什么会因为说了这些话而死。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

孤独守望

梦石
0
星屑
3121
在线时间
1534 小时
注册时间
2006-10-16
帖子
4321

开拓者贵宾

25
发表于 2010-7-1 09:18:26 | 只看该作者
不是挖坟不是挖坟……
  1. module Stop
  2.   @@bitmap = Bitmap.new(640 * 2 + 1,480 * 2 + 1)
  3.   @@bitmap.fill_rect(640,0,1,960,Color.new(255,0,0))
  4.   @@bitmap.fill_rect(0,480,1280,1,Color.new(255,0,0))
  5.   @@viewport = Viewport.new(0,0,640,480)
  6.   @@viewport.z = 2000
  7.   @@sprite = Sprite.new(@@viewport)
  8.   @@sprite.bitmap = @@bitmap
  9.   @@sprite.visible = false
  10.   @@help_bitmap = Bitmap.new(200,48)
  11.   @@help_bitmap.font.color = Color.new(255,255,0)
  12.   @@help_sprite = Sprite.new(@@viewport)
  13.   @@help_sprite.bitmap = @@help_bitmap
  14.   @@help_sprite.visible = false
  15.   def self.main
  16.     @@sprite.visible = true
  17.     @@help_sprite.visible = true
  18.     @@sprite.x = -320
  19.     @@sprite.y = -240
  20.     begin
  21.       Graphics.update
  22.       Mouse.update
  23.       a = Mouse.pixels
  24.       @@sprite.x = a[0] - 640
  25.       @@sprite.y = a[1] - 480
  26.       @@help_bitmap.clear
  27.       @@help_bitmap.draw_text(0,0,200,48,"[#{a[0].to_s},#{a[1].to_s}]")
  28.     end until Mouse.press?(3) or Mouse.press?(2) or Mouse.press?(1)
  29.     @@sprite.visible = false
  30.     @@help_sprite.visible = false
  31.   end
  32. end

  33. class <<Input
  34.   alias stop_update_add update unless method_defined?("stop_update_add")
  35.   def update
  36.     stop_update_add
  37.     if Input.trigger?(Input::SHIFT)
  38.       Stop.main
  39.     end
  40.   end
  41. end
复制代码

  1. #==============================================================================
  2. # ** 鼠标输出模块
  3. #------------------------------------------------------------------------------
  4. #   微调 by zh99998
  5. #   版本 1.2a
  6. #   06-30-2010
  7. #   修复press判定
  8. #   基于沉影的鼠标系统修改版alpha
  9. #------------------------------------------------------------------------------
  10. #   by DerVVulfman
  11. #   版本 1.2
  12. #   08-18-2007
  13. #------------------------------------------------------------------------------
  14. #   建立在鼠标输出模块...
  15. #
  16. #   by Near Fantastica
  17. #------------------------------------------------------------------------------
  18. #   Set_Pos feature by
  19. #   Freakboy
  20. #------------------------------------------------------------------------------
  21. #
  22. #   CALLS:
  23. #
  24. #   Mouse.click?
  25. #   判断鼠标是否真的按下(Ture/False).
  26. #   这个值控制您按下的是左/右键,还是中键

  27. #
  28. #   Mouse.press?
  29. #   判断鼠标是否真的按下/保持按下状态
  30. #   这个值控制您按下的是左/右键,还是中键
  31. #   Mouse.pixels
  32. #   Mouse.pixels
  33. #   这个值返回鼠标所在的坐标(640*480大小),如果鼠标超出游戏画面,这个值为空
  34. #
  35. #   Mouse.tiles
  36. #   This returns  the mouse's screen  coordinates  in map tiles.   Based on the
  37. #   system's 20x15 tile size,  this returns it in index values  (a 0-19 width &
  38. #   a 0-14 height).  This functions the same manner as Mouse.pixels.
  39. #
  40. #   Mouse.set_pos
  41. #   This allows you  to forcefully position the mouse at an x/y position within
  42. #   the game screen by pixel coordinates.  Given the game's normal screen width
  43. #   of 640x480, adding:  Mouse.set_pos(320,240)  should position the mouse dead
  44. #   center of the gaming window.
  45. #
  46. #   Mouse.update
  47. #   Add this routine  into your update routines  to update  the mouse position.
  48. #   It must be called otherwise you won't get valid mouse coordinates.
  49. #
  50. #==============================================================================

  51. module Mouse
  52.   #--------------------------------------------------------------------------
  53.   # ## 常量
  54.   #--------------------------------------------------------------------------
  55.   GetAsyncKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
  56.   GetKeyState = Win32API.new("user32","GetKeyState",['i'],'i')
  57.   
  58.   ScreenToClient = Win32API.new('user32', 'ScreenToClient', 'lp', 'i')
  59.   
  60.   GetCursorPos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  61.   GetClientRect = Win32API.new('user32', 'GetClientRect', 'lp', 'i')
  62.   
  63.   #--------------------------------------------------------------------------
  64.   # * Mouse Click
  65.   #     button      : button
  66.   #--------------------------------------------------------------------------
  67.   def Mouse.click?(button)
  68.     return false if button == 1 and !$click_abled
  69.     return true if @keys.include?(button)
  70.     return false
  71.   end  
  72.   #--------------------------------------------------------------------------
  73.   # * Mouse Pressed
  74.   #     button      : button
  75.   #--------------------------------------------------------------------------
  76.   def Mouse.press?(button)
  77.     return true if @press.include?(button)
  78.     return false
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # * Mouse Pressed
  82.   #     button      : button
  83.   #--------------------------------------------------------------------------
  84.   def Mouse.area?(x, y, width=32, height=32)
  85.     return false if @pos == nil
  86.     return true if @pos[0] >= x and @pos[0] <= (x+width) and @pos[1] >= y and @pos[1] <= (y+height)
  87.     return false
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * Mouse Pixel Position
  91.   #--------------------------------------------------------------------------
  92.   def Mouse.pixels
  93.     return @pos == nil ? [0, 0] : @pos
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # * Mouse Tile Position
  97.   #--------------------------------------------------------------------------
  98.   def Mouse.tiles
  99.     return nil if @pos == nil
  100.     x = @pos[0] / 32
  101.     y = @pos[1] / 32
  102.     return [x, y]
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # * Set Mouse Position
  106.   #--------------------------------------------------------------------------
  107.   def Mouse.set_pos(x_pos=0, y_pos=0)
  108.     width, height = Mouse.client_size
  109.     if (x_pos.between?(0, width) && y_pos.between?(0, height))
  110.       x = Mouse.client_pos[0] + x_pos; y = Mouse.client_pos[1] + y_pos
  111.       Win32API.new('user32', 'SetCursorPos', 'NN', 'N').call(x, y)
  112.     end
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # * Mouse Update
  116.   #--------------------------------------------------------------------------
  117.   def Mouse.update
  118.     @pos            = Mouse.pos
  119.     @keys, @press   = [], []
  120.     @keys.push(1)   if GetAsyncKeyState.call(1) & 0X01 == 1
  121.     @keys.push(2)   if GetAsyncKeyState.call(2) & 0X01 == 1
  122.     @keys.push(3)   if GetAsyncKeyState.call(4) & 0X01 == 1
  123.     @press.push(1)  if GetKeyState.call(1) > 1
  124.     @press.push(2)  if GetKeyState.call(2) > 1
  125.     @press.push(3)  if GetKeyState.call(4) > 1
  126.     ## 鼠标双击
  127.     @wait ||= 0
  128.     @wait += 1 if @key != nil
  129.     (@key = nil; @wait = 0) if @wait > 30 # 双击时间
  130.   end  
  131.   #--------------------------------------------------------------------------
  132.   # * Automatic functions below
  133.   #--------------------------------------------------------------------------
  134.   #
  135.   #--------------------------------------------------------------------------
  136.   # * Obtain Mouse position in screen
  137.   #--------------------------------------------------------------------------
  138.   def Mouse.global_pos
  139.     pos = [0, 0].pack('ll')
  140.     if GetCursorPos.call(pos) != 0
  141.       return pos.unpack('ll')
  142.     else
  143.       return nil
  144.     end
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Return Screen mouse position within game window
  148.   #--------------------------------------------------------------------------
  149.   def Mouse.pos
  150.     x, y = Mouse.screen_to_client(*Mouse.global_pos)
  151.     width, height = Mouse.client_size
  152.     begin
  153.       if (x >= 0 and y >= 0 and x < width and y < height)
  154.         return x, y
  155.       else
  156.         return nil
  157.       end
  158.     rescue
  159.       return nil
  160.     end
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   #  * Pass Screen to Game System
  164.   #--------------------------------------------------------------------------
  165.   def Mouse.screen_to_client(x, y)
  166.     return nil unless x and y
  167.     pos = [x, y].pack('ll')
  168.     if ScreenToClient.call(HWND, pos) != 0
  169.       return pos.unpack('ll')
  170.     else
  171.       return nil
  172.     end
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Get Game Window Size
  176.   #--------------------------------------------------------------------------
  177.   def Mouse.client_size
  178.     rect = [0, 0, 0, 0].pack('l4')
  179.     GetClientRect.call(HWND, rect)
  180.     right, bottom = rect.unpack('l4')[2..3]
  181.     return right, bottom
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # * Get Window Position
  185.   #--------------------------------------------------------------------------
  186.   def Mouse.client_pos
  187.     rect = [0, 0, 0, 0].pack('l4')
  188.     ## 用户区
  189.     GetClientRect.call(HWND, rect)
  190.     left, upper = rect.unpack('l4')[0..1]
  191.     return left, upper
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ## 句柄
  195.   #--------------------------------------------------------------------------
  196.   def Mouse.get_hwnd
  197.     game_name = "\0" * 256
  198.     Win32API.new('kernel32', 'GetPrivateProfileStringA', 'pppplp', 'l').call('Game','Title','',game_name,255,".\\Game.ini")
  199.     game_name.delete!("\0")
  200.     return Win32API.new('user32', 'FindWindowA', 'pp', 'l').call('RGSS Player',game_name)
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ## 双击
  204.   #--------------------------------------------------------------------------
  205.   def self.double_click?(key)
  206.     if @keys.include?(key)
  207.       @key !=key ? (@key = key; return false) : (@key = nil; return true)
  208.     end
  209.   end
  210.   ## 句柄常量
  211.   HWND = Mouse.get_hwnd
  212.   
  213.   ###############
  214.   GetMessage = Win32API.new('user32','GetMessage','plll','l')
  215.   
  216.   Point = Struct.new(:x, :y)
  217.   Message = Struct.new(:message, :wparam, :lparam, :pt)
  218.   Param = Struct.new(:x, :y, :scroll)
  219.   
  220.   def self.scroll
  221.     msg = "\0"*32
  222.     GetMessage.call(msg,0,0,0)
  223.     r = wmcallback(unpack_msg(msg))
  224.     return r unless r.nil?
  225.   end
  226.   
  227.   def wmcallback(msg)
  228.     return unless msg.message == Scroll
  229.     param = Param.new
  230.     param.x = word2signed_short(loword(msg.lparam))
  231.     param.y = word2signed_short(hiword(msg.lparam))
  232.     param.scroll = word2signed_short(hiword(msg.wparam))
  233.     return [param.x,param.y,param.scroll]
  234.   end
  235.   
  236.   def hiword(dword)
  237.     ###return ((dword&0xffff0000)>>16)&0x0000ffff
  238.     return (dword & 0xffff0000) / 0x10000
  239.   end
  240.   
  241.   def loword(dword)
  242.     return dword&0x0000ffff
  243.   end
  244. end
复制代码
按Shift使用,按鼠标任意键退出。

评分

参与人数 1星屑 +600 收起 理由
「旅」 + 600 认可答案

查看全部评分

菩提本非树,明镜本非台。回头自望路漫漫。不求姻缘,但求再见。
本来无一物,何处惹尘埃。风打浪吹雨不来。荒庭遍野,扶摇难接。
不知道多久更新一次的博客
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
70
在线时间
2 小时
注册时间
2008-12-28
帖子
21
26
发表于 2010-7-5 08:33:20 | 只看该作者
一般情况下都是自己摸索吧...
回复 支持 反对

使用道具 举报

Lv3.寻梦者

宛若

梦石
0
星屑
1558
在线时间
526 小时
注册时间
2007-8-19
帖子
1493

极短24参与开拓者

27
发表于 2010-7-5 22:26:27 | 只看该作者
运用鼠标脚本 全屏 +此软件http://www.greendown.cn/soft/13186.html
[url=http://rpg.blue/thread-219730-1-1.html]http://unhero.sinaapp.com/wi.php[/url]
[color=Red]如你所见这是个死坑,没错这就是打我的脸用的[/color]
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-6 08:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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