Ring Menu
Version: 1.8.1
By: Trebor777
Introduction
A nice customizable Ring Menu :) that you can where you want! It's not a scene! :)
but an actual "object" like a window.
Features
[list]
[*]Specify the radius for the Vertical and Horizontal dimension. :) If Horizontal is 0, you have a vertical riing menu.
[*]Pass a block of code to each options! :)
[*]Icons can be from the icon set or an independant file.
[*]"Perspective effect" if "zoom" activated.
[*]Smooth "scrolling" between options :) you can even specify how smooth you want it!
[*]Easy access to the "selected" option, and possibilty to disable options as well :)( they will be skipped when scrolling )
[*]Non-static => you can move the menu around and change its attributes after creation!
[*] Brings a few useful methods to the Array class :)[/list]
1.8->1.8.1
Fixed: You can now used Up/Down Keys when it's a vertical ring menu
Screenshots
-> From Castlevania :

Demo
Basic demo for VX 400KB
Basic demo for XP 262KB
Look at the Scene_Demo script :)
Script
Instructions
Very easy to use, only a few things to keep in mind!
->Paste the script above main!
->Now to create a ring menu:
Step 1
- you need to create the options like this =>
FOR VX ONLY : If icon_id is equal to 0 ( its default value), it will look for an image named with "Name" in a folder called "Icons" in the Graphics folder.
FOR XP only: Because XP doesn't have an icon set, the icon feature only works with the name, the xp script doesn't care about the Icon id, and will only look for a valid icon name
The block is optional as well :) if not needed, don't write anything after the parenthesis.
Step 2
You place those options inside a temporary array, this array will be used when creating the menu:
Step 3
Create the menu!
-> by default h_radius and v_radius = 10, x & y = 0 and opt_array is an empty array.
Yes that means you can add/remove options later on!
That's for the basic Creation!
-> The menu needs to be updated! Like any normal graphical object in a scene. :) menu.update
No need to use code stuff for arrow keys, it's already done in the update method.
-> AND to be disposed as well :) menu.dispose
To get the current selected option : menu.selected
Therefore: to execute the optional block given at the option creation, -> menu.selected.call
Like a window, the menu is only active or visible when you want it: menu.active/visible = true/false,
The zoom attribute: if true ( menu.zoom = true ), it'll activate the perspective effect, -> basically the options 'in front' of us are bigger than the options in the back.
By default the "max size" is 40% bigger than the original file (zoom_x/y = 1.4)
But you can change that max value if required. For example -> menu.zoom_max = 1.0
If you need to change the fluidity of the menu scrolling: you need to use -> menu.reso= value
by default this value is 4, it means it takes 4 frames to go from one option to another.
If you intend to change the "fluidity", it's important that you do it before anything else.
You can play with the opacity, as well like sprites.
FAQ
[i]"I've noticed some constants in the RingMenu class, what are they? Can I use them?"
3 Constants:
- RESO : the default "fluidity"(number of frames) used to move from one option ot another, you can change it, if you don't want to do it for several menu that use the same value
- PLAY_SE : if false, the menu won't make any noise when being scrolled.
- SELECTED_ANGLE : I suggest you don't touch it. The function -> Because a 0° angle is on the right on the trigonometric circle, I need to "rotate" that circle in order to have the 0 , in front of me, which is at the bottom. It is used when the menu is "horizontal", to have the selected option, in front of us, instead of the right of the ring. The angle is in Radian.
When I press Up/Down on a vertical ring menu, nothing happens, Why ?
-> Check that the horizontal radius is 0, if not, Use the left/right keys!
Compatibility
I've added Methods to the cache module, to the array Class, the sprite Class as well
As long as no other classes are called like mines, it should be fine. ( too lazy to put mine into a module. )
Author's Notes
I did this script for the 1st time in 12/2007 on XP :) and updated for my needs with time.
It's used in Castlevania as well. And I thought I should release it, cause it's a very convenient thing to use!
Terms and Conditions
Everywhere you want, just credit me :)
Version: 1.8.1
By: Trebor777
Introduction
A nice customizable Ring Menu :) that you can where you want! It's not a scene! :)
but an actual "object" like a window.
Features
[list]
[*]Specify the radius for the Vertical and Horizontal dimension. :) If Horizontal is 0, you have a vertical riing menu.
[*]Pass a block of code to each options! :)
[*]Icons can be from the icon set or an independant file.
[*]"Perspective effect" if "zoom" activated.
[*]Smooth "scrolling" between options :) you can even specify how smooth you want it!
[*]Easy access to the "selected" option, and possibilty to disable options as well :)( they will be skipped when scrolling )
[*]Non-static => you can move the menu around and change its attributes after creation!
[*] Brings a few useful methods to the Array class :)[/list]
1.8->1.8.1
Fixed: You can now used Up/Down Keys when it's a vertical ring menu
Screenshots
-> From Castlevania :

