Jump to content
Rpg²S Forum
  • 0

Screen Touch


PietroMaker96
 Share

Question

allora io ho installato sul mio rpg questo script:

 

#======================================================================
========
# ● 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')

#==============================================================================
# ● Module Mouse
#==============================================================================

module Mouse  
LEFT = 0x01
RIGHT = 0x02

#--------------------------------------------------------------------------
# * Start Script
#--------------------------------------------------------------------------

def self.init(sprite = nil)
 $ShowCursor.call(0)
 @show_cursor = false
 @mouse_sprite = Sprite.new
 @mouse_sprite.z = 100000
 if $PokemonSystem.screensize==0
   @mouse_sprite.bitmap = Bitmap.new('Graphics/Pictures/mouse_2')
 else
   @mouse_sprite.bitmap = Bitmap.new('Graphics/Pictures/mouse_3')
 end
 @left_press = false
 @right_press = false
 @left_trigger = false
 @right_trigger = false
 @left_repeat = false
 @right_repeat = false
 @click_lock = false
 update
end

#--------------------------------------------------------------------------
# * Change Mouse Picture
#--------------------------------------------------------------------------

def self.picture(picture=nil)
 if picture == nil
   if $PokemonSystem.screensize==0
     @mouse_sprite.bitmap = Bitmap.new('Graphics/Pictures/mouse_2')
   else
     @mouse_sprite.bitmap = Bitmap.new('Graphics/Pictures/mouse_3')
   end
 else
   @mouse_sprite.bitmap = BitmapCache.load_bitmap(picture)
 end
end

#--------------------------------------------------------------------------
# * Remove Mouse
#--------------------------------------------------------------------------

def self.exit
 @mouse_sprite.bitmap.dispose
 @mouse_sprite.dispose
 @show_cursor = true
 $ShowCursor.call(1)
end

#--------------------------------------------------------------------------
# * Debug
#--------------------------------------------------------------------------

def self.mouse_debug
 return @mouse_debug.bitmap
end

#--------------------------------------------------------------------------
# * Update Mouse
#--------------------------------------------------------------------------

def self.update
 left_down = $GetKeyState.call(0x01)
 right_down = $GetKeyState.call(0x02)
 if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
   @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
   @a = !@a
 end
 if $scene.is_a?(Scene_Map) == false
   $mouse_icon_id = 0
 end

 @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[7] == 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[7] == 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

#--------------------------------------------------------------------------
# * Get Mouse's Position
#--------------------------------------------------------------------------

def self.get_mouse_pos
 point_var = [0, 0].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 > Graphics.width then x = Graphics.width end
     if y > Graphics.height then y = Graphics.height end
     if $PokemonSystem.screensize==1
       return x, y
     elsif $PokemonSystem.screensize==0
       z=x
       x=z*2
       z=y
       y=z*2
       return x, y
     end
   else
     return 0, 0
   end
 else
   return 0, 0
 end
end

#--------------------------------------------------------------------------
# * Mouse Click
#--------------------------------------------------------------------------

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

#--------------------------------------------------------------------------
# * Mouse Trigger
#--------------------------------------------------------------------------

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

#--------------------------------------------------------------------------
# * Mouse Repeat
#--------------------------------------------------------------------------

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

#--------------------------------------------------------------------------
# * Mouse Click Lock Check
#--------------------------------------------------------------------------

def self.click_lock?
 return @click_lock
end

#--------------------------------------------------------------------------
# * Mouse Click Lock
#--------------------------------------------------------------------------

def self.click_lock
 @click_lock = true
end

#--------------------------------------------------------------------------
# * Mouse Click Unlock
#--------------------------------------------------------------------------

def self.click_unlock
 @click_lock = false
end

end

#==============================================================================
# ● Module Input
#==============================================================================

module Input

#--------------------------------------------------------------------------
# * Starting Key Input
#--------------------------------------------------------------------------

if @self_update == nil
 @self_update = method('update')
 @self_press = method('press?')
 @self_trigger = method('trigger?')
 @self_repeat = method('repeat?')
end

#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------

def self.update
 @self_update.call
 Mouse.update
end

#--------------------------------------------------------------------------
# * Key Press
#--------------------------------------------------------------------------

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

#--------------------------------------------------------------------------
# * Key Trigger
#--------------------------------------------------------------------------

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

#--------------------------------------------------------------------------
# * Key Repeat
#--------------------------------------------------------------------------

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

#==============================================================================
# ● Touchable List
#==============================================================================

=begin
class SpriteWindow_Selectable
if @self_alias == nil
 alias self_update update
 @self_alias = true
end
def update
 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
   testmin = (@index-(height/(@row_height+@column_spacing)))
   testmax = (height/(@row_height+@column_spacing)+@index)
   if testmin < 0
     testmin = 0
   end
   if testmax > @item_max
     testmax = @item_max
   end
   for i in testmin...testmax
     @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
  update_cursor_rect
 end
end
end
=end

#==============================================================================
# ● Call Mouse
#==============================================================================

Mouse.init
END { Mouse.exit }

 

serve a creare senza dual screen il touch ma la domanda è

 

come si fa a fare che tu con il cursore ti serve solo da pulsante azione??

 

cioè tipo quando tu scegli il nome vai con il cursore sulla letterina fai click e ti viene fuore la lettera k hai clikkato intendo??

 

io so alcune basi dell'rgss ma nn so come potere modificare nn so proprio dove mettere le mani

 

aiutatemi^^

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...