Sha256: 6e4be59736c0995e8a8a9efc3bf9a73cfd731dc2686e7a20eb938b7fc47e355e

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# TODO: Revisar el nombre de esto
module Joybox
  module Core

    class PhysicsSprite < Sprite

      attr_accessor :body

      def self.new(options = {})

        sprite = super 
        sprite.body = options[:body] if options.include? :body

        sprite
      end


      def dirty

        true
      end

      # We need this method to return true, so Cocos2d continue
      # to call the nodeToParentTransform method
      def nodeToParentTransform

        position = @body.position.from_pixel_coordinates

        position = position + anchorPointInPoints if ignoreAnchorPointForPosition

        angle = @body.angle

        x = position.x
        y = position.y
        cosine = Math.cos(angle)
        sine = Math.sin(angle)


        unless anchorPointInPoints == CGPointZero

          x = x + cosine * -anchorPointInPoints.x + -sine * -anchorPointInPoints.y
          y = y + sine * -anchorPointInPoints.x + cosine * -anchorPointInPoints.y        
        end


        CGAffineTransformMake(cosine, sine, -sine, cosine, x, y)
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
joybox-0.0.6 motion/joybox/physics/physics_sprite.rb