Hello there!
I'm currently making a simple Zelda menu with pictures using script.
Everything's OK, except this: cursor-picture movement.
What I want is moving a picture as a cursor whose possible positions form sequences (
X_pos1 -> X_pos2 -> X_posn and
Y_pos1 -> Y_pos2 -> Y_posn ) that don't obey any mathematical law.
On testing RGSS reads my script very strangely: at some
intermediate positions the cursor moves to the left instead of right, at others it merely skips 2 positions.
Here is a test-script of this called by an event; could aynone tell me where my error is?
Thank you
class Cursor_Menu
#------------------------------------------
# 4 position for the cursor X=20 ; X=50 ; X=100 ; X= 200
#-------------------------------------------
def initialize
@image = Sprite.new
@image.bitmap = RPG::Cache.picture("your cursor picture name")
@image.x = 20 # initial X co-ordinate
@image.y = 200
@image.zoom_x = 0.2
@image.zoom_y = 0.2
loop do
Graphics.update
Input.update
cmd_update
@image.update
end
end
#------------------------------------------------
def cmd_update
if Input.trigger?(Input::LEFT)
if @image.x == 20
@image.x = 200 #20 being min. position, place the cursor to the max. one
end
if @image.x == 50
@image.x = 20
end
if @image.x == 100
@image.x = 50
end
if @image.x == 200
@image.x = 100
end
end
if Input.trigger?(Input::RIGHT)
if @image.x == 20
@image.x = 50
end
if @image.x == 50
@image.x = 100
end
if @image.x == 100
@image.x = 200
end
if @image.x == 200
# @image.x = 20 #200 being the max. position, place the cursor to the min. one
end
end
end
end