Class: UI::VoltorbFlip::BoardTile
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::VoltorbFlip::BoardTile
- Defined in:
- scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb
Overview
Board tile in VoltorbFlip game
Constant Summary
Constants inherited from SpriteStack
Instance Attribute Summary collapse
-
#content ⇒ Integer, :voltorb
Content of the tile.
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#hide
Hide the tile.
-
#hiden? ⇒ Boolean
Tell if the tile is hidden.
-
#initialize(viewport) ⇒ BoardTile
constructor
Create a new BoardTile.
-
#reveal
Reveal the tile.
-
#revealed? ⇒ Boolean
Tell if the tile was revealed.
-
#simple_mouse_in?(mx, my) ⇒ Boolean
Detect if the mouse is in the tile.
-
#toggle_memo(index)
Toggle a memo marker.
-
#update_animation ⇒ Boolean
Update the animation of the tile.
-
#update_hide_animation ⇒ Boolean
Update the hide animation.
-
#update_reveal_animation ⇒ Boolean
Update the reveal animation.
Methods inherited from SpriteStack
#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #size, #stop_animation, #translate_mouse_coords, #update, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=
Constructor Details
#initialize(viewport) ⇒ BoardTile
Create a new BoardTile
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 186 def initialize() super(, default_cache: :interface) @tile_back = push(14, 14, 'voltorbflip/tiles') @tile_back.ox = 14 @tile_back.oy = 14 @tile_back.set_rect_div(0, 0, 5, 1) @tile_front = push(14, 14, 'voltorbflip/tiles') @tile_front.ox = 14 @tile_front.oy = 14 @tile_front.set_rect_div(0, 0, 5, 1) @tile_front.visible = false @markers = Array.new(4) do |i| s = push(-3, -3, 'voltorbflip/markers') s.set_rect_div(2 + i, 0, 6, 1) s.visible = false next(s) end end |
Instance Attribute Details
#content ⇒ Integer, :voltorb
Returns Content of the tile.
182 183 184 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 182 def content @content end |
Instance Method Details
#hide
Hide the tile
245 246 247 248 249 250 251 252 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 245 def hide return unless @tile_front.visible @animation = :hide @animation_counter = 0 @tile_back.visible = false @tile_front.visible = true @markers.each { |m| m.visible = false } end |
#hiden? ⇒ Boolean
Tell if the tile is hidden
255 256 257 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 255 def hiden? return @tile_back.visible end |
#reveal
Reveal the tile
229 230 231 232 233 234 235 236 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 229 def reveal return unless @tile_back.visible @animation = :reveal @animation_counter = 0 @tile_back.visible = true @tile_front.visible = false @markers.each { |m| m.visible = false } end |
#revealed? ⇒ Boolean
Tell if the tile was revealed
240 241 242 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 240 def revealed? return @tile_front.visible end |
#simple_mouse_in?(mx, my) ⇒ Boolean
Detect if the mouse is in the tile
211 212 213 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 211 def simple_mouse_in?(mx, my) return @tile_back.simple_mouse_in?(mx + @tile_back.ox, my + @tile_back.oy) end |
#toggle_memo(index)
Toggle a memo marker
224 225 226 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 224 def toggle_memo(index) @markers[index].visible = !@markers[index].visible end |
#update_animation ⇒ Boolean
Update the animation of the tile
261 262 263 264 265 266 267 268 269 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 261 def update_animation case @animation when :reveal return update_reveal_animation when :hide return update_hide_animation end return false end |
#update_hide_animation ⇒ Boolean
Update the hide animation
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 296 def update_hide_animation case @animation_counter when 0, 1, 2, 3, 4, 5, 6, 7 @tile_front.zoom_x -= 1 / 8.0 # 0.25 when 8 @tile_front.visible = false @tile_front.zoom_x = 1 @tile_back.visible = true @tile_back.zoom_x = 0 when 9, 10, 11, 12, 13, 14, 15 @tile_back.zoom_x += 1 / 8.0 when 16 @tile_back.zoom_x = 1 @animation_counter = 0 @animation = nil return self end @animation_counter += 1 return !@animation.nil? end |
#update_reveal_animation ⇒ Boolean
Update the reveal animation
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'scripts/01450 Systems/09000 Games/00002 VoltorbFlip/02200 VoltorbFlipSprites.rb', line 273 def update_reveal_animation case @animation_counter when 0, 1, 2, 3, 4, 5, 6, 7 @tile_back.zoom_x -= 1 / 8.0 # 0.25 when 8 @tile_back.visible = false @tile_back.zoom_x = 1 @tile_front.visible = true @tile_front.zoom_x = 0 when 9, 10, 11, 12, 13, 14, 15 @tile_front.zoom_x += 1 / 8.0 when 16 @tile_front.zoom_x = 1 @animation_counter = 0 @animation = nil return self end @animation_counter += 1 return !@animation.nil? end |