Class: Rubygame::Sprites::BasicSprite
- Inherits:
-
Object
- Object
- Rubygame::Sprites::BasicSprite
- Includes:
- Sprite
- Defined in:
- lib/xgame.rb
Overview
This is a basic class for updatable, image-based, sprites with a rectangular box matching their image
Class Method Summary collapse
-
.default_image ⇒ Object
Override this in subclasses to have a default image.
Instance Method Summary collapse
-
#initialize(x, y, image = nil) ⇒ BasicSprite
constructor
Create a new BasicSprite.
- #update(time) ⇒ Object
Constructor Details
#initialize(x, y, image = nil) ⇒ BasicSprite
Create a new BasicSprite. Pass x, y coordinates for location to spawn. Pass path to image if you have not ovrriden default_image
272 273 274 275 276 277 278 279 280 281 |
# File 'lib/xgame.rb', line 272 def initialize(x,y,image=nil) super() if image @image = Rubygame::Surface[image] throw "Image #{image} failed to load. Looking in: #{Rubygame::Surface.autoload_dirs.join(":")}" unless @image else @image = default_image end @rect = Rubygame::Rect.new(x,y,*@image.size) end |
Class Method Details
.default_image ⇒ Object
Override this in subclasses to have a default image
268 |
# File 'lib/xgame.rb', line 268 def self.default_image; end |
Instance Method Details
#update(time) ⇒ Object
283 |
# File 'lib/xgame.rb', line 283 def update(time); end |