Class: SceneKBookPages
- Inherits:
-
Object
- Object
- SceneKBookPages
- Includes:
- Input
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/books/book.rb
Instance Method Summary collapse
-
#draw ⇒ Object
# === draw ========================================================================= #.
-
#initialize(id) ⇒ SceneKBookPages
constructor
initialize.
-
#play_bgm(name, volume = 80, non_stop = true) ⇒ Object
play_bgm.
-
#play_list(volume, *args) ⇒ Object
play_list.
-
#play_next_bgm ⇒ Object
play_next_bgm.
-
#stop_bgm ⇒ Object
stop_bgm.
-
#update ⇒ Object
update.
Constructor Details
#initialize(id) ⇒ SceneKBookPages
initialize
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 99 def initialize(id) @id = id @bgm_index = @index = @ticks = 0 @width = 8 @book = [] @pages = [] @bgm = nil @bgms = [] @default_font = 'High Tower Text'#'Liberation'#'DS-Digital' @default_color = Gosu::Color.new(255, 255, 255, 255) rescue nil @outline_color = Gosu::Color.new(255, 0, 0, 0) rescue nil @ok_se = Gosu::Sample.new('audio/Ok.ogg') @cancel_se = Gosu::Sample.new('audio/Cancel.ogg') @cursor_se = Gosu::Sample.new('audio/PageFlip.ogg') # The next sound was played when a wrong move was done. # @wrong_se = Gosu::Sample.new('audio/Wrong.ogg') book = Library.books[@id] pages = book.pages @max = pages.size @max.times {|n| @book << Sprite_Page.new(400, 50, n, pages[n]) } end |
Instance Method Details
#draw ⇒ Object
#
draw
#
199 200 201 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 199 def draw @book.each {|page| page.draw } end |
#play_bgm(name, volume = 80, non_stop = true) ⇒ Object
play_bgm
130 131 132 133 134 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 130 def play_bgm(name, volume = 80, non_stop = true) @bgm = Gosu::Song.new('audio/' + name) @bgm.volume = volume / 100.0 @bgm.play(non_stop) end |
#play_list(volume, *args) ⇒ Object
play_list
136 137 138 139 140 141 142 143 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 136 def play_list(volume, *args) @bgm_index = 0 @volume = volume / 100.0 names = args.flatten names.each {|name| @bgms << Gosu::Song.new('audio/' + name) @bgms[-1].volume = @volume } @bgms[@bgm_index].play(false) end |
#play_next_bgm ⇒ Object
play_next_bgm
146 147 148 149 150 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 146 def play_next_bgm return if @bgms.empty? or @bgms[@bgm_index]. @bgm_index = (@bgm_index + 1) % @bgms.size @bgms[@bgm_index].play(false) end |
#stop_bgm ⇒ Object
stop_bgm
122 123 124 125 126 127 128 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 122 def stop_bgm @bgm.stop if @bgm return if @bgms.empty? @bgms[@bgm_index].stop @bgms.clear @volume = @bgm_index = nil end |
#update ⇒ Object
update
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/games_and_rpg_paradise/gui/gosu/books/book.rb', line 153 def update play_next_bgm if @@down_ticks > 0 @@down_ticks -= 1 @@down_id = nil if @@down_ticks == 0 end unless @pages.empty? @pages[0].update @pages.shift unless @pages[0].flip? end return @ticks -= 1 if @ticks > 0 if Gosu.(Gosu::KbLeftAlt) and (:return) @fullscreen = Window.toggle_fullscreen @ticks = 6 return end if press_quit? @cancel_se.play Window.close elsif press_left? if @index == 0 return # @wrong_se.play else @cursor_se.play @index -= 1 unless @index == @max - 1 @pages = [@book[@index], @book[@index-1]] @index = [@index-1,0].max @pages.each {|page| page.flip(:left) } @ticks = 20 end elsif press_right? if @index == @max - 1 return # @wrong_se.play else @cursor_se.play @pages = @book[@index..@index+1] @pages.each {|page| page.flip(:right) } @index = [@index+2,@max-1].min @ticks = 20 end end end |