Class: RubySketch::WheelConstraint

Inherits:
Constraint show all
Defined in:
lib/rubysketch/constraint.rb

Overview

Rides on the target like a wheel: slides along an axis for the suspension while spinning freely.

Instance Method Summary collapse

Methods inherited from Constraint

#active?, #collide=, #collide?, #damping, #damping=, #force, #force=, #remove, #removed?, #spring, #spring=, #sprites

Instance Method Details

#axisVector

Returns the axis to slide along.

Returns:



345
346
347
# File 'lib/rubysketch/constraint.rb', line 345

def axis()
  @constraint__.axis&.toVector
end

#axis=(axis) ⇒ Vector, Array<Numeric>

Sets the axis to slide along for the suspension.

Parameters:

  • axis (Vector, Array<Numeric>)

    direction in the target local space

Returns:

  • (Vector, Array<Numeric>)

    axis



337
338
339
# File 'lib/rubysketch/constraint.rb', line 337

def axis=(axis)
  @constraint__.axis = RubySketch.unwrap__ axis
end

#motorNumeric?

Returns the motor speed.

Returns:

  • (Numeric, nil)

    angular velocity per second



383
384
385
386
# File 'lib/rubysketch/constraint.rb', line 383

def motor()
  speed = @constraint__.motor
  speed && fromDegrees__(speed)
end

#motor=(speed) ⇒ Numeric?

Sets the motor speed that spins the wheel.

Parameters:

  • speed (Numeric, nil)

    angular velocity per second, radians or degrees depending on angleMode(). nil stops the motor

Returns:

  • (Numeric, nil)

    speed



375
376
377
# File 'lib/rubysketch/constraint.rb', line 375

def motor=(speed)
  @constraint__.motor = speed && toDegrees__(speed)
end

#rangeRange?

Returns the range of the translation along the axis.

Returns:

  • (Range, nil)

    translation range



363
364
365
# File 'lib/rubysketch/constraint.rb', line 363

def range()
  @constraint__.range
end

#range=(range) ⇒ Range, ...

Sets the range of the translation along the axis.

Parameters:

  • range (Range, Numeric, nil)

    translation range in pixels

Returns:

  • (Range, Numeric, nil)

    range



355
356
357
# File 'lib/rubysketch/constraint.rb', line 355

def range=(range)
  @constraint__.range = range
end