Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Cursor Help

Im using the cusor system made by squall from rmxp.net squall@loeher.zzn.com

Code:
#******************************************************************************
# â–¡ Module Graphic
#******************************************************************************

module Graphic
 #--------------------------------------------------------------------------
 # ● Graphic.move() method to move pictures and windows.
 #--------------------------------------------------------------------------
 def self.move(pic, pic_x, pic_y, speed = 50)
   if pic.x <= pic_x
     pic.x += pic.x + speed > pic_x ? pic_x - pic.x : speed
   else
     pic.x -= pic.x - speed < pic_x ? pic.x - pic_x : speed
   end
   if pic.y <= pic_y
     pic.y += pic.y + speed > pic_y ? pic_y - pic.y : speed
   else
     pic.y -= pic.y - speed < pic_y ? pic.y - pic_y : speed
   end
 end
 #--------------------------------------------------------------------------
 # ● Graphic.opacity() method to change pictures and windows opacity.
 #--------------------------------------------------------------------------
 def self.opacity(pic, max_opacity, speed)
   if pic.opacity < max_opacity
     pic.opacity += pic.opacity + speed < max_opacity ? speed : max_opacity - pic.opacity
   elsif pic.opacity > max_opacity
     pic.opacity -= pic.opacity - speed > max_opacity ? speed : pic.opacity - max_opacity
   end
 end
 #--------------------------------------------------------------------------
 # ● Graphic.grow() method to change pictures or windows height.
 #--------------------------------------------------------------------------
 def self.grow(pic, height, speed = 5)
   if pic.height <= height
     pic.height += pic.height + speed > height ? height - pic.height : speed
   else
     pic.height -= pic.height - speed < height ? pic.height - height : speed
   end
 end
 #--------------------------------------------------------------------------
 # ● Graphic.enlarge() method to change pictures or windows width.
 #--------------------------------------------------------------------------
 def self.enlarge(pic, width, speed = 5)
   if pic.width <= width
     pic.width += pic.width + speed > width ? width - pic.width : speed
   else
     pic.width -= pic.width - speed < width ? pic.width - width : speed
   end
 end
 #--------------------------------------------------------------------------
 # ● Graphic.square()
 #--------------------------------------------------------------------------
 def self.square(x, y, width, color)
   w = width + 34
   @win = Window_Base.new(x, y, w, w)
   @win.contents = Bitmap.new(w - 32, w - 32)
   @win.opacity = 0
   @win.z = 3000
   @win.contents.fill_rect(0, 0, width, 1, color)
   @win.contents.fill_rect(0, 0, 1, width, color)
   @win.contents.fill_rect(0 + width, 0, 1, width + 1, color)
   @win.contents.fill_rect(0, 0 + width, width + 1, 1, color)
 end
 #--------------------------------------------------------------------------
 # ● Graphic.circle() //credit to Axe Man Deke (from rmxp.net) for this part ^^//
 #--------------------------------------------------------------------------
 def self.circle(x, y, r, width, color, intervals = 360.0)
   r += width
   @win = Window_Base.new(x - r - 16, y - r - 16, r * 2 + 32, r * 2 + 32)
   @win.contents = Bitmap.new(@win.width - 32, @win.height - 32)
   @win.opacity = 0
   @win.z = 3000
   each = 360.0 / intervals
   for j in 0...width
     rad = r - j
     for i in 0...intervals
       angle = (i * each) / (2.0 * Math::PI)
       x_pos = Math.cos(angle) * rad + r
       y_pos = Math.sin(angle) * rad + r
       @win.contents.fill_rect(x_pos, y_pos, 1, 1, color)
     end
   end
 end
 #--------------------------------------------------------------------------
 # ● Graphic.stop
 #--------------------------------------------------------------------------
 def self.stop
   @win.dispose
 end
end

#==============================================================================
# â–  Window_Selectable
#==============================================================================

