Class: SpriteKit::Sprite
- Inherits:
-
Object
- Object
- SpriteKit::Sprite
- Defined in:
- mygame/lib/sprite_kit/sprite.rb
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Sprite
constructor
A new instance of Sprite.
- #serialize ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ Sprite
Returns a new instance of Sprite.
6 7 8 9 10 |
# File 'mygame/lib/sprite_kit/sprite.rb', line 6 def initialize(**kwargs) kwargs.each do |kwarg, value| instance_variable_set("@#{kwarg}", value) end end |
Instance Method Details
#serialize ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'mygame/lib/sprite_kit/sprite.rb', line 12 def serialize hash = {} instance_variables.each do |var| # Remove the '@' prefix from the instance variable name for the hash key key = var.to_s.delete('@').to_sym value = instance_variable_get(var) hash[key] = value end hash end |