Sha256: b443ccd5f530e3d2296c0dcb596b3c43c3302cb96af5ed617859815322d859cc

Contents?: true

Size: 1.05 KB

Versions: 3

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.to_uikit_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

3 entries across 3 versions & 1 rubygems

Version Path
joybox-0.0.5 lib/joybox/cocos2d/core/physics_sprite.rb
joybox-0.0.4 lib/joybox/cocos2d/core/physics_sprite.rb
joybox-0.0.3 lib/joybox/cocos2d/core/physics_sprite.rb