Demo
Basic demo for VX 400KB
Basic demo for XP 262KB
Look at the Scene_Demo script :)
Script
script FOR VX
Spoiler
- #===============================================================================
- =begin
- RING MENU advanced.
- by Trebor777
- v1.8.1
- 24/07/2009
- An independant, class free, Ring menu, easily usable, with a lot of options.
- =end
- #===============================================================================
- class Array
- # rotate n item(s) to the left ( first becomes last) as a new array
- def rotate_l(n=1)
- a = self.clone
- n.times{a.push(a.shift)}
- return a
- end
- # rotate n item(s) to the right ( last becomes first) as a new array
- def rotate_r(n=1)
- a = self.clone
- n.times{a.unshift(a.pop)}
- return a
- end
- # rotate n item(s) to the left
- def rotate_l!(n=1)
- n.times{self.push(self.shift)}
- return self
- end
- # rotate n item(s) to the right
- def rotate_r!(n=1)
- n.times{self.unshift(self.pop)}
- return self
- end
- # Do the sum of all the items. (they need to be all of the same type)
- def sum
- inject( nil ) { |sum,x| sum ? sum+x : x if x.respond_to? "+" }
- end
- end
- #===============================================================================
- class Sprite
- #--------------------------------------------------------------------------
- # * Draw Icon
- # icon_index : Icon number
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # enabled : Enabled flag. When false, draw semi-transparently.
- #--------------------------------------------------------------------------
- def draw_icon(icon_index, x, y, enabled = true)
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 128)
- end
- end
- #===============================================================================
- module Cache
- def self.icon(filename)
- load_bitmap("Graphics/Icons/",filename)
- end
- end
- #===============================================================================
- class Ring_Menu
- RESO = 4
- PLAY_SE = true
- SELECTED_ANGLE= Math::PI/2.0 # 90°CW to set the "0" at the bottom
- #---------------------------------
- attr_reader :options, :h_radius, :v_radius, :center, :zoom, :visible, :opacity, :zoom_max, :reso
- attr_accessor :active, :index
- #---------------------------------
- def initialize(h_rad=10,v_rad=10,center=Table.new(2),options=[])
- @options=options
- @v_radius=v_rad
- @h_radius=h_rad
- @center = center
- @index=0
- @reso = RESO
- @visible = true
- @zoom_max = 1.4
- @opacity = 255
- @active = true
- @zoom = true
- @angle = h_rad == 0 ? 0 : SELECTED_ANGLE
- process
- end
- # Attributes
- def options=(a=[])
- @options=a
- @index=0
- process
- end
- def vertical?
- @h_radius == 0
- end
- def x
- @center[0]
- end
- def y
- @center[1]
- end
- def x=(*args)
- @center[0]= args.first
- process
- end
- def y=(*args)
- @center[1]= args.first
- process
- end
- def visible=(value)
- @visible = value
- @options.each{|opt| opt.sprite.visible=value if !opt.nil?}
- end
- def opacity=(value)
- value = 0 if value < 0
- value = 255 if value > 255
- @opacity = value
- @options.each{|opt| opt.sprite.opacity=value}
- end
- def h_radius=(value)
- @h_radius = value
- end
- def v_radius=(value)
- @v_radius = value
- end
- def center=(value)
- @center = value
- end
- def zoom=(value)
- @zoom = value
- draw
- end
- def reso=(v)
- @reso = v
- process
- end
- def zoom_max=(value)
- @zoom_max= value
- process
- end
- # ENd Attributes
- #---------------------------------
- # Update
- #---------------------------------
- def update
- return if !self.active or !self.visible
- update_flag = (@old_center!=@center or @old_hr != @h_radius or @old_vr != @v_radius)
- if Input.repeat?(vertical? ? Input::UP : Input::LEFT)
- loop do
- rotate
- break unless self.selected.disabled
- end
- elsif Input.repeat?(vertical? ? Input::DOWN : Input::RIGHT)
- loop do
- rotate(1)
- break unless self.selected.disabled
- end
- end
- process if update_flag
- end
- #---------------------------------
- # Process: Create/recreate according to the menu attributes, the position/zoom values of the options, and store them into arrays.
- #---------------------------------
- def process
- # return if the menu is empty.
- return if @options.empty?
- # Get the maximum size for the arrays.
- max_data=@options.size*@reso
- # Divide a circle(2*Pi) by the numbers of options.
- @base_angle = Math::PI*2.0/max_data
- @zoom_step = (@zoom_max-0.5)/(max_data/2.0)
- # set an array having precalculated pair of coordinates so we don't have to
- # get process them for each rotation(we simply switch the options coords)
- @coord_set= Array.new(max_data,0)
- # and for zoom values as well
- @zoom_set = Array.new(max_data,0)
- max_data.times do |i|
- angle = i*@base_angle+@angle
- x = (Math::cos(angle)*@h_radius)+@center[0]
- y = (Math::sin(angle)*@v_radius)+@center[1]
- @coord_set[i]=([x,y])
- @zoom_set[i]= i<max_data/2.0 ? @zoom_max-@zoom_step*i : @zoom_set[max_data/2.0-i-max_data/2.0-1]
- end
- val = (@index % max_data)+1+((@reso-4)/2.0).round
- @coord_set.rotate_r!(val)
- @zoom_set.rotate_r!(val)
- @old_center = @center
- @old_hr = @h_radius
- @old_vr = @v_radius
- draw
- self.selected.selected = true
- if @h_radius==0
- self.selected.sprite.z =1000
- end
- end
- #--------------------------------------
- # Draw the options according to the current index
- #--------------------------------------
- def draw
- @coord_set.each_index do |index|
- i = (index / @reso.to_f).round
- # next iteration if the current option is not a RMenu_Option
- next if !@options[i].is_a?(RMenu_Option)
- # Set the Option coords
- (@options[i]).coord = @coord_set[index]
- # Set the option's Z-index to its y.
- @options[i].z = @coord_set[index][1]
- #@options.zoom = 1.0 if !@zoom
- @options[i].zoom = @zoom? @zoom_set[index] : 1.0
- #@options[i].selected = (@options[i]==self.selected)
- end
- @old_zoom = @zoom
- Graphics.update
- end
- #---------------------------------
- # Rotate the menu options
- #---------------------------------
- def rotate(way=0)# 0 = left, 1 = right
- self.selected.selected = false
- Sound.play_cursor if PLAY_SE
- frcount = Graphics.frame_count # Save the current frame count ( -> Game Time )
- @index += way*2-1
- @index %= @options.size
- @reso.times do
- if way==0
- @coord_set.rotate_l!
- @zoom_set.rotate_l!
- elsif way==1
- @coord_set.rotate_r!
- @zoom_set.rotate_r!
- end
- draw
- end
- self.selected.selected = true
- if @h_radius==0
- self.selected.sprite.z =1000 # Set the selected option to the top
- end
- Graphics.frame_count = frcount # Reset the frame count to the previous value
- end
- #---------------------------------
- # Return the current selected option
- #---------------------------------
- def selected
- @options[@index % @options.size]
- end
- #---------------------------------
- # Dispose the menu (and all the options)
- #---------------------------------
- def dispose
- @options.each{|opt| opt.dispose}
- end
- #--------------------------------------------------------------------------
- # * Save State
- #--------------------------------------------------------------------------
- def save_state
- @state_visible = self.visible
- @state_active = self.active
- end
- #--------------------------------------------------------------------------
- # * Load State
- #--------------------------------------------------------------------------
- def load_state
- self.visible = @state_visible unless @state_visible.nil?
- self.active = @state_active unless @state_active.nil?
- end
- #--------------------------------------------------------------------------
- # * Hide
- #--------------------------------------------------------------------------
- def hide
- self.visible = false
- self.active = false
- end
- #--------------------------------------------------------------------------
- # * Show
- #--------------------------------------------------------------------------
- def show
- self.visible = true
- self.active = true
- end
- end
- #===============================================================================
- # Menu option class
- class RMenu_Option
- attr_reader :name, :icon, :coord, :sprite, :selected, :disabled
- attr_accessor :angle
- def initialize(name="",icon=0,viewport=nil,&block)
- @name=name
- @icon=icon
- @block=block
- @angle = 0
- @coord=Table.new(2)
- @disabled = false
- @sprite = Sprite.new(viewport)
- if icon != 0
- @sprite.bitmap = Bitmap.new(24,24)
- @sprite.draw_icon(@icon,0,0,true)
- else
- @sprite.bitmap = Cache.icon(name)
- end
- #p @sprite.bitmap.width/2,@sprite.bitmap.height/2
- @sprite.ox = @sprite.bitmap.width/2
- @sprite.oy = @sprite.bitmap.height/2
- @selected = false
- @sprite.tone.gray = 255
- end
- def call
- return if @block.nil?
- @block.call
- end
- def z=(value)
- @sprite.z = value
- end
- def selected=(v)
- if v != @selected
- @sprite.tone.gray = (v==true ? 0 : 255)
- @selected = v==true
- end
- end
- def disabled=(v)
- @disabled= v==true
- end
- def coord=(c = [0,0])
- @coord=c
- @sprite.x = @coord[0]
- @sprite.y = @coord[1]
- end
- def x=(*args)
- @coord[0]= args.first
- @sprite.x= args.first
- end
- def y=(*args)
- @coord[1]= args.first
- @sprite.y= args.first
- end
- def zoom=value
- @sprite.zoom_x = value
- @sprite.zoom_y = value
- end
- def dispose
- @coord=nil
- @block=nil
- @sprite.dispose
- end
- end
Expand to see the code.
SCRIPT FOR XP
Spoiler
- #===============================================================================
- =begin
- RING MENU advanced.
- by Trebor777
- v1.8.1
- 24/07/2009
- An independant, class free, Ring menu, easily usable, with a lot of options.
- =end
- #===============================================================================
- class Array
- # rotate n item(s) to the left ( first becomes last) as a new array
- def rotate_l(n=1)
- a = self.clone
- n.times{a.push(a.shift)}
- return a
- end
- # rotate n item(s) to the right ( last becomes first) as a new array
- def rotate_r(n=1)
- a = self.clone
- n.times{a.unshift(a.pop)}
- return a
- end
- # rotate n item(s) to the left
- def rotate_l!(n=1)
- n.times{self.push(self.shift)}
- return self
- end
- # rotate n item(s) to the right
- def rotate_r!(n=1)
- n.times{self.unshift(self.pop)}
- return self
- end
- # Do the sum of all the items. (they need to be all of the same type)
- def sum
- inject( nil ) { |sum,x| sum ? sum+x : x if x.respond_to? "+" }
- end
- end
- module Sound
- #--------------------------------------------------------------------------
- # * Play Sound Effect
- # se : sound effect to be played
- #--------------------------------------------------------------------------
- def self.se_play(se)
- if se != nil and se.name != ""
- Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
- end
- end
- def self.play_cursor
- se_play($data_system.decision_se) unless $data_system.nil?
- end
- end
- #===============================================================================
- class Ring_Menu
- RESO = 4
- PLAY_SE = true
- SELECTED_ANGLE= Math::PI/2.0 # 90°CW to set the "0" at the bottom
- #---------------------------------
- attr_reader :options, :h_radius, :v_radius, :center, :zoom, :visible, :opacity, :zoom_max, :reso
- attr_accessor :active, :index
- #---------------------------------
- def initialize(h_rad=10,v_rad=10,center=Table.new(2),options=[])
- @options=options
- @v_radius=v_rad
- @h_radius=h_rad
- @center = center
- @index=0
- @reso = RESO
- @visible = true
- @zoom_max = 1.4
- @opacity = 255
- @active = true
- @zoom = true
- @angle = h_rad == 0 ? 0 : SELECTED_ANGLE
- process
- end
- # Attributes
- def options=(a=[])
- @options=a
- @index=0
- process
- end
- def vertical?
- @h_radius == 0
- end
- def x
- @center[0]
- end
- def y
- @center[1]
- end
- def x=(*args)
- @center[0]= args.first
- process
- end
- def y=(*args)
- @center[1]= args.first
- process
- end
- def visible=(value)
- @visible = value
- @options.each{|opt| opt.sprite.visible=value if !opt.nil?}
- end
- def opacity=(value)
- value = 0 if value < 0
- value = 255 if value > 255
- @opacity = value
- @options.each{|opt| opt.sprite.opacity=value}
- end
- def h_radius=(value)
- @h_radius = value
- end
- def v_radius=(value)
- @v_radius = value
- end
- def center=(value)
- @center = value
- end
- def zoom=(value)
- @zoom = value
- draw
- end
- def reso=(v)
- @reso = v
- process
- end
- def zoom_max=(value)
- @zoom_max= value
- process
- end
- # ENd Attributes
- #---------------------------------
- # Update
- #---------------------------------
- def update
- return if !self.active or !self.visible
- update_flag = (@old_center!=@center or @old_hr != @h_radius or @old_vr != @v_radius)
- if Input.repeat?(vertical? ? Input::UP : Input::LEFT)
- loop do
- rotate
- break unless self.selected.disabled
- end
- elsif Input.repeat?(vertical? ? Input::DOWN : Input::RIGHT)
- loop do
- rotate(1)
- break unless self.selected.disabled
- end
- end
- process if update_flag
- end
- #---------------------------------
- # Process: Create/recreate according to the menu attributes, the position/zoom values of the options, and store them into arrays.
- #---------------------------------
- def process
- # return if the menu is empty.
- return if @options.empty?
- # Get the maximum size for the arrays.
- max_data=@options.size*@reso
- # Divide a circle(2*Pi) by the numbers of options.
- @base_angle = Math::PI*2.0/max_data
- @zoom_step = (@zoom_max-0.5)/(max_data/2.0)
- # set an array having precalculated pair of coordinates so we don't have to
- # get process them for each rotation(we simply switch the options coords)
- @coord_set= Array.new(max_data,0)
- # and for zoom values as well
- @zoom_set = Array.new(max_data,0)
- max_data.times do |i|
- angle = i*@base_angle+@angle
- x = (Math::cos(angle)*@h_radius)+@center[0]
- y = (Math::sin(angle)*@v_radius)+@center[1]
- @coord_set[i]=([x,y])
- @zoom_set[i]= i<max_data/2.0 ? @zoom_max-@zoom_step*i : @zoom_set[max_data/2.0-i-max_data/2.0-1]
- end
- val = (@index % max_data)+1+((@reso-4)/2.0).round
- @coord_set.rotate_r!(val)
- @zoom_set.rotate_r!(val)
- @old_center = @center
- @old_hr = @h_radius
- @old_vr = @v_radius
- draw
- self.selected.selected = true
- if @h_radius==0
- self.selected.sprite.z =1000
- end
- end
- #--------------------------------------
- # Draw the options according to the current index
- #--------------------------------------
- def draw
- @coord_set.each_index do |index|
- i = (index / @reso.to_f).round
- # next iteration if the current option is not a RMenu_Option
- next if !@options[i].is_a?(RMenu_Option)
- # Set the Option coords
- (@options[i]).coord = @coord_set[index]
- # Set the option's Z-index to its y.
- @options[i].z = @coord_set[index][1]
- #@options.zoom = 1.0 if !@zoom
- @options[i].zoom = @zoom? @zoom_set[index] : 1.0
- #@options[i].selected = (@options[i]==self.selected)
- end
- @old_zoom = @zoom
- Graphics.update
- end
- #---------------------------------
- # Rotate the menu options
- #---------------------------------
- def rotate(way=0)# 0 = left, 1 = right
- self.selected.selected = false
- Sound.play_cursor if PLAY_SE
- frcount = Graphics.frame_count # Save the current frame count ( -> Game Time )
- @index += way*2-1
- @index %= @options.size
- @reso.times do
- if way==0
- @coord_set.rotate_l!
- @zoom_set.rotate_l!
- elsif way==1
- @coord_set.rotate_r!
- @zoom_set.rotate_r!
- end
- draw
- end
- self.selected.selected = true
- if @h_radius==0
- self.selected.sprite.z =1000 # Set the selected option to the top
- end
- Graphics.frame_count = frcount # Reset the frame count to the previous value
- end
- #---------------------------------
- # Return the current selected option
- #---------------------------------
- def selected
- @options[@index % @options.size]
- end
- #---------------------------------
- # Dispose the menu (and all the options)
- #---------------------------------
- def dispose
- @options.each{|opt| opt.dispose}
- end
- #--------------------------------------------------------------------------
- # * Save State
- #--------------------------------------------------------------------------
- def save_state
- @state_visible = self.visible
- @state_active = self.active
- end
- #--------------------------------------------------------------------------
- # * Load State
- #--------------------------------------------------------------------------
- def load_state
- self.visible = @state_visible unless @state_visible.nil?
- self.active = @state_active unless @state_active.nil?
- end
- #--------------------------------------------------------------------------
- # * Hide
- #--------------------------------------------------------------------------
- def hide
- self.visible = false
- self.active = false
- end
- #--------------------------------------------------------------------------
- # * Show
- #--------------------------------------------------------------------------
- def show
- self.visible = true
- self.active = true
- end
- end
- #===============================================================================
- # Menu option class
- class RMenu_Option
- attr_reader :name, :icon, :coord, :sprite, :selected, :disabled
- attr_accessor :angle
- def initialize(name="",icon=0,viewport=nil,&block)
- @name=name
- @icon=icon
- @block=block
- @angle = 0
- @coord=Table.new(2)
- @disabled = false
- @sprite = Sprite.new(viewport)
- @sprite.bitmap = RPG::Cache.icon(name)
- #p @sprite.bitmap.width/2,@sprite.bitmap.height/2
- @sprite.ox = @sprite.bitmap.width/2
- @sprite.oy = @sprite.bitmap.height/2
- @selected = false
- @sprite.tone.gray = 255
- end
- def call
- return if @block.nil?
- @block.call
- end
- def z=(value)
- @sprite.z = value
- end
- def selected=(v)
- if v != @selected
- @sprite.tone.gray = (v==true ? 0 : 255)
- @selected = v==true
- end
- end
- def disabled=(v)
- @disabled= v==true
- end
- def coord=(c = [0,0])
- @coord=c
- @sprite.x = @coord[0]
- @sprite.y = @coord[1]
- end
- def x=(*args)
- @coord[0]= args.first
- @sprite.x= args.first
- end
- def y=(*args)
- @coord[1]= args.first
- @sprite.y= args.first
- end
- def zoom=value
- @sprite.zoom_x = value
- @sprite.zoom_y = value
- end
- def dispose
- @coord=nil
- @block=nil
- @sprite.dispose
- end
- end
Expand to see the code.
Instructions
Very easy to use, only a few things to keep in mind!
->Paste the script above main!
->Now to create a ring menu:
Step 1
- you need to create the options like this =>
- RMenu_Option.new("Name", [icon_id, viewport]) { optional_block }
Expand to see the code.
FOR VX ONLY : If icon_id is equal to 0 ( its default value), it will look for an image named with "Name" in a folder called "Icons" in the Graphics folder.
FOR XP only: Because XP doesn't have an icon set, the icon feature only works with the name, the xp script doesn't care about the Icon id, and will only look for a valid icon name
The block is optional as well :) if not needed, don't write anything after the parenthesis.
Step 2
You place those options inside a temporary array, this array will be used when creating the menu:
- opt = [
- RMenu_Option.new("SelData"){ $scene = Scene_Data.new },
- RMenu_Option.new("CopData"){ $scene = Scene_Copy_Data.new },
- RMenu_Option.new("DelData"){ $scene = Scene_Del_Data.new }
- ]
Expand to see the code.
Step 3
Create the menu!
- Ring_Menu.new( [h_radius, v_radius, [x,y], opt_array] )
Expand to see the code.
-> by default h_radius and v_radius = 10, x & y = 0 and opt_array is an empty array.
Yes that means you can add/remove options later on!
That's for the basic Creation!
-> The menu needs to be updated! Like any normal graphical object in a scene. :) menu.update
No need to use code stuff for arrow keys, it's already done in the update method.
-> AND to be disposed as well :) menu.dispose
To get the current selected option : menu.selected
Therefore: to execute the optional block given at the option creation, -> menu.selected.call
Like a window, the menu is only active or visible when you want it: menu.active/visible = true/false,
The zoom attribute: if true ( menu.zoom = true ), it'll activate the perspective effect, -> basically the options 'in front' of us are bigger than the options in the back.
By default the "max size" is 40% bigger than the original file (zoom_x/y = 1.4)
But you can change that max value if required. For example -> menu.zoom_max = 1.0
If you need to change the fluidity of the menu scrolling: you need to use -> menu.reso= value
by default this value is 4, it means it takes 4 frames to go from one option to another.
If you intend to change the "fluidity", it's important that you do it before anything else.
You can play with the opacity, as well like sprites.
FAQ
[i]"I've noticed some constants in the RingMenu class, what are they? Can I use them?"
3 Constants:
- RESO : the default "fluidity"(number of frames) used to move from one option ot another, you can change it, if you don't want to do it for several menu that use the same value
- PLAY_SE : if false, the menu won't make any noise when being scrolled.
- SELECTED_ANGLE : I suggest you don't touch it. The function -> Because a 0° angle is on the right on the trigonometric circle, I need to "rotate" that circle in order to have the 0 , in front of me, which is at the bottom. It is used when the menu is "horizontal", to have the selected option, in front of us, instead of the right of the ring. The angle is in Radian.
When I press Up/Down on a vertical ring menu, nothing happens, Why ?
-> Check that the horizontal radius is 0, if not, Use the left/right keys!
Compatibility
I've added Methods to the cache module, to the array Class, the sprite Class as well
As long as no other classes are called like mines, it should be fine. ( too lazy to put mine into a module. )
Author's Notes
I did this script for the 1st time in 12/2007 on XP :) and updated for my needs with time.
It's used in Castlevania as well. And I thought I should release it, cause it's a very convenient thing to use!
Terms and Conditions
Everywhere you want, just credit me :)
