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
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
describe Joybox::Core::Sprite do
|
|
2
|
+
|
|
3
|
+
describe "Initialization" do
|
|
4
|
+
it "should initialize with file name" do
|
|
5
|
+
sprite = Sprite.new file_name: 'sprite.png', position: CGPointMake(100, 100)
|
|
6
|
+
sprite.should.not == nil
|
|
7
|
+
sprite.position.should == CGPointMake(100, 100)
|
|
8
|
+
sprite.contentSize.should.not == CGSizeMake(0, 0)
|
|
9
|
+
sprite.visible.should == true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should initialize with file name and rect" do
|
|
13
|
+
sprite = Sprite.new file_name: 'sprite.png', position: CGPointMake(100, 100), rect: CGRectMake(0, 0, 27, 40)
|
|
14
|
+
sprite.should.not == nil
|
|
15
|
+
sprite.position.should == CGPointMake(100, 100)
|
|
16
|
+
sprite.contentSize.should == CGSizeMake(27, 40)
|
|
17
|
+
sprite.visible.should == true
|
|
18
|
+
sprite.bounding_box.should == CGRectMake(86.5, 80, 27, 40)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should initialize with frame name" do
|
|
22
|
+
SpriteFrameCache.frames.add file_name: 'animation_frames.plist'
|
|
23
|
+
sprite = Sprite.new frame_name: 'bear1.png', position: CGPointMake(100, 100)
|
|
24
|
+
sprite.should.not == nil
|
|
25
|
+
sprite.position.should == CGPointMake(100, 100)
|
|
26
|
+
sprite.contentSize.should.not == CGSizeMake(0, 0)
|
|
27
|
+
sprite.visible.should == true
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should initialize with texture" do
|
|
31
|
+
sprite_batch = SpriteBatch.new file_name: 'sprite_sheet.png'
|
|
32
|
+
sprite = Sprite.new texture: sprite_batch.texture, position: CGPointMake(100, 100)
|
|
33
|
+
sprite.should.not == nil
|
|
34
|
+
sprite.position.should == CGPointMake(100, 100)
|
|
35
|
+
sprite.contentSize.should.not == CGSizeMake(0, 0)
|
|
36
|
+
sprite.visible.should == true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should initialize with texture and rect" do
|
|
40
|
+
sprite_batch = SpriteBatch.new file_name: 'sprite_sheet.png'
|
|
41
|
+
sprite = Sprite.new texture: sprite_batch.texture, position: CGPointMake(100, 100), rect: CGRectMake(0, 0, 16, 16)
|
|
42
|
+
sprite.should.not == nil
|
|
43
|
+
sprite.position.should == CGPointMake(100, 100)
|
|
44
|
+
sprite.contentSize.should == CGSizeMake(16, 16)
|
|
45
|
+
sprite.visible.should == true
|
|
46
|
+
sprite.bounding_box.should == CGRectMake(92, 92, 16, 16)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
describe "Flip" do
|
|
52
|
+
before do
|
|
53
|
+
@sprite = Sprite.new file_name: 'sprite.png', position: CGPointMake(100, 100)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should flip in the X axis" do
|
|
57
|
+
@sprite.flip x: true, y: false
|
|
58
|
+
@sprite.flipX.should == true
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should flip in the Y axis" do
|
|
62
|
+
@sprite.flip x: false, y: true
|
|
63
|
+
@sprite.flipY.should == true
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should flip in both axis" do
|
|
67
|
+
@sprite.flip x: true, y: true
|
|
68
|
+
@sprite.flipX.should == true
|
|
69
|
+
@sprite.flipX.should == true
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "Image Name" do
|
|
74
|
+
it "should change its image name" do
|
|
75
|
+
sprite = Sprite.new file_name: 'sprite.png', position: CGPointMake(100, 100)
|
|
76
|
+
first_texture = sprite.texture
|
|
77
|
+
sprite.file_name = 'sprite_sheet.png'
|
|
78
|
+
sprite.texture.should.not == first_texture
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should change its image name if it was initialized with frame name" do
|
|
82
|
+
SpriteFrameCache.frames.add file_name: 'animation_frames.plist'
|
|
83
|
+
sprite = Sprite.new frame_name: 'bear1.png', position: CGPointMake(100, 100)
|
|
84
|
+
sprite.file_name = 'sprite_sheet.png'
|
|
85
|
+
sprite.texture.should.not == nil
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should not change its image name if it was initialized with texture" do
|
|
89
|
+
sprite_batch = SpriteBatch.new file_name: 'sprite_sheet.png'
|
|
90
|
+
sprite = Sprite.new texture: sprite_batch.texture, position: CGPointMake(100, 100)
|
|
91
|
+
first_texture = sprite.texture
|
|
92
|
+
sprite.file_name = 'sprite_sheet.png'
|
|
93
|
+
sprite.texture.should == first_texture
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "Frame" do
|
|
98
|
+
it "should return if it is displaying a frame" do
|
|
99
|
+
SpriteFrameCache.frames.add file_name: 'animation_frames.plist'
|
|
100
|
+
sprite = Sprite.new frame_name: 'bear1.png', position: CGPointMake(100, 100)
|
|
101
|
+
|
|
102
|
+
sprite.displays_frame?(SpriteFrameCache.frames['bear1.png']).should == true
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should return its displayed frame" do
|
|
106
|
+
SpriteFrameCache.frames.add file_name: 'animation_frames.plist'
|
|
107
|
+
sprite = Sprite.new frame_name: 'bear1.png', position: CGPointMake(100, 100)
|
|
108
|
+
|
|
109
|
+
sprite.frame.should.not == nil
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should change its displayed frame" do
|
|
113
|
+
SpriteFrameCache.frames.add file_name: 'animation_frames.plist'
|
|
114
|
+
sprite = Sprite.new frame_name: 'bear1.png', position: CGPointMake(100, 100)
|
|
115
|
+
|
|
116
|
+
sprite.frame = SpriteFrameCache.frames['bear2.png']
|
|
117
|
+
sprite.displays_frame?(SpriteFrameCache.frames['bear2.png']).should == true
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
end
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
describe Joybox::Macros do
|
|
2
|
+
|
|
3
|
+
before do
|
|
4
|
+
@point_one = CGPointMake(100, 200)
|
|
5
|
+
@point_two = CGPointMake(300, 400)
|
|
6
|
+
@intersect_point_one = CGPointMake(100, 100)
|
|
7
|
+
@intersect_point_two = CGPointMake(400, 400)
|
|
8
|
+
@intersect_point_three = CGPointMake(100, 400)
|
|
9
|
+
@intersect_point_four = CGPointMake(400, 100)
|
|
10
|
+
@angle = 1
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
describe :jbp do
|
|
15
|
+
it "should get a new point" do
|
|
16
|
+
point = jbp(100, 200)
|
|
17
|
+
point.should == @point_one
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe :jbpNeg do
|
|
22
|
+
it "should get the oposite point" do
|
|
23
|
+
point = jbpNeg(@point_one)
|
|
24
|
+
point.should == CGPointMake(-100, -200)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe :jbpAdd do
|
|
29
|
+
it "should sum of two points" do
|
|
30
|
+
point = jbpAdd(@point_one, @point_two)
|
|
31
|
+
point.should == CGPointMake(400, 600)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe :jbpSub do
|
|
36
|
+
it "should substract of two points" do
|
|
37
|
+
point = jbpSub(@point_one, @point_two)
|
|
38
|
+
point.should == CGPointMake(-200, -200)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe :jbpMult do
|
|
43
|
+
it "should multiply point for a factor" do
|
|
44
|
+
point = jbpMult(@point_one, 0.5)
|
|
45
|
+
point.should == CGPointMake(50, 100)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe :jbpMidPoint do
|
|
50
|
+
it "should get the middle point between two points" do
|
|
51
|
+
point = jbpMidPoint(@point_one, @point_two)
|
|
52
|
+
point.should == CGPointMake(200, 300)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe :jbpDot do
|
|
57
|
+
it "should get the product of two points" do
|
|
58
|
+
product = jbpDot(@point_one, @point_two)
|
|
59
|
+
product.should == 110000
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe :jbpCross do
|
|
64
|
+
it "should get the cross product of two points" do
|
|
65
|
+
cross_product = jbpCross(@point_one, @point_two)
|
|
66
|
+
cross_product.should == -20000
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe :jbpPerp do
|
|
71
|
+
it "should get the perpendicular of a point, rotated 90º counter-clockwise" do
|
|
72
|
+
point = jbpPerp(@point_one)
|
|
73
|
+
point.should == CGPointMake(-200, 100)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe :jbpRPerp do
|
|
78
|
+
it "should get the perpendicular of a point, rotated 90º clockwise" do
|
|
79
|
+
point = jbpRPerp(@point_one)
|
|
80
|
+
point.should == CGPointMake(200, -100)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe :jbpProject do
|
|
85
|
+
it "should get the projection of the first point over the second point" do
|
|
86
|
+
point = jbpProject(@point_one, @point_two)
|
|
87
|
+
point.x.should.be.close 132, 0.1
|
|
88
|
+
point.y.should.be.close 176, 0.1
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe :jbpRotate do
|
|
93
|
+
it "should get the rotation of two points" do
|
|
94
|
+
point = jbpRotate(@point_one, @point_two)
|
|
95
|
+
point.should == CGPointMake(-50000, 100000)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe :jbpUnrotate do
|
|
100
|
+
it "should get the unrotation of two points" do
|
|
101
|
+
point = jbpUnrotate(@point_one, @point_two)
|
|
102
|
+
point.should == CGPointMake(110000, 20000)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe :jbpLengthSQ do
|
|
107
|
+
it "should get the square lenght of a point" do
|
|
108
|
+
lenght = jbpLengthSQ(@point_one)
|
|
109
|
+
lenght.should == 50000
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe :jbpDistanceSQ do
|
|
114
|
+
it "should get the square distance between two points" do
|
|
115
|
+
lenght = jbpDistanceSQ(@point_one, @point_two)
|
|
116
|
+
lenght.should == 80000
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
describe :jbpLength do
|
|
121
|
+
it "should get the lenght of a point" do
|
|
122
|
+
lenght = jbpLength(@point_one)
|
|
123
|
+
lenght.should.be.close 223.6067, 0.0001
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe :jbpDistance do
|
|
128
|
+
it "should get the distance between two points" do
|
|
129
|
+
lenght = jbpDistance(@point_one, @point_two)
|
|
130
|
+
lenght.should.be.close 282.8427, 0.0001
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe :jbpNormalize do
|
|
135
|
+
it "should get a point normalized" do
|
|
136
|
+
point = jbpNormalize(@point_one)
|
|
137
|
+
point.should.be.close CGPointMake(0.4472, 0.8944), 0.0001
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
describe :jpbForAngle do
|
|
142
|
+
it "should get the normalized point of an angle in radians" do
|
|
143
|
+
point = jbpForAngle(@angle)
|
|
144
|
+
point.should.be.close CGPointMake(0.5403, 0.8414), 0.0001
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
describe :jbpToAngle do
|
|
149
|
+
it "should get an angle in radians of a point" do
|
|
150
|
+
angle = jbpToAngle(@point_one)
|
|
151
|
+
angle.should.be.close 1.1071, 0.0001
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
describe :jbpClamp do
|
|
156
|
+
it "should get a point between from and to" do
|
|
157
|
+
point = jbpClamp(@point_one, CGPointMake(0, 0), @point_two)
|
|
158
|
+
point.should == @point_one
|
|
159
|
+
|
|
160
|
+
point = jbpClamp(@point_two, @point_one, @point_two)
|
|
161
|
+
point.should == @point_two
|
|
162
|
+
|
|
163
|
+
point = jbpClamp(@point_two, @point_one, @point_one)
|
|
164
|
+
point.should == @point_one
|
|
165
|
+
|
|
166
|
+
point = jbpClamp(@point_one, @point_two, @point_two)
|
|
167
|
+
point.should == @point_two
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
describe :jbpFromSize do
|
|
172
|
+
it "should get a point from a size" do
|
|
173
|
+
point = jbpFromSize(CGSizeMake(100, 200))
|
|
174
|
+
point.should == @point_one
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
describe :jbpCompOp do
|
|
179
|
+
it "should run a math operation function on each point component" do
|
|
180
|
+
point = jbpCompOp(@point_one) { |n| n * 10 }
|
|
181
|
+
point.should == CGPointMake(1000, 2000)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
describe :jbpLerp do
|
|
186
|
+
it "should get the linear interpolation between two points" do
|
|
187
|
+
point = jbpLerp(@point_one, @point_two, 0.5)
|
|
188
|
+
point.should == CGPointMake(200, 300)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
describe :jbpFuzzyEqual do
|
|
193
|
+
it "should get if two points are equal with some degree of variance" do
|
|
194
|
+
equal = jbpFuzzyEqual(@point_one, @point_two, 100)
|
|
195
|
+
equal.should == false
|
|
196
|
+
|
|
197
|
+
equal = jbpFuzzyEqual(@point_one, @point_one, 0)
|
|
198
|
+
equal.should == true
|
|
199
|
+
|
|
200
|
+
equal = jbpFuzzyEqual(@point_one, @point_two, 200)
|
|
201
|
+
equal.should == true
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
describe :jbpCompMult do
|
|
206
|
+
it "should get the product between two points" do
|
|
207
|
+
point = jbpCompMult(@point_one, @point_two)
|
|
208
|
+
point.should == CGPointMake(30000, 80000)
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
describe :jbpAngleSigned do
|
|
213
|
+
it "should get the signed angle between two points" do
|
|
214
|
+
angle = jbpAngleSigned(@point_one, @point_two)
|
|
215
|
+
angle.should.be.close -0.1798, 0.0001
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
describe :jbpAngle do
|
|
220
|
+
it "should get the angle between two points" do
|
|
221
|
+
angle = jbpAngle(@point_one, @point_two)
|
|
222
|
+
angle.should.be.close 0.1798, 0.0001
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
describe :jbpRotateByAngle do
|
|
227
|
+
it "should get a point rotated counter-clockwise by the angle around a pivot point" do
|
|
228
|
+
point = jbpRotateByAngle(@point_one, @point_two, @angle)
|
|
229
|
+
point.should.be.close CGPointMake(360.2337, 123.6453), 0.0001
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
describe :jbpLineIntersect do
|
|
234
|
+
it "should get if two lines intersect" do
|
|
235
|
+
intersect = jbpLineIntersect(@point_one, @point_two, @point_two, @point_one)
|
|
236
|
+
intersect.should == { s: 0, t: 0 }
|
|
237
|
+
|
|
238
|
+
intersect = jbpLineIntersect(@point_two, @point_two, @point_two, @point_two)
|
|
239
|
+
intersect.should == nil
|
|
240
|
+
|
|
241
|
+
intersect = jbpLineIntersect(@intersect_point_one,
|
|
242
|
+
@intersect_point_two,
|
|
243
|
+
@intersect_point_three,
|
|
244
|
+
@intersect_point_four)
|
|
245
|
+
intersect.should == { s: 0.5, t: 0.5 }
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
describe :jbpSegmentIntersect do
|
|
250
|
+
it "should get it two segments intersect" do
|
|
251
|
+
intersect = jbpSegmentIntersect(@point_one, @point_two, @point_two, @point_one)
|
|
252
|
+
intersect.should == true
|
|
253
|
+
|
|
254
|
+
intersect = jbpSegmentIntersect(@point_two, @point_two, @point_two, @point_two)
|
|
255
|
+
intersect.should == false
|
|
256
|
+
|
|
257
|
+
intersect = jbpSegmentIntersect(@intersect_point_one,
|
|
258
|
+
@intersect_point_two,
|
|
259
|
+
@intersect_point_three,
|
|
260
|
+
@intersect_point_four)
|
|
261
|
+
intersect.should == true
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
describe :jbpIntersectPoint do
|
|
266
|
+
it "should get the intersection point between two lines" do
|
|
267
|
+
point = jbpIntersectPoint(@point_one, @point_two, @point_two, @point_one)
|
|
268
|
+
point.should == CGPointMake(100, 200)
|
|
269
|
+
|
|
270
|
+
point = jbpIntersectPoint(@point_two, @point_two, @point_two, @point_two)
|
|
271
|
+
point.should == CGPointMake(0, 0)
|
|
272
|
+
|
|
273
|
+
point = jbpIntersectPoint(@intersect_point_one,
|
|
274
|
+
@intersect_point_two,
|
|
275
|
+
@intersect_point_three,
|
|
276
|
+
@intersect_point_four)
|
|
277
|
+
point.should == CGPointMake(250, 250)
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
describe Joybox::Physics::AABB do
|
|
2
|
+
|
|
3
|
+
it "should convert between coordinate systems" do
|
|
4
|
+
aabb = AABB.new
|
|
5
|
+
|
|
6
|
+
aabb.lower_bound = [32, 32]
|
|
7
|
+
aabb.upper_bound = [32, 32]
|
|
8
|
+
aabb.metric_upper_bound.should == CGPointMake(1, 1)
|
|
9
|
+
aabb.metric_lower_bound.should == CGPointMake(1, 1)
|
|
10
|
+
|
|
11
|
+
aabb.metric_upper_bound = [2, 2]
|
|
12
|
+
aabb.metric_lower_bound = [2, 2]
|
|
13
|
+
aabb.lower_bound.should == CGPointMake(64, 64)
|
|
14
|
+
aabb.upper_bound.should == CGPointMake(64, 64)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
describe Joybox::Physics::Body do
|
|
2
|
+
before do
|
|
3
|
+
@world = World.new gravity: [0, -9.8]
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
describe "Initialization" do
|
|
7
|
+
it "should initialize with position" do
|
|
8
|
+
body = @world.new_body position:[100, 100]
|
|
9
|
+
body.should.not == nil
|
|
10
|
+
body.position.should == CGPointMake(100, 100)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should initialize with position and type" do
|
|
14
|
+
static_body = @world.new_body position: [100, 100]
|
|
15
|
+
static_body.should.not == nil
|
|
16
|
+
static_body.position.should == CGPointMake(100, 100)
|
|
17
|
+
|
|
18
|
+
dynamic_body = @world.new_body position: [100, 100], type: Body::Dynamic
|
|
19
|
+
dynamic_body.should.not == nil
|
|
20
|
+
dynamic_body.position.should == CGPointMake(100, 100)
|
|
21
|
+
|
|
22
|
+
kinematic_body = @world.new_body position: [100, 100], type: Body::Kinematic
|
|
23
|
+
kinematic_body.should.not == nil
|
|
24
|
+
kinematic_body.position.should == CGPointMake(100, 100)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should initialize with position, type and fixture" do
|
|
28
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
29
|
+
edge_fixture start_point: [0, 480],
|
|
30
|
+
end_point: [320, 480],
|
|
31
|
+
friction: 1,
|
|
32
|
+
restitution: 2,
|
|
33
|
+
density: 3,
|
|
34
|
+
is_sensor: true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
body.should.not == nil
|
|
38
|
+
body.position.should == CGPointMake(100, 100)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should change its position" do
|
|
43
|
+
static_body = @world.new_body position: [100, 100] do
|
|
44
|
+
polygon_fixture box: [16, 16]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
dynamic_body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
48
|
+
polygon_fixture box: [16, 16]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
kinematic_body = @world.new_body position: [100, 100], type: Body::Kinematic do
|
|
52
|
+
polygon_fixture box: [16, 16]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
static_body.position.should == CGPointMake(100, 100)
|
|
56
|
+
dynamic_body.position.should == CGPointMake(100, 100)
|
|
57
|
+
kinematic_body.position.should == CGPointMake(100, 100)
|
|
58
|
+
|
|
59
|
+
@world.step delta: 10
|
|
60
|
+
|
|
61
|
+
static_body.position = [200, 200]
|
|
62
|
+
static_body.position.should == CGPointMake(200, 200)
|
|
63
|
+
dynamic_body.position = [200, 200]
|
|
64
|
+
dynamic_body.position.should.be.close CGPointMake(200, 200), 0.01
|
|
65
|
+
kinematic_body.position = [200, 200]
|
|
66
|
+
kinematic_body.position.should == CGPointMake(200, 200)
|
|
67
|
+
|
|
68
|
+
@world.step delta: 10
|
|
69
|
+
|
|
70
|
+
static_body.position.should == CGPointMake(200, 200)
|
|
71
|
+
dynamic_body.position.should.be.close CGPointMake(200, 198.81), 0.01
|
|
72
|
+
kinematic_body.position.should == CGPointMake(200, 200)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "should change its angle" do
|
|
76
|
+
static_body = @world.new_body position: [100, 100] do
|
|
77
|
+
polygon_fixture box: [16, 16]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
dynamic_body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
81
|
+
polygon_fixture box: [16, 16]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
kinematic_body = @world.new_body position: [100, 100], type: Body::Kinematic do
|
|
85
|
+
polygon_fixture box: [16, 16]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
static_body.angle.should == 0
|
|
89
|
+
dynamic_body.angle.should == 0
|
|
90
|
+
kinematic_body.angle.should == 0
|
|
91
|
+
|
|
92
|
+
@world.step delta: 10
|
|
93
|
+
|
|
94
|
+
static_body.angle = 10
|
|
95
|
+
static_body.angle.should.be.close 10, 1
|
|
96
|
+
dynamic_body.angle = 10
|
|
97
|
+
dynamic_body.angle.should.be.close 10, 1
|
|
98
|
+
kinematic_body.angle = 10
|
|
99
|
+
kinematic_body.angle.should.be.close 10, 1
|
|
100
|
+
|
|
101
|
+
@world.step delta: 10
|
|
102
|
+
|
|
103
|
+
static_body.angle.should.be.close 10, 1
|
|
104
|
+
dynamic_body.angle.should.be.close 10, 1
|
|
105
|
+
kinematic_body.angle.should.be.close 10, 1
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should have mass data" do
|
|
109
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
110
|
+
polygon_fixture box: [16, 16]
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
body.mass_data.mass.should == 1.0
|
|
114
|
+
body.mass_data.center.should == CGPointMake(0, 0)
|
|
115
|
+
body.mass_data.rotational_inertia == 0.0
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should change its mass data" do
|
|
119
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
120
|
+
polygon_fixture box: [16, 16]
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
mass_data = MassData.new
|
|
124
|
+
mass_data.mass = 2.0
|
|
125
|
+
mass_data.center = [0.1, 0.1]
|
|
126
|
+
mass_data.rotational_inertia = 1.0
|
|
127
|
+
|
|
128
|
+
body.mass_data = mass_data
|
|
129
|
+
|
|
130
|
+
body.mass_data.mass.should == 2.0
|
|
131
|
+
body.mass_data.center.should.be.close CGPointMake(0.1, 0.1), 0.1
|
|
132
|
+
body.mass_data.rotational_inertia == 1.0
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "should change its linear velocity" do
|
|
136
|
+
static_body = @world.new_body position: [100, 100] do
|
|
137
|
+
polygon_fixture box: [16, 16]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
dynamic_body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
141
|
+
polygon_fixture box: [16, 16]
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
kinematic_body = @world.new_body position: [100, 100], type: Body::Kinematic do
|
|
145
|
+
polygon_fixture box: [16, 16]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
static_body.position.should == CGPointMake(100, 100)
|
|
149
|
+
dynamic_body.position.should == CGPointMake(100, 100)
|
|
150
|
+
kinematic_body.position.should == CGPointMake(100, 100)
|
|
151
|
+
|
|
152
|
+
static_body.linear_velocity = [10, 10]
|
|
153
|
+
static_body.linear_velocity.should == CGPointMake(0, 0)
|
|
154
|
+
dynamic_body.linear_velocity = [10, 10]
|
|
155
|
+
dynamic_body.linear_velocity.should == CGPointMake(10, 10)
|
|
156
|
+
kinematic_body.linear_velocity = [10, 10]
|
|
157
|
+
kinematic_body.linear_velocity.should == CGPointMake(10, 10)
|
|
158
|
+
|
|
159
|
+
@world.step delta: 10
|
|
160
|
+
|
|
161
|
+
static_body.position.should == CGPointMake(100, 100)
|
|
162
|
+
dynamic_body.position.should.be.close CGPointMake(164, 100), 0.01
|
|
163
|
+
kinematic_body.position.should.be.close CGPointMake(145.254, 145.254), 0.01
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it "should change its angular velocity" do
|
|
167
|
+
static_body = @world.new_body position: [100, 100] do
|
|
168
|
+
polygon_fixture box: [16, 16]
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
dynamic_body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
172
|
+
polygon_fixture box: [16, 16]
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
kinematic_body = @world.new_body position: [100, 100], type: Body::Kinematic do
|
|
176
|
+
polygon_fixture box: [16, 16]
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
static_body.position.should == CGPointMake(100, 100)
|
|
180
|
+
dynamic_body.position.should == CGPointMake(100, 100)
|
|
181
|
+
kinematic_body.position.should == CGPointMake(100, 100)
|
|
182
|
+
|
|
183
|
+
static_body.angular_velocity = 10.0
|
|
184
|
+
static_body.angular_velocity.should == 0
|
|
185
|
+
dynamic_body.angular_velocity = 10.0
|
|
186
|
+
dynamic_body.angular_velocity.should == 10.0
|
|
187
|
+
kinematic_body.angular_velocity = 10.0
|
|
188
|
+
kinematic_body.angular_velocity.should == 10
|
|
189
|
+
|
|
190
|
+
@world.step delta: 10
|
|
191
|
+
|
|
192
|
+
static_body.position.should == CGPointMake(100, 100)
|
|
193
|
+
dynamic_body.position.should.be.close CGPointMake(88.38, 36), 0.01
|
|
194
|
+
kinematic_body.position.should == CGPointMake(100, 100)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it "should save a value using a key" do
|
|
198
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic
|
|
199
|
+
body[:message] = 'Body Information'
|
|
200
|
+
body[:message].should == 'Body Information'
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it "should create new fixtures" do
|
|
204
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic
|
|
205
|
+
|
|
206
|
+
body.new_fixture do
|
|
207
|
+
polygon_fixture box: [16, 16]
|
|
208
|
+
polygon_fixture box: [16, 16]
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
body.fixtures.size.should == 2
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it "should destroy fixtures" do
|
|
215
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic
|
|
216
|
+
|
|
217
|
+
body.new_fixture do
|
|
218
|
+
polygon_fixture box: [16, 16]
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
body.destroy_fixture(body.fixtures[0])
|
|
222
|
+
body.fixtures.size.should == 0
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it "should convert from local point to world point" do
|
|
226
|
+
body = @world.new_body position: [100, 100]
|
|
227
|
+
body.to_world_point([0, 0]).should == CGPointMake(100, 100)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "should convert from local vector to world vector" do
|
|
231
|
+
body = @world.new_body position: [100, 100]
|
|
232
|
+
body.to_world_vector([0, 0]).should == CGPointMake(0, 0)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
it "should convert from world point to local point" do
|
|
236
|
+
body = @world.new_body position: [100, 100]
|
|
237
|
+
body.to_local_point([0, 0]).should == CGPointMake(-100, -100)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
it "should convert from world vector to local vector" do
|
|
241
|
+
body = @world.new_body position: [100, 100]
|
|
242
|
+
body.to_local_vector([0, 0]).should == CGPointMake(0, 0)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it "should return the linear velocity at world point" do
|
|
246
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic
|
|
247
|
+
body.linear_velocity = [10, 10]
|
|
248
|
+
body.linear_velocity_at(world_point: [100, 100]).should == CGPointMake(10, 10)
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
it "should return the linear velocity at local point" do
|
|
252
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic
|
|
253
|
+
body.linear_velocity = [10, 10]
|
|
254
|
+
body.linear_velocity_at(local_point: [0, 0]).should == CGPointMake(10, 10)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it "should react to force applied as impulse" do
|
|
258
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
259
|
+
polygon_fixture box: [16, 16]
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
body.position.should == CGPointMake(100, 100)
|
|
263
|
+
body.apply_force force: [1000, 1000]
|
|
264
|
+
|
|
265
|
+
@world.step delta: 10
|
|
266
|
+
body.position.should.be.close CGPointMake(127.135, 42.037), 0.001
|
|
267
|
+
|
|
268
|
+
@world.step delta: 100
|
|
269
|
+
body.position.should.be.close CGPointMake(127.141, -21.962), 0.001
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
it "should react to force applied instantaneously" do
|
|
273
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
274
|
+
polygon_fixture box: [16, 16]
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
body.position.should == CGPointMake(100, 100)
|
|
278
|
+
body.apply_force force: [1000, 1000], as_impulse: false
|
|
279
|
+
|
|
280
|
+
@world.step delta: 10
|
|
281
|
+
body.position.should.be.close CGPointMake(152.765, 136.218), 0.001
|
|
282
|
+
|
|
283
|
+
@world.step delta: 100
|
|
284
|
+
body.position.should.be.close CGPointMake(152.776, 72.218), 0.001
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
it "should react to torque applied as impulse" do
|
|
288
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
289
|
+
polygon_fixture box: [16, 16],
|
|
290
|
+
density: 20
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
body.position.should == CGPointMake(100, 100)
|
|
294
|
+
body.apply_torque torque: 1000
|
|
295
|
+
|
|
296
|
+
@world.step delta: 10
|
|
297
|
+
body.position.should.be.close CGPointMake(100.0, 36.0), 0.001
|
|
298
|
+
|
|
299
|
+
@world.step delta: 100
|
|
300
|
+
body.position.should.be.close CGPointMake(100.0, -28.0), 0.001
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
it "should react to torque applied instantaneously" do
|
|
304
|
+
body = @world.new_body position: [100, 100], type: Body::Dynamic do
|
|
305
|
+
polygon_fixture box: [16, 16],
|
|
306
|
+
density: 1
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
body.position.should == CGPointMake(100, 100)
|
|
310
|
+
body.apply_torque torque: 1000, as_impulse: false
|
|
311
|
+
|
|
312
|
+
@world.step delta: 10
|
|
313
|
+
body.position.should.be.close CGPointMake(100.0, 36.0), 0.001
|
|
314
|
+
|
|
315
|
+
@world.step delta: 100
|
|
316
|
+
body.position.should.be.close CGPointMake(100.0, -28.0), 0.001
|
|
317
|
+
end
|
|
318
|
+
end
|