Hello,
Im using this mouse module in my project:
But if I play the game in full screen (alt+enter) the mouse cursor just disappear. How can I make the cursor being visible?
Im using this mouse module in my project:
Code:
module Mouse
# Declarações de API
GAME_WINDOW = Win32API.new("user32", "GetActiveWindow", "v", "l").call
GET_RECT = Win32API.new("user32", "GetWindowRect", "lp", "l")
CUR_POS = Win32API.new("user32", "GetCursorPos", "p", "l")
GET_CLICK = Win32API.new("user32", "GetAsyncKeyState", "l", "l")
# Constantes
LEFT = 1
RIGHT = 2
SCROLL = 4
BUTTON4 = 5
BUTTON5 = 6
# Auxiliar
@state = {LEFT => 0, RIGHT => 0, SCROLL => 0, BUTTON4 => 0, BUTTON5 => 0}
# Métodos
module_function
# Atualização
def update
@state.each{|key, value|
@state[key] = (GET_CLICK.call(key) != 0 ? @state[key] + 1 : 0)
@state[key] = 15 if @state[key] == 17
}
end
# Método para posição em relação à janela
def pos
buffer = [[0,0].pack("l*"), [0,0].pack("l*")]
GET_RECT.call(GAME_WINDOW, buffer[0])
CUR_POS.call(buffer[1])
return buffer[1].unpack("l*").zip(buffer[0].unpack("l*")).map{|a, b| a - b}
end
def x
return self.pos[0] - 2
end
def y
return self.pos[1] - 23
end
def in_area?(ix, iy, lx, ly)
return true if self.x >= ix and self.x <= lx and self.y >= iy and self.y <= ly
return false
end
# Click único
def click?(button = LEFT)
return @state[button] == 1
end
# Pressionado
def press?(button = LEFT)
return @state[button] > 0
end
# Repetindo
def repeat?(button = LEFT)
return @state[button] == 1 || @state[button] == 16
end
end
=begin
class << Mouse
show_cursor = Win32API.new('user32', 'ShowCursor', 'l', 'l')
show_cursor.call(0)
$mousec = Sprite.new
$mousec.z = 10001
$mousec.x = $mousec.y = 1000
$mouse_icon = 'mecha_icon'
$mousec.bitmap = Script.cache($mouse_icon)
alias wor_mouse_upd_mouse update unless $@
def Mouse.update
wor_mouse_upd_mouse
if $mouse_old_icon.nil? or $mouse_old_icon != $mouse_icon
$mouse_old_icon = $mouse_icon
$mousec.bitmap = Script.cache($mouse_old_icon)
end
if self.pos.nil? or self.pos.empty?
$mousec.x = 1000 if $mousec.x != 1000
$mousec.y = 1000 if $mousec.y != 1000
else
$mousec.x = self.x if $mousec.x != self.x
$mousec.y = self.y if $mousec.y != self.y
end
end
end
=end
But if I play the game in full screen (alt+enter) the mouse cursor just disappear. How can I make the cursor being visible?