Class: CP::Shape::Segment

Inherits:
Object
  • Object
show all
Includes:
CP::Shape
Defined in:
lib/chipmunk-ffi/shape.rb,
lib/chipmunk-ffi/unsafe.rb

Instance Attribute Summary

Attributes included from CP::Shape

#struct

Instance Method Summary collapse

Methods included from CP::Shape

#bb, #body, #body=, #cache_bb, #collision_type, #collision_type=, #data, #data=, #e, #e=, #group, #group=, #layers, #layers=, #point_query, reset_id_counter, #segment_query, #sensor=, #sensor?, #set_data_pointer, #surface_v, #surface_v=, #u, #u=

Constructor Details

#initialize(body, v1, v2, r) ⇒ Segment

Returns a new instance of Segment.



193
194
195
196
197
198
# File 'lib/chipmunk-ffi/shape.rb', line 193

def initialize(body, v1, v2, r)
  @body = body
  ptr = CP.cpSegmentShapeNew body.struct.pointer, v1.struct, v2.struct, r
  @struct = ShapeStruct.new ptr
  set_data_pointer
end

Instance Method Details

#endpoints=(new_endpoints) ⇒ Object



22
23
24
25
# File 'lib/chipmunk-ffi/unsafe.rb', line 22

def endpoints=(new_endpoints)
  new_a, new_b = *new_endpoints.map { |v| v.struct }
  CP.cpSegmentShapeSetEndpoints(@struct, new_a, new_b)
end

#radius=(new_radius) ⇒ Object



26
27
28
# File 'lib/chipmunk-ffi/unsafe.rb', line 26

def radius=(new_radius)
  CP.cpSegmentShapeSetRadius(@struct, new_radius)
end