Class: MovieMaker::Rubygame::Sprite

Inherits:
Object
  • Object
show all
Includes:
Rubygame::Sprites::Sprite
Defined in:
lib/movie_maker/sprite.rb

Overview

A basic spriteclass using rubygames Sprites::Sprite Autoloads a surface and initializes @rect

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, x = 0, y = 0) ⇒ Sprite

Returns a new instance of Sprite.



13
14
15
16
17
18
19
20
21
22
# File 'lib/movie_maker/sprite.rb', line 13

def initialize(file, x=0, y=0)
	super()
	@file = file
	@image = Surface.autoload(file)
	@rect = Rect.new(x,y,*@image.size)
	@image.set_colorkey(@image.get_at(0,0))
	@angle = 0.0
	@width_scaling = 1.0
	@height_scaling = 1.0
end

Instance Attribute Details

#angleObject

Returns the value of attribute angle.



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

def angle
  @angle
end

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#height_scalingObject

Returns the value of attribute height_scaling.



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

def height_scaling
  @height_scaling
end

#imageObject (readonly)

Returns the value of attribute image.



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

def image
  @image
end

#rectObject

Returns the value of attribute rect.



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

def rect
  @rect
end

#width_scalingObject

Returns the value of attribute width_scaling.



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

def width_scaling
  @width_scaling
end

Instance Method Details

#realign_centerObject



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

def realign_center
	old_center = @rect.center
	@rect.size = @image.size
	@rect.center = old_center
end

#xObject



28
# File 'lib/movie_maker/sprite.rb', line 28

def x;					@rect.centerx;					end

#x=(value) ⇒ Object

Rubygame X/Y setters/getters



27
# File 'lib/movie_maker/sprite.rb', line 27

def x=(value); 	@rect.centerx = value;	end

#yObject



30
# File 'lib/movie_maker/sprite.rb', line 30

def y;					@rect.centery;					end

#y=(value) ⇒ Object



29
# File 'lib/movie_maker/sprite.rb', line 29

def y=(value); 	@rect.centery = value;	end