joybox 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +3 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +4 -4
- data/README.md +66 -22
- data/Rakefile +22 -4
- data/app/ios/app_delegate.rb +48 -0
- data/app/osx/app_delegate.rb +26 -0
- data/app/osx/layers/game_layer.rb +5 -0
- data/app/osx/menu.rb +51 -0
- data/command/command/image.rb +26 -0
- data/command/command/string.rb +15 -0
- data/command/command/template.rb +59 -0
- data/command/command/tmx.rb +75 -0
- data/command/joybox_generate_command.rb +64 -110
- data/command/joybox_retina_command.rb +87 -0
- data/command/{joybox/templates → templates}/layer.erb +0 -0
- data/command/{joybox/templates → templates}/layer_spec.erb +0 -0
- data/command/{joybox/templates → templates}/scene.erb +0 -0
- data/command/{joybox/templates → templates}/scene_spec.erb +0 -0
- data/command/{joybox/templates → templates}/sprite.erb +0 -0
- data/command/{joybox/templates → templates}/sprite_spec.erb +0 -0
- data/ext/extconf.rb +34 -0
- data/joybox.gemspec +103 -50
- data/lib/joybox.rb +2 -0
- data/lib/joybox/joybox-ios.rb +18 -3
- data/lib/joybox/joybox-osx.rb +18 -2
- data/lib/joybox/version.rb +1 -1
- data/motion/joybox-ios/common/cg_point.rb +46 -16
- data/motion/joybox-ios/common/device.rb +56 -0
- data/motion/joybox-ios/common/ui_touch.rb +0 -2
- data/motion/joybox-ios/configuration/configuration.rb +10 -40
- data/motion/joybox-ios/configuration/file_utils.rb +0 -4
- data/motion/joybox-ios/configuration/gl_view.rb +14 -20
- data/motion/joybox-ios/configuration/texture_2d.rb +0 -4
- data/motion/joybox-ios/core/layer.rb +2 -8
- data/motion/joybox-ios/debug/proxy_view.rb +5 -5
- data/motion/joybox-ios/debug/{node.rb → repl.rb} +25 -19
- data/motion/joybox-ios/director.rb +15 -4
- data/motion/joybox-osx/common/ats_point.rb +45 -15
- data/motion/joybox-osx/common/device.rb +30 -0
- data/motion/joybox-osx/common/ns_event.rb +0 -1
- data/motion/joybox-osx/configuration/configuration.rb +6 -26
- data/motion/joybox-osx/configuration/gl_view.rb +16 -14
- data/motion/joybox-osx/core/layer.rb +45 -26
- data/motion/joybox-osx/debug/proxy_view.rb +5 -5
- data/motion/joybox-osx/debug/{node.rb → repl.rb} +13 -7
- data/motion/joybox-osx/director.rb +4 -3
- data/motion/joybox/actions/animate.rb +0 -1
- data/motion/joybox/actions/bezier.rb +2 -9
- data/motion/joybox/actions/blink.rb +1 -4
- data/motion/joybox/actions/callback.rb +19 -0
- data/motion/joybox/actions/d3/flip.rb +27 -0
- data/motion/joybox/actions/d3/jump.rb +30 -0
- data/motion/joybox/actions/d3/lens.rb +30 -0
- data/motion/joybox/actions/d3/shake.rb +32 -0
- data/motion/joybox/actions/d3/shatter.rb +30 -0
- data/motion/joybox/actions/d3/wave.rb +33 -0
- data/motion/joybox/actions/delay.rb +19 -0
- data/motion/joybox/actions/ease.rb +3 -21
- data/motion/joybox/actions/fade.rb +30 -6
- data/motion/joybox/actions/jump.rb +0 -5
- data/motion/joybox/actions/liquid.rb +28 -0
- data/motion/joybox/actions/move.rb +2 -9
- data/motion/joybox/actions/place.rb +0 -2
- data/motion/joybox/actions/repeat.rb +0 -2
- data/motion/joybox/actions/rotate.rb +2 -9
- data/motion/joybox/actions/scale.rb +2 -9
- data/motion/joybox/actions/sequence.rb +0 -1
- data/motion/joybox/actions/shuffle.rb +26 -0
- data/motion/joybox/actions/skew.rb +2 -11
- data/motion/joybox/actions/spawn.rb +0 -1
- data/motion/joybox/actions/split.rb +24 -0
- data/motion/joybox/actions/tint.rb +0 -5
- data/motion/joybox/actions/turn.rb +24 -0
- data/motion/joybox/actions/twirl.rb +30 -0
- data/motion/joybox/actions/visibility.rb +21 -0
- data/motion/joybox/actions/wave.rb +32 -0
- data/motion/joybox/animations/animation.rb +7 -11
- data/motion/joybox/audio/audio.rb +31 -0
- data/motion/joybox/audio/audio_effect.rb +69 -0
- data/motion/joybox/audio/background_audio.rb +77 -0
- data/motion/joybox/common/{gc_size.rb → cg_size.rb} +13 -12
- data/motion/joybox/common/color.rb +4 -13
- data/motion/joybox/common/initialize.rb +11 -0
- data/motion/joybox/common/ns_array.rb +15 -0
- data/motion/joybox/common/ns_string.rb +7 -0
- data/motion/joybox/common/numeric.rb +13 -4
- data/motion/joybox/common/screen.rb +4 -12
- data/motion/joybox/configuration/debug.rb +29 -0
- data/motion/joybox/core/layer.rb +0 -24
- data/motion/joybox/core/layer_color.rb +47 -0
- data/motion/joybox/core/node.rb +18 -8
- data/motion/joybox/core/scene.rb +0 -5
- data/motion/joybox/core/sprite.rb +43 -25
- data/motion/joybox/core/sprite_batch.rb +15 -6
- data/motion/joybox/core/sprite_frame_cache.rb +9 -58
- data/motion/joybox/debug/physics.rb +40 -0
- data/motion/joybox/debug/physics_draw.rb +191 -0
- data/motion/joybox/joybox.rb +9 -1
- data/motion/joybox/macros.rb +13 -13
- data/motion/joybox/physics/aabb.rb +28 -0
- data/motion/joybox/physics/body.rb +163 -68
- data/motion/joybox/physics/chain_shape.rb +71 -0
- data/motion/joybox/physics/circle_shape.rb +31 -0
- data/motion/joybox/physics/edge_shape.rb +37 -0
- data/motion/joybox/physics/filter.rb +17 -0
- data/motion/joybox/physics/fixture.rb +52 -0
- data/motion/joybox/physics/mass_data.rb +19 -0
- data/motion/joybox/physics/physics_sprite.rb +50 -16
- data/motion/joybox/physics/polygon_shape.rb +54 -0
- data/motion/joybox/physics/profile.rb +14 -0
- data/motion/joybox/physics/ray_cast_input.rb +30 -0
- data/motion/joybox/physics/ray_cast_output.rb +17 -0
- data/motion/joybox/physics/shape.rb +61 -0
- data/motion/joybox/physics/transform.rb +17 -0
- data/motion/joybox/physics/world.rb +101 -30
- data/motion/joybox/tmx/object_layer.rb +12 -0
- data/motion/joybox/tmx/tile_layer.rb +74 -0
- data/motion/joybox/tmx/tile_map.rb +112 -0
- data/motion/joybox/tmx/tile_set.rb +26 -0
- data/motion/joybox/tmx/tmx.rb +16 -0
- data/motion/joybox/ui/label.rb +44 -16
- data/motion/joybox/ui/menu.rb +7 -9
- data/motion/joybox/ui/menu_image.rb +11 -8
- data/motion/joybox/ui/menu_label.rb +14 -13
- data/resources/Default-568h@2x.png +0 -0
- data/resources/animation_frames-hd.plist +126 -0
- data/resources/animation_frames-ipadhd.plist +126 -0
- data/resources/animation_frames.plist +126 -0
- data/resources/animation_sprite_sheet-hd.png +0 -0
- data/resources/animation_sprite_sheet-ipadhd.png +0 -0
- data/resources/animation_sprite_sheet.png +0 -0
- data/resources/fps_images-hd.png +0 -0
- data/resources/fps_images-ipadhd.png +0 -0
- data/resources/fps_images.png +0 -0
- data/resources/sprite.png +0 -0
- data/resources/sprite_inverted.png +0 -0
- data/resources/sprite_sheet.png +0 -0
- data/spec/motion/joybox-ios/common/screen_spec.rb +21 -0
- data/spec/{main_spec.rb → motion/joybox-ios/main_spec.rb} +6 -2
- data/spec/motion/joybox-ios/ui/label_spec.rb +20 -0
- data/spec/motion/joybox-ios/ui/menu_label_spec.rb +15 -0
- data/spec/motion/joybox-ios/ui/menu_spec.rb +87 -0
- data/spec/motion/joybox-osx/common/screen_spec.rb +21 -0
- data/spec/motion/joybox-osx/main_spec.rb +13 -0
- data/spec/motion/joybox-osx/ui/label_spec.rb +18 -0
- data/spec/motion/joybox-osx/ui/menu_label_spec.rb +13 -0
- data/spec/motion/joybox-osx/ui/menu_spec.rb +87 -0
- data/spec/motion/joybox/actions/actions_spec.rb +11 -0
- data/spec/motion/joybox/actions/bezier_spec.rb +37 -0
- data/spec/motion/joybox/actions/blink_spec.rb +16 -0
- data/spec/motion/joybox/actions/fade_spec.rb +49 -0
- data/spec/motion/joybox/actions/jump_spec.rb +37 -0
- data/spec/motion/joybox/actions/move_spec.rb +37 -0
- data/spec/motion/joybox/actions/place_spec.rb +12 -0
- data/spec/motion/joybox/actions/rotate_spec.rb +35 -0
- data/spec/motion/joybox/actions/scale_spec.rb +43 -0
- data/spec/motion/joybox/actions/skew_spec.rb +43 -0
- data/spec/motion/joybox/common/cg_size_spec.rb +29 -0
- data/spec/motion/joybox/common/color_spec.rb +31 -0
- data/spec/motion/joybox/common/ns_string_spec.rb +8 -0
- data/spec/motion/joybox/common/numeric_spec.rb +13 -0
- data/spec/motion/joybox/core/node_spec.rb +36 -0
- data/spec/motion/joybox/core/sprite_batch_spec.rb +34 -0
- data/spec/motion/joybox/core/sprite_frame_cache_spec.rb +111 -0
- data/spec/motion/joybox/core/sprite_spec.rb +121 -0
- data/spec/motion/joybox/macros_spec.rb +280 -0
- data/spec/motion/joybox/physics/aabb_spec.rb +17 -0
- data/spec/motion/joybox/physics/body_spec.rb +318 -0
- data/spec/motion/joybox/physics/chain_shape_spec.rb +80 -0
- data/spec/motion/joybox/physics/circle_shape_spec.rb +63 -0
- data/spec/motion/joybox/physics/edge_shape_spec.rb +48 -0
- data/spec/motion/joybox/physics/fixture_spec.rb +106 -0
- data/spec/motion/joybox/physics/mass_data_spec.rb +13 -0
- data/spec/motion/joybox/physics/physics_sprite_spec.rb +50 -0
- data/spec/motion/joybox/physics/polygon_shape_spec.rb +92 -0
- data/spec/motion/joybox/physics/ray_cast_input_spec.rb +17 -0
- data/spec/motion/joybox/physics/ray_cast_output_spec.rb +13 -0
- data/spec/motion/joybox/physics/shape_spec.rb +50 -0
- data/spec/motion/joybox/physics/transform_spec.rb +13 -0
- data/spec/motion/joybox/physics/world_spec.rb +228 -0
- data/spec/motion/joybox/ui/label_spec.rb +53 -0
- data/spec/motion/joybox/ui/menu_image_spec.rb +51 -0
- data/spec/motion/joybox/ui/menu_label_spec.rb +68 -0
- data/spec/motion/joybox/ui/menu_spec.rb +26 -0
- data/spec/spec_helpers/cg_point.rb +5 -0
- data/spec/spec_helpers/cg_point_spec.rb +14 -0
- data/template/joybox-ios-example-repl/files/.gitignore +16 -0
- data/template/joybox-ios/files/.gitignore +16 -0
- data/template/joybox-osx-example-repl/files/.gitignore +16 -0
- data/template/joybox-osx/files/.gitignore +16 -0
- data/vendor/vendor-ios/box_2d/box_2d.bridgesupport +1201 -85
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DAABB.h +21 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DBody.h +58 -13
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DBodyDef.h +44 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DBodyTypes.h +20 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DChainShape.h +29 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DCircleShape.h +7 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DColor.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DContactFilter.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DContactListener.h +1 -1
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DDestructionListener.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DDraw.h +54 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DEdgeShape.h +13 -2
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DFilter.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DFixture.h +47 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DFixtureDef.h +29 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DMassData.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DPolygonShape.h +14 -1
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DProfile.h +31 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DQueryCallback.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DRayCastCallback.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DRayCastInput.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DRayCastOutput.h +21 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DShape.h +23 -3
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DShapeTypes.h +22 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DTransform.h +21 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DWorld.h +40 -19
- data/vendor/vendor-ios/box_2d/libBox2D.a +0 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d.bridgesupport +808 -1578
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCActionEase.h +47 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCFontDefinition.h +85 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCLabelTTF.h +54 -6
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCMenuItem.h +1 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCTMXLayer.h +2 -2
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCTexture2D.h +4 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/ccTypes.h +51 -1
- data/vendor/vendor-ios/cocos_2d/libcocos2d.a +0 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader.bridgesupport +510 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBAnimationManager.h +149 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBKeyframe.h +40 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBReader.h +176 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBSequence.h +49 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBSequenceProperty.h +38 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCNode+CCBRelativePositioning.h +65 -0
- data/vendor/vendor-ios/cocos_builder_reader/libCocosBuilderReader.a +0 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion.bridgesupport +1001 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDAudioManager.h +243 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDConfig.h +60 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDOpenALSupport.h +77 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDXMacOSXSupport.h +232 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDXPropertyModifierAction.h +45 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CocosDenshion.h +440 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/SimpleAudioEngine.h +90 -0
- data/vendor/vendor-ios/cocos_denshion/libCocosDenshion.a +0 -0
- data/vendor/vendor-ios/kazmath/kazmath.bridgesupport +865 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/GL/mat4stack.h +51 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/GL/matrix.h +58 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/aabb.h +53 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/kazmath.h +39 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/mat3.h +75 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/mat4.h +93 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/neon_matrix_impl.h +41 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/plane.h +70 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/quaternion.h +113 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/ray2.h +50 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/utility.h +74 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/vec2.h +64 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/vec3.h +68 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/vec4.h +68 -0
- data/vendor/vendor-ios/kazmath/libkazmath.a +0 -0
- data/vendor/vendor-osx/box_2d/box_2d.bridgesupport +1199 -83
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DAABB.h +21 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DBody.h +58 -13
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DBodyDef.h +44 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DBodyTypes.h +20 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DChainShape.h +29 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DCircleShape.h +7 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DColor.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DContactFilter.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DContactListener.h +1 -1
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DDestructionListener.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DDraw.h +54 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DEdgeShape.h +13 -2
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DFilter.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DFixture.h +47 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DFixtureDef.h +29 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DMassData.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DPolygonShape.h +14 -1
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DProfile.h +31 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DQueryCallback.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DRayCastCallback.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DRayCastInput.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DRayCastOutput.h +21 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DShape.h +23 -3
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DShapeTypes.h +22 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DTransform.h +21 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DWorld.h +40 -19
- data/vendor/vendor-osx/box_2d/libBox2D.a +0 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d.bridgesupport +2820 -2633
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCActionEase.h +47 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCFontDefinition.h +85 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCLabelTTF.h +54 -6
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCMenuItem.h +1 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCTMXLayer.h +2 -2
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCTexture2D.h +4 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCDirectorIOS.h +111 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCES2Renderer.h +83 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCESRenderer.h +54 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCGLView.h +175 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCTouchDelegateProtocol.h +75 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCTouchDispatcher.h +120 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCTouchHandler.h +93 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/ccTypes.h +65 -1
- data/vendor/vendor-osx/cocos_2d/libcocos2d.a +0 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader.bridgesupport +510 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBAnimationManager.h +149 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBKeyframe.h +40 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBReader.h +176 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBSequence.h +49 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBSequenceProperty.h +38 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCNode+CCBRelativePositioning.h +65 -0
- data/vendor/vendor-osx/cocos_builder_reader/libCocosBuilderReader.a +0 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion.bridgesupport +1001 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDAudioManager.h +243 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDConfig.h +60 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDOpenALSupport.h +77 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDXMacOSXSupport.h +232 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDXPropertyModifierAction.h +45 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CocosDenshion.h +440 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/SimpleAudioEngine.h +90 -0
- data/vendor/vendor-osx/cocos_denshion/libCocosDenshion.a +0 -0
- data/vendor/vendor-osx/kazmath/kazmath.bridgesupport +865 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/GL/mat4stack.h +51 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/GL/matrix.h +58 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/aabb.h +53 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/kazmath.h +39 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/mat3.h +75 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/mat4.h +93 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/neon_matrix_impl.h +41 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/plane.h +70 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/quaternion.h +113 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/ray2.h +50 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/utility.h +74 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/vec2.h +64 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/vec3.h +68 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/vec4.h +68 -0
- data/vendor/vendor-osx/kazmath/libkazmath.a +0 -0
- metadata +353 -57
- checksums.yaml +0 -15
- data/bin/joybox +0 -49
- data/command/joybox/USAGE +0 -24
- data/motion/joybox-ios/configuration/debug.rb +0 -27
- data/motion/joybox-ios/debug/debug.rb +0 -10
- data/motion/joybox-osx/configuration/debug.rb +0 -27
- data/motion/joybox-osx/configuration/sprite_view.rb +0 -91
- data/motion/joybox-osx/debug/debug.rb +0 -10
- data/motion/joybox/core/ns_object.rb +0 -8
- data/spec/lib/joybox/cocos2d/cocos2d_spec.rb +0 -7
- data/spec/lib/joybox/cocos2d/macros_spec.rb +0 -37
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/cocos2d-ios-exceptions.bridgesupport +0 -39
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/gen_cocos2d_bridgesupport.sh +0 -17
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/gen_cocos2d_complement.sh +0 -17
data/motion/joybox/joybox.rb
CHANGED
|
@@ -7,11 +7,19 @@ module Joybox
|
|
|
7
7
|
include Joybox::UI
|
|
8
8
|
include Joybox::Macros
|
|
9
9
|
include Joybox::Physics
|
|
10
|
-
|
|
10
|
+
include Joybox::Audio
|
|
11
|
+
|
|
12
|
+
attr_accessor :random
|
|
13
|
+
|
|
11
14
|
module_function
|
|
12
15
|
|
|
13
16
|
def director
|
|
14
17
|
Director.sharedDirector
|
|
15
18
|
end
|
|
16
19
|
|
|
20
|
+
def generate_seed
|
|
21
|
+
@random ||= Random.new
|
|
22
|
+
@random.rand(10...100)
|
|
23
|
+
end
|
|
24
|
+
|
|
17
25
|
end
|
data/motion/joybox/macros.rb
CHANGED
|
@@ -51,7 +51,7 @@ module Joybox
|
|
|
51
51
|
jbp(-point.y, point.x)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
# Perpendicular of
|
|
54
|
+
# Perpendicular of point, rotated 90 degrees clockwise
|
|
55
55
|
def jbpRPerp(point)
|
|
56
56
|
jbp(point.y, -point.x)
|
|
57
57
|
end
|
|
@@ -73,7 +73,7 @@ module Joybox
|
|
|
73
73
|
first_point.y * second_point.x - first_point.x * second_point.y)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
# Square lenght of a
|
|
76
|
+
# Square lenght of a point
|
|
77
77
|
def jbpLengthSQ(point)
|
|
78
78
|
jbpDot(point, point)
|
|
79
79
|
end
|
|
@@ -93,7 +93,7 @@ module Joybox
|
|
|
93
93
|
jbpLength(jbpSub(first_point, second_point))
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
# Point multiplied to a
|
|
96
|
+
# Point multiplied to a length of 1
|
|
97
97
|
def jbpNormalize(point)
|
|
98
98
|
jbpMult(point, 1.0 / jbpLength(point))
|
|
99
99
|
end
|
|
@@ -105,7 +105,7 @@ module Joybox
|
|
|
105
105
|
|
|
106
106
|
# Converts vector to radians
|
|
107
107
|
def jbpToAngle(point)
|
|
108
|
-
Math.atan2(
|
|
108
|
+
Math.atan2(point.y, point.x)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
# Clamp a value between from and to
|
|
@@ -127,7 +127,7 @@ module Joybox
|
|
|
127
127
|
clamp(point.y, minimum_inclusive.y, maximum_inclusive.y))
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
#
|
|
130
|
+
# CGPoint from a CGSize
|
|
131
131
|
def jbpFromSize(size)
|
|
132
132
|
jbp(size.width, size.height)
|
|
133
133
|
end
|
|
@@ -163,8 +163,8 @@ module Joybox
|
|
|
163
163
|
first_point = jbpNormalize(first_point)
|
|
164
164
|
second_point = jbpNormalize(second_point)
|
|
165
165
|
|
|
166
|
-
angle = Math.atan2(first_point.x * second_point.y - first_point.y * second_point.x
|
|
167
|
-
jbpDot(first_point, second_point)
|
|
166
|
+
angle = Math.atan2(first_point.x * second_point.y - first_point.y * second_point.x,
|
|
167
|
+
jbpDot(first_point, second_point))
|
|
168
168
|
|
|
169
169
|
angle = 0.0 if angle.abs < Float::EPSILON
|
|
170
170
|
angle
|
|
@@ -192,7 +192,7 @@ module Joybox
|
|
|
192
192
|
# Evaluates if two lines intersect
|
|
193
193
|
def jbpLineIntersect(point_a, point_b, point_c, point_d)
|
|
194
194
|
# Line undefined
|
|
195
|
-
return
|
|
195
|
+
return nil if point_a.x == point_b.x && point_a.y == point_b.y || point_c.x == point_d.x && point_c.y == point_d.y
|
|
196
196
|
|
|
197
197
|
x_b_to_a = point_b.x - point_a.x
|
|
198
198
|
y_b_to_a = point_b.y - point_a.y
|
|
@@ -207,20 +207,20 @@ module Joybox
|
|
|
207
207
|
denom = y_d_to_c * x_b_to_a - x_d_to_c * y_b_to_a
|
|
208
208
|
if denom == 0
|
|
209
209
|
# Lines incident
|
|
210
|
-
return { s:
|
|
210
|
+
return { s: s, t: t } if s == 0 && t == 0
|
|
211
211
|
|
|
212
212
|
# Lines parallel and not incident
|
|
213
213
|
return nil
|
|
214
214
|
end
|
|
215
215
|
|
|
216
|
-
{ s:
|
|
216
|
+
{ s: s / denom, t: t / denom }
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
# Evaluates if two segments intersect
|
|
220
220
|
def jbpSegmentIntersect(point_a, point_b, point_c, point_d)
|
|
221
221
|
r = jbpLineIntersect(point_a, point_b, point_c, point_d)
|
|
222
|
-
return false
|
|
223
|
-
return true
|
|
222
|
+
return false if r.nil?
|
|
223
|
+
return r[:s] >= 0.0 && r[:s] <= 1.0 && r[:t] >= 0.0 && r[:t] <= 1.0 ? true : false
|
|
224
224
|
end
|
|
225
225
|
|
|
226
226
|
# Intersection point between the two lines
|
|
@@ -231,4 +231,4 @@ module Joybox
|
|
|
231
231
|
end
|
|
232
232
|
|
|
233
233
|
end
|
|
234
|
-
end
|
|
234
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Joybox::Physics::AABB = B2DAABB
|
|
2
|
+
|
|
3
|
+
class B2DAABB
|
|
4
|
+
|
|
5
|
+
alias_method :metric_lower_bound, :lowerBound
|
|
6
|
+
alias_method :metric_lower_bound=, :setLowerBound
|
|
7
|
+
alias_method :metric_upper_bound, :upperBound
|
|
8
|
+
alias_method :metric_upper_bound=, :setUpperBound
|
|
9
|
+
|
|
10
|
+
def lower_bound
|
|
11
|
+
lowerBound.to_pixel_coordinates
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def lower_bound=(bound)
|
|
15
|
+
bound = bound.to_point unless bound.is_a? (CGPoint)
|
|
16
|
+
self.lowerBound = bound.from_pixel_coordinates
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def upper_bound
|
|
20
|
+
upperBound.to_pixel_coordinates
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def upper_bound=(bound)
|
|
24
|
+
bound = bound.to_point unless bound.is_a? (CGPoint)
|
|
25
|
+
self.upperBound = bound.from_pixel_coordinates
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -2,134 +2,229 @@ Joybox::Physics::Body = B2DBody
|
|
|
2
2
|
|
|
3
3
|
class B2DBody
|
|
4
4
|
|
|
5
|
+
alias_method :world_center, :worldCenter
|
|
6
|
+
alias_method :local_center, :localCenter
|
|
7
|
+
alias_method :linear_velocity, :linearVelocity
|
|
8
|
+
alias_method :linear_velocity=, :setLinearVelocity
|
|
9
|
+
alias_method :angular_velocity, :angularVelocity
|
|
10
|
+
alias_method :angular_velocity=, :setAngularVelocity
|
|
11
|
+
alias_method :linear_damping, :linearDamping
|
|
12
|
+
alias_method :linear_damping=, :setLinearDamping
|
|
13
|
+
alias_method :angular_damping, :angularDamping
|
|
14
|
+
alias_method :angular_damping=, :setAngularDamping
|
|
15
|
+
alias_method :gravity_scale, :gravityScale
|
|
16
|
+
alias_method :gravity_scale=, :setGravityScale
|
|
17
|
+
alias_method :bullet?, :isBullet
|
|
18
|
+
alias_method :bullet=, :setBullet
|
|
19
|
+
alias_method :awake?, :isAwake
|
|
20
|
+
alias_method :awake=, :setAwake
|
|
21
|
+
alias_method :active?, :isActive
|
|
22
|
+
alias_method :fixed_rotation?, :isFixedRotation
|
|
23
|
+
alias_method :fixed_rotation=, :setFixedRotation
|
|
24
|
+
alias_method :sleeping_allowed?, :isSleepingAllowed
|
|
25
|
+
alias_method :sleeping_allowed=, :setSleepingAllowed
|
|
26
|
+
alias_method :reset_mass, :resetMassData
|
|
27
|
+
alias_method :fixtures, :fixtureList
|
|
28
|
+
alias_method :destroy_fixture, :destroyFixture
|
|
29
|
+
alias_method :metric_position, :position
|
|
30
|
+
alias_method :radian_angle, :angle
|
|
31
|
+
|
|
32
|
+
Static = 0
|
|
33
|
+
Kinematic = 1
|
|
34
|
+
Dynamic = 2
|
|
35
|
+
|
|
5
36
|
def self.defaults
|
|
6
37
|
{
|
|
7
38
|
position: [0, 0],
|
|
8
|
-
|
|
39
|
+
angle: 0,
|
|
40
|
+
linear_velocity: [0, 0],
|
|
41
|
+
angular_velocity: 0,
|
|
42
|
+
linear_damping: 0,
|
|
43
|
+
angular_damping: 0,
|
|
44
|
+
allow_sleep: true,
|
|
45
|
+
awake: true,
|
|
46
|
+
fixed_rotation: false,
|
|
47
|
+
bullet: false,
|
|
48
|
+
type: Static,
|
|
49
|
+
active: true,
|
|
50
|
+
gravity_scale: 1.0
|
|
9
51
|
}
|
|
10
52
|
end
|
|
11
53
|
|
|
54
|
+
def mass_data
|
|
55
|
+
massData
|
|
56
|
+
end
|
|
12
57
|
|
|
13
|
-
def
|
|
58
|
+
def mass_data=(mass_data)
|
|
59
|
+
setMassData(mass_data)
|
|
60
|
+
end
|
|
14
61
|
|
|
62
|
+
def self.new(world, options = {})
|
|
15
63
|
options = options.nil? ? defaults : defaults.merge!(options)
|
|
16
64
|
|
|
17
|
-
|
|
65
|
+
body_definition = B2DBodyDef.new()
|
|
18
66
|
position = CGPointMake(options[:position][0], options[:position][1])
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
67
|
+
body_definition.position = position.from_pixel_coordinates
|
|
68
|
+
body_definition.angle = options[:angle].to_radians * -1
|
|
69
|
+
linear_velocity = CGPointMake(options[:linear_velocity][0], options[:linear_velocity][1])
|
|
70
|
+
body_definition.linearVelocity = linear_velocity.from_pixel_coordinates
|
|
71
|
+
body_definition.angularVelocity = options[:angular_velocity]
|
|
72
|
+
body_definition.linearDamping = options[:linear_damping]
|
|
73
|
+
body_definition.angularDamping = options[:angular_damping]
|
|
74
|
+
body_definition.allowSleep = options[:allow_sleep]
|
|
75
|
+
body_definition.awake = options[:awake]
|
|
76
|
+
body_definition.fixedRotation = options[:fixed_rotation]
|
|
77
|
+
body_definition.bullet = options[:bullet]
|
|
78
|
+
body_definition.type = options[:type]
|
|
79
|
+
body_definition.active = options[:active]
|
|
80
|
+
body_definition.gravityScale = options[:gravity_scale]
|
|
81
|
+
|
|
82
|
+
body = world.createBody(body_definition)
|
|
83
|
+
body.userData = Hash.new
|
|
84
|
+
body
|
|
22
85
|
end
|
|
23
86
|
|
|
87
|
+
def ==(body)
|
|
88
|
+
body.is_a?(self.class) && self.isEqualToBody(body)
|
|
89
|
+
end
|
|
24
90
|
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
91
|
+
def position
|
|
92
|
+
metric_position.to_pixel_coordinates
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def position=(position)
|
|
96
|
+
position = CGPointMake(position[0], position[1])
|
|
97
|
+
position = position.from_pixel_coordinates
|
|
98
|
+
self.setTransformWithPosition(position, andAngle: radian_angle)
|
|
32
99
|
end
|
|
33
100
|
|
|
101
|
+
def angle
|
|
102
|
+
radian_angle.from_radians * -1
|
|
103
|
+
end
|
|
34
104
|
|
|
35
|
-
def
|
|
105
|
+
def angle=(angle)
|
|
106
|
+
self.setTransformWithPosition(metric_position, andAngle: angle.to_radians * -1)
|
|
107
|
+
end
|
|
36
108
|
|
|
37
|
-
|
|
38
|
-
|
|
109
|
+
def to_world_point(local_point)
|
|
110
|
+
local_point = local_point.to_point.from_pixel_coordinates
|
|
111
|
+
worldPoint(local_point).to_pixel_coordinates
|
|
112
|
+
end
|
|
39
113
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
114
|
+
def to_world_vector(local_vector)
|
|
115
|
+
local_vector = local_vector.to_point.from_pixel_coordinates
|
|
116
|
+
worldVector(local_vector).to_pixel_coordinates
|
|
117
|
+
end
|
|
44
118
|
|
|
45
|
-
|
|
46
|
-
|
|
119
|
+
def to_local_point(world_point)
|
|
120
|
+
world_point = world_point.to_point.from_pixel_coordinates
|
|
121
|
+
localPoint(world_point).to_pixel_coordinates
|
|
122
|
+
end
|
|
47
123
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
density: options[:density],
|
|
52
|
-
isSensor: options[:is_sensor])
|
|
124
|
+
def to_local_vector(world_vector)
|
|
125
|
+
world_vector = world_vector.to_point.from_pixel_coordinates
|
|
126
|
+
localVector(world_vector).to_pixel_coordinates
|
|
53
127
|
end
|
|
54
128
|
|
|
129
|
+
def linear_velocity_at(options = {})
|
|
130
|
+
point = options[:local_point] if options.has_key? :local_point
|
|
131
|
+
point = options[:world_point] if options.has_key? :world_point
|
|
132
|
+
point = point.to_point.from_pixel_coordinates
|
|
55
133
|
|
|
56
|
-
|
|
134
|
+
return linearVelocityFromLocalPoint(point) if options.has_key? :local_point
|
|
135
|
+
return linearVelocityFromWorldPoint(point) if options.has_key? :world_point
|
|
136
|
+
end
|
|
57
137
|
|
|
58
|
-
|
|
59
|
-
|
|
138
|
+
def [](key)
|
|
139
|
+
self.userData[key]
|
|
140
|
+
end
|
|
60
141
|
|
|
61
|
-
|
|
62
|
-
|
|
142
|
+
def []=(key, value)
|
|
143
|
+
self.userData[key] = value
|
|
144
|
+
end
|
|
63
145
|
|
|
64
|
-
|
|
146
|
+
def new_fixture(&block)
|
|
147
|
+
instance_eval(&block) if block
|
|
148
|
+
end
|
|
65
149
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
restitution: options[:restitution],
|
|
69
|
-
density: options[:density],
|
|
70
|
-
isSensor: options[:is_sensor])
|
|
150
|
+
def fixture(options = {})
|
|
151
|
+
add_fixture(options, options[:shape])
|
|
71
152
|
end
|
|
72
153
|
|
|
154
|
+
def edge_fixture(options = {})
|
|
155
|
+
edge_shape = B2DEdgeShape.new(options)
|
|
156
|
+
add_fixture(options, edge_shape)
|
|
157
|
+
end
|
|
73
158
|
|
|
74
|
-
def
|
|
159
|
+
def polygon_fixture(options = {})
|
|
160
|
+
polygon_shape = B2DPolygonShape.new(options)
|
|
161
|
+
add_fixture(options, polygon_shape)
|
|
162
|
+
end
|
|
75
163
|
|
|
76
|
-
|
|
77
|
-
|
|
164
|
+
def circle_fixture(options = {})
|
|
165
|
+
circle_shape = B2DCircleShape.new(options)
|
|
166
|
+
add_fixture(options, circle_shape)
|
|
167
|
+
end
|
|
78
168
|
|
|
79
|
-
|
|
80
|
-
|
|
169
|
+
def chain_fixture(options = {})
|
|
170
|
+
chain_shape = B2DChainShape.new(options)
|
|
171
|
+
add_fixture(options, chain_shape)
|
|
172
|
+
end
|
|
81
173
|
|
|
82
|
-
|
|
174
|
+
def add_fixture_defaults
|
|
175
|
+
{
|
|
176
|
+
friction: 0.2,
|
|
177
|
+
restitution: 0,
|
|
178
|
+
density: 0,
|
|
179
|
+
is_sensor: false
|
|
180
|
+
}
|
|
83
181
|
end
|
|
84
182
|
|
|
183
|
+
def add_fixture(options = {}, shape)
|
|
184
|
+
options = options.nil? ? add_fixture_defaults : add_fixture_defaults.merge!(options)
|
|
85
185
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
186
|
+
fixture_definition = B2DFixtureDef.new
|
|
187
|
+
fixture_definition.shape = shape;
|
|
188
|
+
fixture_definition.friction = options[:friction];
|
|
189
|
+
fixture_definition.restitution = options[:friction];
|
|
190
|
+
fixture_definition.density = options[:density];
|
|
191
|
+
fixture_definition.isSensor = options[:is_sensor];
|
|
89
192
|
|
|
90
|
-
|
|
91
|
-
addFixtureForShape(circle_shape,
|
|
92
|
-
friction: options[:friction],
|
|
93
|
-
restitution: options[:restitution],
|
|
94
|
-
density: options[:density],
|
|
95
|
-
isSensor: options[:is_sensor])
|
|
193
|
+
createFixture(fixture_definition)
|
|
96
194
|
end
|
|
97
195
|
|
|
98
|
-
|
|
99
196
|
def apply_force_defaults
|
|
100
197
|
{
|
|
101
|
-
location: self.center,
|
|
102
198
|
as_impulse: true
|
|
103
199
|
}
|
|
104
200
|
end
|
|
105
201
|
|
|
106
|
-
|
|
107
202
|
def apply_force(options = {})
|
|
108
|
-
|
|
109
203
|
options = options.nil? ? apply_force_defaults : apply_force_defaults.merge!(options)
|
|
204
|
+
force = CGPointMake(options[:force][0], options[:force][1]).from_pixel_coordinates
|
|
110
205
|
|
|
111
|
-
|
|
112
|
-
|
|
206
|
+
if options.has_key? :location
|
|
207
|
+
location = CGPointMake(options[:location][0], options[:location][1])
|
|
208
|
+
location = location.from_pixel_coordinates
|
|
209
|
+
else
|
|
210
|
+
location = local_center
|
|
211
|
+
end
|
|
113
212
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
asImpulse: options[:as_impulse])
|
|
213
|
+
applyLinearImpulse(force, atPoint: location) if options[:as_impulse]
|
|
214
|
+
applyForce(force, atPoint: location) unless options[:as_impulse]
|
|
117
215
|
end
|
|
118
216
|
|
|
119
|
-
|
|
120
217
|
def apply_torque_defaults
|
|
121
218
|
{
|
|
122
219
|
as_impulse: true
|
|
123
220
|
}
|
|
124
221
|
end
|
|
125
222
|
|
|
126
|
-
|
|
127
223
|
def apply_torque(options = {})
|
|
128
|
-
|
|
129
224
|
options = options.nil? ? apply_torque_defaults : apply_torque_defaults.merge!(options)
|
|
130
225
|
|
|
131
|
-
applyTorque(options[:torque]
|
|
132
|
-
|
|
226
|
+
applyTorque(options[:torque]) unless options[:as_impulse]
|
|
227
|
+
applyAngularImpulse(options[:torque]) if options[:as_impulse]
|
|
133
228
|
end
|
|
134
229
|
|
|
135
|
-
end
|
|
230
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Joybox::Physics::ChainShape = B2DChainShape
|
|
2
|
+
|
|
3
|
+
class B2DChainShape
|
|
4
|
+
|
|
5
|
+
extend Joybox::Common::Initialize
|
|
6
|
+
|
|
7
|
+
alias_method :metric_vertices, :vertices
|
|
8
|
+
alias_method :has_previous_vertex?, :hasPreviousVertex
|
|
9
|
+
alias_method :has_next_vertex?, :hasNextVertex
|
|
10
|
+
alias_method :metric_previous_vertex, :previousVertex
|
|
11
|
+
alias_method :metric_previous_vertex=, :setPreviousVertex
|
|
12
|
+
alias_method :metric_next_vertex, :nextVertex
|
|
13
|
+
alias_method :metric_next_vertex=, :setNextVertex
|
|
14
|
+
|
|
15
|
+
def initialize(options = {})
|
|
16
|
+
init
|
|
17
|
+
initialize_with_loop(options) if options.has_key? :loop
|
|
18
|
+
initialize_with_chain(options) if options.has_key? :chain
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def initialize_with_loop(options = {})
|
|
22
|
+
vertices = Pointer.new(CGPoint.type, options[:loop].size)
|
|
23
|
+
options[:loop].each_with_index do |vertex, index|
|
|
24
|
+
vertices[index] = CGPointMake(vertex[0], vertex[1]).from_pixel_coordinates
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
createLoopWithVertices(vertices, andVertexCount: options[:loop].size)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def initialize_with_chain(options = {})
|
|
31
|
+
vertices = Pointer.new(CGPoint.type, options[:chain].size)
|
|
32
|
+
options[:chain].each_with_index do |vertex, index|
|
|
33
|
+
vertices[index] = CGPointMake(vertex[0], vertex[1]).from_pixel_coordinates
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
createChainWithVertices(vertices, andVertexCount: options[:chain].size)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def vertices_count
|
|
40
|
+
vertexCount
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def vertices
|
|
44
|
+
Array.new(vertices_count){ |i| metric_vertices[i].to_pixel_coordinates }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def previous_vertex
|
|
48
|
+
previousVertex.to_pixel_coordinates
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def previous_vertex=(vertex)
|
|
52
|
+
vertex = vertex.to_point unless vertex.is_a? (CGPoint)
|
|
53
|
+
setPreviousVertex(vertex.from_pixel_coordinates)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def next_vertex
|
|
57
|
+
nextVertex.to_pixel_coordinates
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def next_vertex=(vertex)
|
|
61
|
+
vertex = vertex.to_point unless vertex.is_a? (CGPoint)
|
|
62
|
+
setNextVertex(vertex.from_pixel_coordinates)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def edge_shape_by_index(index)
|
|
66
|
+
edge_shape = EdgeShape.new start_point: [0, 0], end_point: [0, 0]
|
|
67
|
+
getChildEdge(edge_shape, withIndex: index)
|
|
68
|
+
edge_shape
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|