Class: Sprite

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

Constant Summary

Constants included from RGSS3::Container

RGSS3::Container::BLEND

Instance Attribute Summary collapse

Attributes included from RGSS3::Container

#bitmap, #blend_type, #color, #opacity, #ox, #oy, #tone, #viewport, #visible, #z, #zoom_x, #zoom_y

Instance Method Summary collapse

Methods included from RGSS3::Container

#dispose, #disposed?, #do_draw, #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
  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



44
45
46
47
# File 'lib/rgss3/sprite.rb', line 44

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

#drawObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rgss3/sprite.rb', line 49

def draw
  if viewport
    x = @x + viewport.rect.x
    y = @y + viewport.rect.y
    w = [width - viewport.ox, viewport.rect.x + viewport.rect.width - x].min
    h = [height - viewport.oy, viewport.rect.y + viewport.rect.height - y].min
    return if w <= 0 || h <= 0
    z = @z + (viewport.z << 12)
    src_x = @src_rect.x + viewport.ox
    src_y = @src_rect.y + viewport.oy
  else
    x = @x
    y = @y
    z = @z
    src_x, src_y, w, h = *@src_rect
  end
  image = bitmap.gosu_image.subimage(src_x, src_y, w, h)
  return unless image
  image.draw_rot(
    x,
    y,
    z,
    @angle,
    ox.fdiv(width),
    oy.fdiv(height),
    @zoom_x * (@mirror ? -1 : 1),
    @zoom_y,
    0xff_ffffff,
    BLEND[@blend_type])
end

#flash(color, duration) ⇒ Object



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

def flash(color, duration)
end

#heightObject



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

def height
  @src_rect.height
end

#updateObject



29
30
# File 'lib/rgss3/sprite.rb', line 29

def update
end

#widthObject



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

def width
  @src_rect.width
end