Sha256: 625bec3e47ad383a649a5b7501ce53fb9083302b4203f13688f3d08540e8b8d9
Contents?: true
Size: 1022 Bytes
Versions: 1
Compression:
Stored size: 1022 Bytes
Contents
# frozen_string_literal: true module ParticleFX2D module Ruby2D # # A particle shape that is based on the Ruby2D _Circle_ shape. class ParticleCircle < ::Ruby2D::Circle include ShapeRenderer # Called by the emitter for each particle that it manages. Creates an instance # of _ParticleCircle_ intialized with the particle's position, size and colour. # # @param [ParticleFX2D::Particle] particle # 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 # Sets the circle's position using the incoming centre coordinates. def center!(centre_x, centre_y) self.x = centre_x self.y = centre_y end # Sets the radius using the particle size and calls #super def draw_particle(particle) self.radius = particle.size / 2 super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
particlefx2d-0.5.0 | lib/particlefx2d/ruby2d/particle_circle.rb |