class Window_Selectable < Window_Base
 #--------------------------------------------------------------------------
 # ● define instance variable
 #--------------------------------------------------------------------------
  attr_reader    :index
  attr_reader    :help_window
  attr_accessor :cursor
 #--------------------------------------------------------------------------
 # ● initialize
 #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    @cursor = Sprite.new
    @cursor.bitmap = RPG::Cache.picture("cursor")
    @cursor.z = 10000
    @num = 0
    super(x, y, width, height)
    @item_max = 1
    @column_max = 1
    @index = -1
  end
 def x=(x)
   super
   @cursor.x = x
 end
 def y=(y)
   super
   @cursor.y = y
 end
 #--------------------------------------------------------------------------
 # ● animate the cursor
 #--------------------------------------------------------------------------
 def animation
   @num += 1
   if @num == 1 or @num == 2
     a = 1
   elsif @num == 3 or @num == 4 
     a = 2
   elsif @num == 5 or @num == 6
     a = 3
   elsif @num == 7 or @num == 8
     a = 4
   elsif @num == 9 or @num == 10
     a = 3
   elsif @num == 11 or @num == 12
     a = 2
   elsif @num == 13 or @num == 14
     a = 2
   elsif @num == 15 or @num == 16
     a = 1
   elsif @num == 17 or @num == 18
     a = 0
   elsif @num == 19 or @num == 20
     a = -1
   elsif @num == 21 or @num == 22
     a = -2
   elsif @num == 23 or @num == 24
     a = -3
   elsif @num == 25 or @num == 26
     a = -2
   elsif @num == 27 or @num == 28
     a = -1
   elsif @num == 29 or @num == 30
     a = 0
     @num = 0
   end
   unless a != nil
     a = 0
   end
   return a
 end
 #--------------------------------------------------------------------------
 # ● set the cursor according to current index
 #--------------------------------------------------------------------------
 def set_cursor
   if @index < 0 or self.visible == false
     @cursor.opacity = 0
   else
     @cursor.opacity = 255
   end
   row = @index / @column_max
   if row < self.top_row
     self.top_row = row
   end
   if row > self.top_row + (self.page_row_max - 1)
     self.top_row = row - (self.page_row_max - 1)
   end
   cursor_width = self.width / @column_max - 32
   x = @index % @column_max * (cursor_width + 32)-5
   y = @index / @column_max * 32 - self.oy + animation+20
   Graphic.move(@cursor, x + self.x + 4, y + self.y + 4)
 end
 #--------------------------------------------------------------------------
 # ● redefine dispose method to dispose the cursor
 #--------------------------------------------------------------------------
 def dispose
   @cursor.dispose
   super
 end
 #--------------------------------------------------------------------------
 # ● define the cursor position
 #--------------------------------------------------------------------------
 def index=(index)
   @index = index
   if self.active and @help_window != nil
     update_help
   end
   set_cursor
 end
 #--------------------------------------------------------------------------
 # ● フレーム更新
 #--------------------------------------------------------------------------
 def update
   super
   if self.active and @item_max > 0 and @index >= 0
     if Input.repeat?(Input::DOWN)
       if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
          @index < @item_max - @column_max
         $game_system.se_play($data_system.cursor_se)
         @index = (@index + @column_max) % @item_max
       end
     end
     if Input.repeat?(Input::UP)
       if (@column_max == 1 and Input.trigger?(Input::UP)) or
          @index >= @column_max
         $game_system.se_play($data_system.cursor_se)
         @index = (@index - @column_max + @item_max) % @item_max
       end
     end
     if Input.repeat?(Input::RIGHT)
       if @column_max >= 2 and @index < @item_max - 1
         $game_system.se_play($data_system.cursor_se)
         @index += 1
       end
     end
     if Input.repeat?(Input::LEFT)
       if @column_max >= 2 and @index > 0
         $game_system.se_play($data_system.cursor_se)
         @index -= 1
       end
     end
     if Input.repeat?(Input::R)
       if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
         $game_system.se_play($data_system.cursor_se)
         @index = [@index + self.page_item_max, @item_max - 1].min
         self.top_row += self.page_row_max
       end
     end
     if Input.repeat?(Input::L)
       if self.top_row > 0
         $game_system.se_play($data_system.cursor_se)
         @index = [@index - self.page_item_max, 0].max
         self.top_row -= self.page_row_max
       end
     end
   end
   if self.active and @help_window != nil
     update_help
   end
   set_cursor
 end
end

I modified the Window_Target to this

Code:
#==============================================================================
# ** Window_Target
#------------------------------------------------------------------------------
#  This window selects a use target for the actor on item and skill screens.
#==============================================================================

class Window_Target < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 180, 392)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.z += 10
    @item_max = $game_party.actors.size
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...$game_party.actors.size
      x = 4
      y = i * 91
      actor = $game_party.actors[i]
      draw_actor_name(actor, x, y)
      draw_actor_state(actor, x + 60, y)
      draw_actor_hp(actor, x - 1, y + 25)
      draw_actor_sp(actor, x - 1, y + 50)
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Update
  #--------------------------------------------------------------------------
  def set_cursor
    if @index < 0
      @cursor.opacity = 0
    else
      @cursor.opacity = 255
      Graphic.move(@cursor, 8, 105 + @index * 91 + animation)
    end
  end
end

My problem is now when you go to skills and choose to heal someone and then back out it leaves the cursor there so there are two, one floating in space where the target window was and the one your using to choose the skill with.
I need to get rid of the floating out there in space.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top