Class: CP::Vect

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/chipmunk-ffi/vec2.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Vect

Returns a new instance of Vect.



10
11
12
13
14
15
16
17
# File 'lib/chipmunk-ffi/vec2.rb', line 10

def initialize( ptr )
  case ptr
  when FFI::MemoryPointer, FFI::Buffer, FFI::AutoPointer
    super ptr
  else
    super FFI::AutoPointer.new(ptr, self.class.method(:release))
  end
end

Class Method Details

.release(ptr) ⇒ Object



6
7
8
# File 'lib/chipmunk-ffi/vec2.rb', line 6

def self.release( ptr )
  free ptr
end

Instance Method Details

#to_bytesObject



19
20
21
# File 'lib/chipmunk-ffi/vec2.rb', line 19

def to_bytes
  return self.pointer.get_bytes(0, self.size)
end