Class: Sprite

Inherits:
Object
  • Object
show all
Includes:
RGSS3::SpriteContainer
Defined in:
lib/rgss3/sprite.rb

Constant Summary

Constants included from RGSS3::SpriteContainer

RGSS3::SpriteContainer::BLEND

Instance Attribute Summary collapse

Attributes included from RGSS3::SpriteContainer

#bitmap, #blend_type, #color, #zoom_x, #zoom_y

Attributes included from RGSS3::Container

#opacity, #ox, #oy, #tone, #viewport, #visible, #z

Instance Method Summary collapse

Methods included from RGSS3::Container

#dispose, #disposed?, #initialize_copy

Constructor Details

#initialize(viewport = nil) ⇒ Sprite

Returns a new instance of Sprite.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rgss3/sprite.rb', line 14

def initialize(viewport = nil)
  @x = 0
  @y = 0
  @angle = 0
  @mirror = false
  @bush_depth = 0
  @bush_opacity = 128
  @wave_speed = 360
  @src_rect = Rect.new(0, 0, 0, 0)
  super()
end

Instance Attribute Details

#angleObject

Returns the value of attribute angle.



11
12
13
# File 'lib/rgss3/sprite.rb', line 11

def angle
  @angle
end

#bush_depthObject

Returns the value of attribute bush_depth.



12
13
14
# File 'lib/rgss3/sprite.rb', line 12

def bush_depth
  @bush_depth
end

#bush_opacityObject

Returns the value of attribute bush_opacity.



7
8
9
# File 'lib/rgss3/sprite.rb', line 7

def bush_opacity
  @bush_opacity
end

#mirrorObject

Returns the value of attribute mirror.



11
12
13
# File 'lib/rgss3/sprite.rb', line 11

def mirror
  @mirror
end

#src_rectObject

Returns the value of attribute src_rect.



9
10
11
# File 'lib/rgss3/sprite.rb', line 9

def src_rect
  @src_rect
end

#wave_ampObject

Returns the value of attribute wave_amp.



10
11
12
# File 'lib/rgss3/sprite.rb', line 10

def wave_amp
  @wave_amp
end

#wave_lengthObject

Returns the value of attribute wave_length.



10
11
12
# File 'lib/rgss3/sprite.rb', line 10

def wave_length
  @wave_length
end

#wave_phaseObject

Returns the value of attribute wave_phase.



10
11
12
# File 'lib/rgss3/sprite.rb', line 10

def wave_phase
  @wave_phase
end

#wave_speedObject

Returns the value of attribute wave_speed.



10
11
12
# File 'lib/rgss3/sprite.rb', line 10

def wave_speed
  @wave_speed
end

#xObject

Returns the value of attribute x.



8
9
10
# File 'lib/rgss3/sprite.rb', line 8

def x
  @x
end

#yObject

Returns the value of attribute y.



8
9
10
# File 'lib/rgss3/sprite.rb', line 8

def y
  @y
end

Instance Method Details

#bitmap=(bitmap) ⇒ Object



48
49
50
51
# File 'lib/rgss3/sprite.rb', line 48

def bitmap=(bitmap)
  super(bitmap)
  @src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
end

#drawObject



53
54
55
56
# File 'lib/rgss3/sprite.rb', line 53

def draw
  return if !@visible || @opacity == 0 || @bitmap == nil
  @bitmap.gosu_image.draw_rot(@x, @y, @z, @angle, ox.fdiv(width), oy.fdiv(height), @zoom_x * (@mirror ? -1 : 1), @zoom_y, 0xffffffff, BLEND[@blend_type])
end

#flash(color, duration) ⇒ Object



26
27
28
29
# File 'lib/rgss3/sprite.rb', line 26

def flash(color, duration)
  @flash_color = color || Color.new(0, 0, 0, 0)
  @duration = duration
end

#heightObject



40
41
42
# File 'lib/rgss3/sprite.rb', line 40

def height
  @src_rect.height
end

#updateObject



31
32
33
34
# File 'lib/rgss3/sprite.rb', line 31

def update
  @duration = [@duration - 1, 0].max
  @flash_color = nil if @duration == 0
end

#widthObject



36
37
38
# File 'lib/rgss3/sprite.rb', line 36

def width
  @src_rect.width
end