Class: Xibe::Sprite
Instance Attribute Summary collapse
-
#animate ⇒ Object
writeonly
Sets the attribute animate.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#frames ⇒ Object
Returns the value of attribute frames.
Attributes inherited from Layer
#height, #visible, #width, #x, #y, #z
Instance Method Summary collapse
-
#draw ⇒ Object
Draw sprite.
-
#first_frame ⇒ Object
Go to first frame.
-
#go_frame(frame) ⇒ Object
Go to parameter frame.
-
#initialize(filename, width, height, transparent = false) ⇒ Sprite
constructor
A new instance of Sprite.
-
#last_frame ⇒ Object
Go to last frame.
-
#next_frame ⇒ Object
Go to next frame.
-
#prev_frame ⇒ Object
Go to previous frame.
Methods inherited from Layer
#bottom, #hide, #left, #pos, #right, #show, #top
Constructor Details
#initialize(filename, width, height, transparent = false) ⇒ Sprite
Returns a new instance of Sprite.
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
# File 'lib/xibe.rb', line 572 def initialize(filename,width,height,transparent=false) super() @tiles = Image.to_tiles(filename, width, height, transparent) @width = width @height = height @frames = [] @frame = 0 @delay = 200 @last_update = 0 @direction = :right @visible = true @animate = true @tile @cmap end |
Instance Attribute Details
#animate=(value) ⇒ Object
Sets the attribute animate
571 572 573 |
# File 'lib/xibe.rb', line 571 def animate=(value) @animate = value end |
#delay ⇒ Object
Returns the value of attribute delay.
570 571 572 |
# File 'lib/xibe.rb', line 570 def delay @delay end |
#direction ⇒ Object
Returns the value of attribute direction.
570 571 572 |
# File 'lib/xibe.rb', line 570 def direction @direction end |
#frames ⇒ Object
Returns the value of attribute frames.
570 571 572 |
# File 'lib/xibe.rb', line 570 def frames @frames end |
Instance Method Details
#draw ⇒ Object
Draw sprite
616 617 618 619 620 |
# File 'lib/xibe.rb', line 616 def draw animate if @animate == true first_frame if @frames[@frame].nil? draw_tile(@tiles[@frames[@frame]], @x, @y) if @visible == true end |
#first_frame ⇒ Object
Go to first frame
589 590 591 |
# File 'lib/xibe.rb', line 589 def first_frame @frame = 0 end |
#go_frame(frame) ⇒ Object
Go to parameter frame
611 612 613 |
# File 'lib/xibe.rb', line 611 def go_frame(frame) @frame = frame end |
#last_frame ⇒ Object
Go to last frame
594 595 596 |
# File 'lib/xibe.rb', line 594 def last_frame @frame = @frames.length - 1 end |
#next_frame ⇒ Object
Go to next frame
599 600 601 602 |
# File 'lib/xibe.rb', line 599 def next_frame @frame += 1 first_frame if @frame > @frames.length - 1 end |
#prev_frame ⇒ Object
Go to previous frame
605 606 607 608 |
# File 'lib/xibe.rb', line 605 def prev_frame @frame -= 1 last_frame if @frame < 0 end |