Sha256: f7be262b76b62234dd87c3d8d3e579282bc8040cfea25c20d41f3901643c8a0f

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

# -*- coding: utf-8 -*-


require 'xot/setter'
require 'xot/universal_accessor'
require 'xot/block_util'
require 'reflex/ext'
require 'reflex/helper'


module Reflex


  class Shape

    include Xot::Setter
    include Hookable
    include HasFrame
    include HasTags

    alias view    owner
    alias sensor? sensor

    universal_accessor :name, :selector,
      :density, :friction, :restitution, :sensor

    def initialize(options = nil, &block)
      super()
      set options if options
      Xot::BlockUtil.instance_eval_or_block_call self, &block if block
    end

    def on_contact(e)
    end

    def on_contact_begin(e)
    end

    def on_contact_end(e)
    end

    private

      def on_contact!(*args)
        call_contact!(*args)
        owner&.delay {on_contact(*args)}# delay to avoid physics world lock
      end

      def on_contact_begin!(*args)
        call_contact_begin!(*args)
        owner&.delay {on_contact_begin(*args)}
      end

      def on_contact_end!(*args)
        call_contact_end!(*args)
        owner&.delay {on_contact_end(*args)}
      end

  end# Shape


end# Reflex

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reflexion-0.1.35 lib/reflex/shape.rb
reflexion-0.1.34 lib/reflex/shape.rb
reflexion-0.1.33 lib/reflex/shape.rb