Advertisement
Guest User

RPG Maker VX ACE Sample Scene

a guest
Oct 2nd, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.54 KB | None | 0 0
  1. class Scene_Custom < Scene_Base
  2.   def start
  3.     super
  4.     create_background
  5.     create_icons
  6.     @current_index = 0
  7.     @message_window = Window_Message.new
  8.   end
  9.  
  10.   def create_background
  11.     @back = Sprite.new
  12.     @back.bitmap = Cache.picture('back')
  13.   end
  14.  
  15.   def create_icons
  16.     @icons = Array.new(4){Sprite.new}
  17.     @icons.each_with_index{|item, index|
  18.       case index
  19.         when 0
  20.           pic = 'char3'
  21.           x, y = 69, 100
  22.         when 1
  23.           pic = 'char1'
  24.           x, y = 214, 104
  25.         when 2
  26.           pic = 'char2'
  27.           x, y = 393, 89
  28.         when 3
  29.           pic = 'icon'
  30.           x, y = 468, 342
  31.       end
  32.       item.bitmap = Cache.picture(pic)
  33.       item.x, item.y, item.z = x, y, 1
  34.     }
  35.   end
  36.  
  37.   def update
  38.     super
  39.     update_input
  40.     update_icon
  41.   end
  42.  
  43.   def update_input
  44.     return if $game_message.busy?
  45.     if Input.repeat?(:RIGHT)
  46.       Sound.play_cursor
  47.       @current_index = (@current_index+1)%4
  48.     end
  49.     if Input.repeat?(:LEFT)
  50.       Sound.play_cursor
  51.       @current_index = (@current_index-1)%4
  52.     end
  53.     if Input.trigger?(:C)
  54.       if @current_index <= 2
  55.         text = ['...','你好','嘿嘿']
  56.         $game_message.add(text[@current_index])
  57.       else
  58.        
  59.       end
  60.     end
  61.   end
  62.  
  63.   def update_icon
  64.     @icons.each_with_index{|item, index|
  65.       index == @current_index ? item.tone.set(255,0,0) : item.tone.set(0,0,0)
  66.     }
  67.   end
  68.  
  69.   def terminate
  70.     super
  71.     @back.dispose
  72.     @icons.each{|item| item.dispose}
  73.   end
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement