Sha256: 59dce2129cefaa0118334c48a7173bea6b55fc9a698753e9a0f3c58bc2e29945
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 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 # We need this method to return true, so Cocos2d continue # to call the nodeToParentTransform method def dirty true end def position=(position) @body.position = position end 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
joybox-1.0.0 | motion/joybox/physics/physics_sprite.rb |