Class: Core::GUI::CharSelector
- Defined in:
- lib/gui/char_selector.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Attributes inherited from Element
#h, #w, #x, #xoff, #y, #yoff, #zoff
Instance Method Summary collapse
- #changed? ⇒ Boolean
- #draw ⇒ Object
-
#initialize(x, y, party, w = 256, h = 32) ⇒ CharSelector
constructor
A new instance of CharSelector.
- #left ⇒ Object
- #right ⇒ Object
- #update ⇒ Object
Methods inherited from Element
Constructor Details
#initialize(x, y, party, w = 256, h = 32) ⇒ CharSelector
Returns a new instance of CharSelector.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gui/char_selector.rb', line 8 def initialize(x, y, party, w=256, h=32) super(x, y, w, h) @index = 0 @changed = false @party = party @background = Core.sprite("gui/charselect_background") @font = Core.font(Core::DEFAULT_FONT, 24) @left = Button.new(x, y, 32, 32, "<", lambda {left}, false) @right = Button.new(x+w-32, y, 32, 32, ">", lambda {right}, false) end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
7 8 9 |
# File 'lib/gui/char_selector.rb', line 7 def index @index end |
Instance Method Details
#changed? ⇒ Boolean
38 39 40 41 42 43 44 45 |
# File 'lib/gui/char_selector.rb', line 38 def changed? if @changed @changed = false return true else return false end end |
#draw ⇒ Object
46 47 48 49 50 51 |
# File 'lib/gui/char_selector.rb', line 46 def draw @background.draw(@x+@xoff, @y+@yoff, Core::GUI_Z + 9, @w/@background.width, @h/@background.height) @font.draw(@party.members[@index].name, @x+@xoff+(@w/2)-(@font.text_width(@party.members[@index].name)/2), @y+@yoff+(@h/6), Core::GUI_Z + 10, 1, 1, Gosu::Color::BLACK) @left.draw @right.draw end |
#left ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/gui/char_selector.rb', line 24 def left @index -= 1 if @index < 0 @index = @party.members.size-1 end @changed = true end |
#right ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/gui/char_selector.rb', line 31 def right @index += 1 if @index >= @party.members.size @index = 0 end @changed = true end |
#update ⇒ Object
18 19 20 21 22 23 |
# File 'lib/gui/char_selector.rb', line 18 def update @left.xoff = @right.xoff = @xoff @left.yoff = @right.yoff = @yoff @left.update @right.update end |