motion/joybox/physics/physics_sprite.rb in joybox-0.0.6 vs motion/joybox/physics/physics_sprite.rb in joybox-1.0.0

- old
+ new

@@ -5,48 +5,51 @@ class PhysicsSprite < Sprite attr_accessor :body def self.new(options = {}) - sprite = super sprite.body = options[:body] if options.include? :body sprite end - + # We need this method to return true, so Cocos2d continue + # to call the nodeToParentTransform method def dirty + true + end - true + def position=(position) + @body.position = position end - # We need this method to return true, so Cocos2d continue - # to call the nodeToParentTransform method + def position + @body.position.from_pixel_coordinates + end + def nodeToParentTransform + return super if @body.nil? + super + 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 +end \ No newline at end of file