Class: Sprite
- Inherits:
-
Object
- Object
- Sprite
- 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
Instance Attribute Summary collapse
-
#angle ⇒ Object
The sprite’s angle of rotation.
-
#bitmap ⇒ Object
Refers to the Bitmap used for the sprite’s starting point.
-
#blend_type ⇒ Object
The sprite’s blending mode (0: normal, 1: addition, 2: subtraction).
-
#bush_depth ⇒ Object
The Bush depth for that sprite.
-
#color ⇒ Object
The color (Color) to be blended with the sprite.
-
#mirror ⇒ Object
Flag denoting the sprite has been flipped horizontally.
-
#opacity ⇒ Object
The sprite’s opacity (0-255).
-
#ox ⇒ Object
The X-coordinate of the sprite’s starting point.
-
#oy ⇒ Object
The Y-coordinate of the sprite’s starting point.
-
#src_rect ⇒ Object
The box (Rect) taken from a bitmap.
-
#tone ⇒ Object
The sprite’s color Tone.
-
#viewport ⇒ Object
readonly
Gets the Viewport specified when the tilemap was created.
-
#visible ⇒ Object
The sprite’s visibility.
-
#x ⇒ Object
The sprite’s X-coordinate.
-
#y ⇒ Object
The sprite’s Y-coordinate.
-
#z ⇒ Object
The viewport’s Z-coordinate.
-
#zoom_x ⇒ Object
The sprite’s X-axis zoom level.
-
#zoom_y ⇒ Object
The sprite’s Y-axis zoom level.
Instance Method Summary collapse
-
#dispose ⇒ Object
Frees the sprite.
-
#disposed? ⇒ Boolean
Returns TRUE if the sprite has been freed.
-
#flash(color, duration) ⇒ Object
Begins flashing the sprite.
-
#initialize(viewport = nil) ⇒ Sprite
constructor
A new instance of Sprite.
-
#update ⇒ Object
Refreshes the sprite flash.
Constructor Details
#initialize(viewport = nil) ⇒ Sprite
Returns a new instance of Sprite.
73 74 75 76 77 |
# File 'lib/sprite.rb', line 73 def initialize( = nil) raise "not implemented" @viewport = end |
Instance Attribute Details
#angle ⇒ Object
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 |
#bitmap ⇒ Object
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_type ⇒ Object
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_depth ⇒ Object
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 |
#color ⇒ Object
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 |
#mirror ⇒ Object
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 |
#opacity ⇒ Object
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 |
#ox ⇒ Object
The X-coordinate of the sprite’s starting point.
27 28 29 |
# File 'lib/sprite.rb', line 27 def ox @ox end |
#oy ⇒ Object
The Y-coordinate of the sprite’s starting point.
30 31 32 |
# File 'lib/sprite.rb', line 30 def oy @oy end |
#src_rect ⇒ Object
The box (Rect) taken from a bitmap.
9 10 11 |
# File 'lib/sprite.rb', line 9 def src_rect @src_rect end |
#viewport ⇒ Object (readonly)
Gets the Viewport specified when the tilemap was created.
71 72 73 |
# File 'lib/sprite.rb', line 71 def @viewport end |
#visible ⇒ Object
The sprite’s visibility. If TRUE, the sprite is visible.
12 13 14 |
# File 'lib/sprite.rb', line 12 def visible @visible end |
#x ⇒ Object
The sprite’s X-coordinate.
15 16 17 |
# File 'lib/sprite.rb', line 15 def x @x end |
#y ⇒ Object
The sprite’s Y-coordinate.
18 19 20 |
# File 'lib/sprite.rb', line 18 def y @y end |
#z ⇒ Object
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_x ⇒ Object
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_y ⇒ Object
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
#dispose ⇒ Object
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 |
#update ⇒ Object
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 |