Class: ParticleFX2D::Ruby2D::ParticleCircle
- Inherits:
-
Ruby2D::Circle
- Object
- Ruby2D::Circle
- ParticleFX2D::Ruby2D::ParticleCircle
- Includes:
- ShapeRenderer
- Defined in:
- lib/particlefx2d/ruby2d/particle_circle.rb
Overview
A particle shape that is based on the Ruby2D Circle shape.
Class Method Summary collapse
-
.for(particle) ⇒ Object
Called by the emitter for each particle that it manages.
Instance Method Summary collapse
-
#center!(centre_x, centre_y) ⇒ Object
Sets the circle’s position using the incoming centre coordinates.
-
#draw_particle(particle) ⇒ Object
Sets the radius using the particle size and calls #super.
Methods included from ShapeRenderer
#hide_particle, #show_particle
Methods included from ParticleFX2D::Renderer
#hide_particle, #show_particle
Class Method Details
.for(particle) ⇒ Object
Called by the emitter for each particle that it manages. Creates an instance of ParticleCircle intialized with the particle’s position, size and colour.
15 16 17 18 19 20 21 |
# File 'lib/particlefx2d/ruby2d/particle_circle.rb', line 15 def self.for(particle) s = ParticleCircle.new x: particle.x, y: particle.y, radius: particle.size / 2 s.color! particle.color s.remove s end |
Instance Method Details
#center!(centre_x, centre_y) ⇒ Object
Sets the circle’s position using the incoming centre coordinates.
24 25 26 27 |
# File 'lib/particlefx2d/ruby2d/particle_circle.rb', line 24 def center!(centre_x, centre_y) self.x = centre_x self.y = centre_y end |
#draw_particle(particle) ⇒ Object
Sets the radius using the particle size and calls #super
30 31 32 33 |
# File 'lib/particlefx2d/ruby2d/particle_circle.rb', line 30 def draw_particle(particle) self.radius = particle.size / 2 super end |