Class: Sprite

Inherits:
Object
  • Object
show all
Defined in:
lib/sprite.rb

Overview

The sprite class. Sprites are the basic concept used to display characters, etc. on the game screen.

Direct Known Subclasses

RPG::Sprite

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(viewport = nil) ⇒ Sprite


73
74
75
76
77
# File 'lib/sprite.rb', line 73

def initialize(viewport = nil)
  raise "not implemented"

  @viewport = viewport
end

Instance Attribute Details

#angleObject

The sprite's angle of rotation. Specifies up to 360 degrees of counterclockwise rotation. However, drawing a rotated sprite is time-consuming, so avoid overuse.


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

def angle
  @angle
end

#bitmapObject

Refers to the Bitmap used for the sprite's starting point.


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

def bitmap
  @bitmap
end

#blend_typeObject

The sprite's blending mode (0: normal, 1: addition, 2: subtraction).


57
58
59
# File 'lib/sprite.rb', line 57

def blend_type
  @blend_type
end

#bush_depthObject

The Bush depth for that sprite. This is a pixel value denoting how much of the sprite's lower portion will be displayed as semitransparent. A simple way to convey a sense of a character's feet being obscured by foliage and the like.


51
52
53
# File 'lib/sprite.rb', line 51

def bush_depth
  @bush_depth
end

#colorObject

The color (Color) to be blended with the sprite. Alpha values are used in the blending ratio.

Handled separately from the color blended into a flash effect. However, the color with the higher alpha value when displayed will have the higher priority when blended.


65
66
67
# File 'lib/sprite.rb', line 65

def color
  @color
end

#mirrorObject

Flag denoting the sprite has been flipped horizontally. If TRUE, the sprite will be drawn flipped.


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

def mirror
  @mirror
end

#opacityObject

The sprite's opacity (0-255). Values out of range are automatically corrected.


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

def opacity
  @opacity
end

#oxObject

The X-coordinate of the sprite's starting point.


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

def ox
  @ox
end

#oyObject

The Y-coordinate of the sprite's starting point.


30
31
32
# File 'lib/sprite.rb', line 30

def oy
  @oy
end

#src_rectObject

The box (Rect) taken from a bitmap.


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

def src_rect
  @src_rect
end

#toneObject

The sprite's color Tone.


68
69
70
# File 'lib/sprite.rb', line 68

def tone
  @tone
end

#viewportObject (readonly)

Gets the Viewport specified when the tilemap was created.


71
72
73
# File 'lib/sprite.rb', line 71

def viewport
  @viewport
end

#visibleObject

The sprite's visibility. If TRUE, the sprite is visible.


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

def visible
  @visible
end

#xObject

The sprite's X-coordinate.


15
16
17
# File 'lib/sprite.rb', line 15

def x
  @x
end

#yObject

The sprite's Y-coordinate.


18
19
20
# File 'lib/sprite.rb', line 18

def y
  @y
end

#zObject

The viewport's Z-coordinate. The larger this value, the closer to the player the viewport will be displayed. If multiple objects share the same Z-coordinate, the more recently created object will be displayed closest to the player.


24
25
26
# File 'lib/sprite.rb', line 24

def z
  @z
end

#zoom_xObject

The sprite's X-axis zoom level. 1.0 denotes actual pixel size.


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

def zoom_x
  @zoom_x
end

#zoom_yObject

The sprite's Y-axis zoom level. 1.0 denotes actual pixel size.


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

def zoom_y
  @zoom_y
end

Instance Method Details

#disposeObject

Frees the sprite. If the sprite has already been freed, does nothing.


80
81
82
83
84
# File 'lib/sprite.rb', line 80

def dispose
  raise "not implemented"

  @disposed = true
end

#disposed?Boolean

Returns TRUE if the sprite has been freed.


87
88
89
# File 'lib/sprite.rb', line 87

def disposed?
  @disposed
end

#flash(color, duration) ⇒ Object

Begins flashing the sprite. duration specifies the number of frames the flash will last.

If color is set to nil, the sprite will disappear while flashing.


95
96
97
# File 'lib/sprite.rb', line 95

def flash(color, duration) 
  raise "not implemented"
end

#updateObject

Refreshes the sprite flash. As a rule, this method is called once per frame.

It is not necessary to call this method if no flash effect is needed.


102
103
104
# File 'lib/sprite.rb', line 102

def update
  raise "not implemented"
end