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,47 @@
|
|
|
1
|
+
module Joybox
|
|
2
|
+
module Core
|
|
3
|
+
|
|
4
|
+
class LayerColor < CCLayerColor
|
|
5
|
+
|
|
6
|
+
def self.scene
|
|
7
|
+
define_singleton_method(:scene) do
|
|
8
|
+
scene = CCScene.new
|
|
9
|
+
menu_layer = self.new
|
|
10
|
+
scene << menu_layer
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def onEnter
|
|
15
|
+
super
|
|
16
|
+
on_enter if defined? (on_enter)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def onExit
|
|
20
|
+
super
|
|
21
|
+
on_exit if defined? (on_exit)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.defaults
|
|
25
|
+
{
|
|
26
|
+
opacity: 255,
|
|
27
|
+
width: Screen.width,
|
|
28
|
+
height: Screen.height
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.new(options = {})
|
|
33
|
+
options = options.nil? ? defaults : defaults.merge!(options)
|
|
34
|
+
options[:color] << options[:opacity]
|
|
35
|
+
|
|
36
|
+
layer = CCLayerColor.layerWithColor(options[:color],
|
|
37
|
+
width: options[:width],
|
|
38
|
+
height: options[:height])
|
|
39
|
+
|
|
40
|
+
layer.position = options[:position] if options.has_key? :position
|
|
41
|
+
layer
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
data/motion/joybox/core/node.rb
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
class CCNode
|
|
2
2
|
|
|
3
3
|
alias_method :add_child, :addChild
|
|
4
|
+
alias_method :run_action, :runAction
|
|
5
|
+
alias_method :stop_action, :stopAction
|
|
6
|
+
alias_method :stop_all_actions, :stopAllActions
|
|
7
|
+
alias_method :number_of_running_actions, :numberOfRunningActions
|
|
4
8
|
|
|
5
9
|
def << (node)
|
|
6
|
-
|
|
7
10
|
self.addChild(node)
|
|
8
11
|
end
|
|
9
12
|
|
|
10
13
|
def self.inherited(base)
|
|
11
|
-
|
|
12
14
|
base.send(:include, Joybox)
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
def add_childs(*nodes)
|
|
17
|
-
|
|
17
|
+
def add_children(*nodes)
|
|
18
18
|
nodes.each do |node|
|
|
19
|
-
|
|
20
19
|
self.addChild(node)
|
|
21
|
-
|
|
22
20
|
end
|
|
23
|
-
|
|
24
21
|
end
|
|
25
22
|
|
|
23
|
+
def schedule_update(&block)
|
|
24
|
+
@schedule_update_block = block if block_given?
|
|
25
|
+
scheduleUpdate
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def update(dt)
|
|
29
|
+
@schedule_update_block.call(dt) if @schedule_update_block
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def running_actions?
|
|
33
|
+
self.number_of_running_actions > 0
|
|
34
|
+
end
|
|
35
|
+
|
|
26
36
|
end
|
data/motion/joybox/core/scene.rb
CHANGED
|
@@ -3,27 +3,31 @@ module Joybox
|
|
|
3
3
|
|
|
4
4
|
class Sprite < CCSprite
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
extend Joybox::Common::Initialize
|
|
7
7
|
|
|
8
|
-
alias_method :run_action, :runAction
|
|
9
|
-
alias_method :stop_action, :stopAction
|
|
10
|
-
alias_method :stop_all_actions, :stopAllActions
|
|
11
8
|
alias_method :bounding_box, :boundingBox
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
alias_method :frame, :displayFrame
|
|
10
|
+
alias_method :frame=, :setDisplayFrame
|
|
11
|
+
attr_accessor :properties
|
|
12
|
+
|
|
13
|
+
def initialize(options = {})
|
|
14
|
+
initialize_with_file_name(options) if options.has_key? (:file_name)
|
|
15
|
+
initialize_with_texture(options) if options.has_key? (:texture)
|
|
16
|
+
initialize_with_frame_name(options) if options.has_key? (:frame_name)
|
|
17
|
+
initialize_with_frame(options) if options.has_key? (:frame)
|
|
18
|
+
initialize_with_cg_image(options) if options.has_key?(:cg_image) && options.has_key?(:key)
|
|
19
|
+
self.position = options.delete(:position) if options.has_key? (:position)
|
|
20
|
+
self.properties = options
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def file_name=(file_name)
|
|
24
24
|
texture = CCTextureCache.sharedTextureCache.addImage(file_name)
|
|
25
25
|
self.setTexture(texture)
|
|
26
26
|
end
|
|
27
|
+
|
|
28
|
+
def displays_frame?(frame)
|
|
29
|
+
isFrameDisplayed(frame)
|
|
30
|
+
end
|
|
27
31
|
|
|
28
32
|
# Review this in another version, because I dont still quite convinced
|
|
29
33
|
# that this is the correct approach. The alternative is two methods
|
|
@@ -49,25 +53,39 @@ module Joybox
|
|
|
49
53
|
super
|
|
50
54
|
end
|
|
51
55
|
|
|
56
|
+
def [](key)
|
|
57
|
+
@properties[key]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def []=(key, value)
|
|
61
|
+
@properties[key] = value
|
|
62
|
+
end
|
|
63
|
+
|
|
52
64
|
private
|
|
53
65
|
|
|
54
|
-
def
|
|
55
|
-
|
|
66
|
+
def initialize_with_file_name(options = {})
|
|
67
|
+
initWithFile(options.delete(:file_name)) if options[:rect].nil?
|
|
68
|
+
initWithFile(options.delete(:file_name), rect: options.delete(:rect)) unless options[:rect].nil?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def initialize_with_texture(options = {})
|
|
72
|
+
initWithTexture(options.delete(:texture)) if options[:rect].nil?
|
|
73
|
+
initWithTexture(options.delete(:texture), rect: options.delete(:rect)) unless options[:rect].nil?
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def initialize_with_frame_name(options = {})
|
|
77
|
+
initWithSpriteFrameName(options.delete(:frame_name))
|
|
56
78
|
end
|
|
57
79
|
|
|
58
|
-
def
|
|
59
|
-
|
|
60
|
-
spriteWithTexture(options[:texture], rect: options[:rect])
|
|
61
|
-
else
|
|
62
|
-
spriteWithTexture(options:[:texture])
|
|
63
|
-
end
|
|
80
|
+
def initialize_with_frame(options = {})
|
|
81
|
+
initWithSpriteFrame(options.delete(:frame))
|
|
64
82
|
end
|
|
65
83
|
|
|
66
|
-
def
|
|
67
|
-
|
|
84
|
+
def initialize_with_cg_image(options = {})
|
|
85
|
+
initWithCGImage(options.delete(:cg_image).CGImage, key: options.delete(:key))
|
|
68
86
|
end
|
|
69
87
|
|
|
70
88
|
end
|
|
71
89
|
|
|
72
90
|
end
|
|
73
|
-
end
|
|
91
|
+
end
|
|
@@ -3,19 +3,28 @@ module Joybox
|
|
|
3
3
|
|
|
4
4
|
class SpriteBatch < CCSpriteBatchNode
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
extend Joybox::Common::Initialize
|
|
7
|
+
|
|
8
|
+
def defaults
|
|
7
9
|
{
|
|
8
|
-
capacity:
|
|
10
|
+
capacity: 29
|
|
9
11
|
}
|
|
10
12
|
end
|
|
11
13
|
|
|
14
|
+
def initialize(options = {})
|
|
15
|
+
options = options.nil? ? defaults : defaults.merge!(options)
|
|
16
|
+
initialize_with_file_name(options) if options.has_key? (:file_name)
|
|
17
|
+
initialize_with_texture(options) if options.has_key? (:texture)
|
|
18
|
+
end
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
private
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
def initialize_with_file_name(options = {})
|
|
23
|
+
initWithFile(options[:file_name], capacity: options[:capacity])
|
|
24
|
+
end
|
|
16
25
|
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
def initialize_with_texture(options = {})
|
|
27
|
+
initWithTexture(options[:texture], capacity: options[:capacity])
|
|
19
28
|
end
|
|
20
29
|
|
|
21
30
|
end
|
|
@@ -2,146 +2,97 @@ module Joybox
|
|
|
2
2
|
module Core
|
|
3
3
|
|
|
4
4
|
class SpriteFrameCache < CCSpriteFrameCache
|
|
5
|
-
|
|
6
|
-
# Class Method Alias Method
|
|
7
5
|
class << self
|
|
8
|
-
|
|
9
6
|
alias_method :frames, :sharedSpriteFrameCache
|
|
10
7
|
alias_method :purge, :purgeSharedSpriteFrameCache
|
|
11
|
-
|
|
12
8
|
end
|
|
13
|
-
|
|
14
9
|
end
|
|
15
10
|
|
|
16
11
|
end
|
|
17
12
|
end
|
|
18
13
|
|
|
19
|
-
# Open the CCSpriteFrameCache Class because of the singleton pattern
|
|
20
14
|
class CCSpriteFrameCache
|
|
21
15
|
|
|
22
16
|
alias_method :remove_all, :removeSpriteFrames
|
|
23
17
|
alias_method :remove_unused_frames, :removeUnusedSpriteFrames
|
|
24
18
|
|
|
25
|
-
|
|
26
19
|
def add(options = {})
|
|
27
|
-
|
|
28
20
|
add_frame_with_name(options) if options.has_key? (:name)
|
|
29
21
|
add_frames_with_file(options) if options.has_key? (:file_name)
|
|
30
|
-
|
|
31
|
-
# Check if it should fail silently or crash if any of the options
|
|
32
|
-
# above are sended
|
|
33
22
|
end
|
|
34
23
|
|
|
35
|
-
|
|
36
24
|
def add_frame_with_name(options = {})
|
|
37
|
-
|
|
38
|
-
if options.has_key? (:frame)
|
|
39
|
-
|
|
40
|
-
addSpriteFrame(options[:frame], name: options[:name])
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Check if it should fail silently or crash if any of the options
|
|
44
|
-
# above are sended
|
|
25
|
+
addSpriteFrame(options[:frame], name: options[:name]) if options.has_key? (:frame)
|
|
45
26
|
end
|
|
46
27
|
|
|
47
|
-
|
|
48
28
|
def add_frames_with_file(options = {})
|
|
49
|
-
|
|
50
29
|
if options.has_key? (:texture)
|
|
51
|
-
|
|
52
30
|
addSpriteFramesWithFile(options[:file_name], texture: options[:texture])
|
|
53
|
-
|
|
54
31
|
elsif options.has_key? (:texture_file_name)
|
|
55
|
-
|
|
56
32
|
addSpriteFramesWithFile(options[:file_name], textureFilename: options[:texture_file_name])
|
|
57
33
|
else
|
|
58
|
-
|
|
59
34
|
addSpriteFramesWithFile(options[:file_name])
|
|
60
35
|
end
|
|
61
|
-
|
|
62
36
|
end
|
|
63
37
|
|
|
64
|
-
|
|
65
38
|
def remove(options = {})
|
|
66
|
-
|
|
67
39
|
remove_frame_by_name(options) if options.has_key? (:name)
|
|
68
40
|
remove_frame_from_file(options) if options.has_key? (:file_name)
|
|
69
41
|
remove_frame_from_texture(options) if options.has_key? (:texture)
|
|
70
|
-
|
|
71
|
-
# Check if it should fail silently or crash if any of the options
|
|
72
|
-
# above are sended
|
|
73
42
|
end
|
|
74
43
|
|
|
75
|
-
|
|
76
44
|
def remove_frame_by_name(options = {})
|
|
77
|
-
|
|
78
45
|
removeSpriteFrameByName(options[:name])
|
|
79
46
|
end
|
|
80
47
|
|
|
81
|
-
|
|
82
48
|
def remove_frame_from_file(options = {})
|
|
83
|
-
|
|
84
49
|
removeSpriteFramesFromFile(options[:file_name])
|
|
85
50
|
end
|
|
86
51
|
|
|
87
|
-
|
|
88
52
|
def remove_frame_from_texture(options = {})
|
|
89
|
-
|
|
90
53
|
removeSpriteFramesFromTexture(options[:texture])
|
|
91
54
|
end
|
|
92
55
|
|
|
93
|
-
|
|
94
56
|
def [](name)
|
|
95
|
-
|
|
96
57
|
spriteFrameByName(name)
|
|
97
58
|
end
|
|
98
59
|
|
|
99
|
-
|
|
100
60
|
def []=(name, frame)
|
|
101
|
-
|
|
102
61
|
addSpriteFrame(frame, name: name)
|
|
103
62
|
end
|
|
104
63
|
|
|
105
|
-
|
|
106
64
|
def default_where
|
|
107
65
|
{
|
|
108
|
-
from:
|
|
66
|
+
from: 1,
|
|
109
67
|
to: nil
|
|
110
68
|
}
|
|
111
69
|
end
|
|
112
70
|
|
|
113
|
-
|
|
114
71
|
def where(options = {})
|
|
115
|
-
|
|
116
72
|
options = options.nil? ? default_where : default_where.merge!(options)
|
|
117
|
-
|
|
118
73
|
frame_prefix = options[:prefix]
|
|
119
74
|
frame_suffix = options[:suffix]
|
|
120
75
|
|
|
121
76
|
frames = Array.new
|
|
122
77
|
|
|
123
|
-
|
|
78
|
+
frame_order = options[:order]
|
|
79
|
+
from_frame = frame_order ? frame_order.pop : options[:from]
|
|
124
80
|
to_frame = options[:to]
|
|
125
81
|
|
|
126
|
-
|
|
127
82
|
frame = nil
|
|
128
|
-
|
|
83
|
+
|
|
129
84
|
# Yukihiro Matsumoto recomends using loop instead of while or until statements
|
|
130
85
|
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/6745
|
|
131
|
-
loop do
|
|
132
|
-
|
|
86
|
+
loop do
|
|
133
87
|
frame_name = "#{frame_prefix}#{from_frame}#{frame_suffix}"
|
|
134
|
-
|
|
135
88
|
frame = self[frame_name]
|
|
136
|
-
|
|
137
89
|
frames << frame unless frame.nil?
|
|
138
90
|
|
|
139
|
-
from_frame = from_frame + 1
|
|
140
|
-
|
|
91
|
+
from_frame = frame_order ? frame_order.pop : (from_frame + 1)
|
|
141
92
|
break if frame.nil? or (from_frame > to_frame unless to_frame.nil?)
|
|
142
|
-
end
|
|
93
|
+
end
|
|
143
94
|
|
|
144
95
|
frames
|
|
145
96
|
end
|
|
146
97
|
|
|
147
|
-
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Joybox
|
|
2
|
+
module Debug
|
|
3
|
+
module Physics
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
attr_accessor :modes
|
|
7
|
+
attr_accessor :world
|
|
8
|
+
attr_accessor :draw
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def draw
|
|
12
|
+
super
|
|
13
|
+
initialize_physics_drawing if @world_symbol.nil?
|
|
14
|
+
draw_physics unless @world_symbol.nil?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize_physics_drawing
|
|
18
|
+
@world_symbol = self.instance_variables.find do |symbol|
|
|
19
|
+
instance_variable_get(symbol).class == Joybox::Physics::World
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
unless @world_symbol.nil?
|
|
23
|
+
@physics_draw = PhysicsDraw.new(Joybox::Debug::Physics.modes)
|
|
24
|
+
instance_variable_get(@world_symbol).setDebugDraw(@physics_draw.draw)
|
|
25
|
+
Joybox::Debug::Physics.world = instance_variable_get(@world_symbol)
|
|
26
|
+
Joybox::Debug::Physics.draw = @physics_draw
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def draw_physics
|
|
31
|
+
ccGLEnableVertexAttribs(KCCVertexAttribFlag_Position)
|
|
32
|
+
kmGLPushMatrix
|
|
33
|
+
instance_variable_get(@world_symbol).drawDebugData
|
|
34
|
+
kmGLPopMatrix
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
module Joybox
|
|
2
|
+
module Debug
|
|
3
|
+
class PhysicsDraw
|
|
4
|
+
|
|
5
|
+
attr_accessor :draw
|
|
6
|
+
|
|
7
|
+
Modes = { shapes: 0x0001, joints: 0x0002, aabb: 0x0004, pairs: 0x0008, center_of_mass: 0x0010 }
|
|
8
|
+
|
|
9
|
+
def initialize(options = [])
|
|
10
|
+
@draw = B2DDraw.new
|
|
11
|
+
|
|
12
|
+
initialize_shader
|
|
13
|
+
initialize_drawing
|
|
14
|
+
|
|
15
|
+
mode = options.reduce(0) { |sum, option| sum + Modes[option] }
|
|
16
|
+
@draw.drawFlags = mode unless options.empty?
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def modes=(options = [])
|
|
20
|
+
modes = options.reduce(0) { |sum, option| sum + Modes[option] }
|
|
21
|
+
@draw.drawFlags = modes unless options.empty?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def initialize_shader
|
|
27
|
+
@shader_program = CCShaderCache.sharedShaderCache.programForKey(KCCShader_Position_uColor)
|
|
28
|
+
@color_location = glGetUniformLocation(@shader_program.program, :u_color)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def initialize_drawing
|
|
32
|
+
@draw.drawPolygon = lambda do |vertices, vertex_count, color|
|
|
33
|
+
prepare_for_drawing
|
|
34
|
+
draw_polygon(vertices, vertex_count, color)
|
|
35
|
+
check_for_drawing_errors
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
@draw.drawSolidPolygon = lambda do |vertices, vertex_count, color|
|
|
39
|
+
prepare_for_drawing
|
|
40
|
+
draw_solid_polygon(vertices, vertex_count, color)
|
|
41
|
+
check_for_drawing_errors
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@draw.drawCircle = lambda do |center, radius, color|
|
|
45
|
+
prepare_for_drawing
|
|
46
|
+
draw_circle(center, radius, color)
|
|
47
|
+
check_for_drawing_errors
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
@draw.drawSolidCircle = lambda do |center, radius, axis, color|
|
|
51
|
+
prepare_for_drawing
|
|
52
|
+
draw_solid_circle(center, radius, axis, color)
|
|
53
|
+
check_for_drawing_errors
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
@draw.drawSegment = lambda do |first_point, second_point, color|
|
|
57
|
+
prepare_for_drawing
|
|
58
|
+
draw_segment(first_point, second_point, color)
|
|
59
|
+
check_for_drawing_errors
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
@draw.drawTransform = lambda do |transform|
|
|
63
|
+
prepare_for_drawing
|
|
64
|
+
draw_transform(transform)
|
|
65
|
+
check_for_drawing_errors
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def prepare_for_drawing
|
|
70
|
+
@shader_program.use
|
|
71
|
+
@shader_program.setUniformsForBuiltins
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def set_drawing_color(color, alpha)
|
|
75
|
+
@shader_program.setUniformLocation(@color_location,
|
|
76
|
+
withF1: color.red * alpha,
|
|
77
|
+
f2: color.green * alpha,
|
|
78
|
+
f3: color.blue * alpha,
|
|
79
|
+
f4: alpha)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def check_for_drawing_errors
|
|
83
|
+
error = glGetError
|
|
84
|
+
print "error" if error > 0
|
|
85
|
+
# Todo print error message on the console "0x#{error}4x" if error > 0
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def draw_polygon(box_vertices, vertex_count, color)
|
|
89
|
+
vertices = Pointer.new(:float, vertex_count * 2)
|
|
90
|
+
vertex_count.times do |i|
|
|
91
|
+
vertices[i * 2] = box_vertices[i].x.to_pixels
|
|
92
|
+
vertices[i * 2 + 1] = box_vertices[i].y.to_pixels
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
set_drawing_color(color, 1)
|
|
96
|
+
glVertexAttribPointer(KCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices)
|
|
97
|
+
glDrawArrays(GL_LINE_LOOP, 0, vertex_count)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def draw_solid_polygon(box_vertices, vertex_count, color)
|
|
101
|
+
vertices = Pointer.new(:float, vertex_count * 2)
|
|
102
|
+
vertex_count.times do |i|
|
|
103
|
+
vertices[i * 2] = box_vertices[i].x.to_pixels
|
|
104
|
+
vertices[i * 2 + 1] = box_vertices[i].y.to_pixels
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
set_drawing_color(color, 0.5)
|
|
108
|
+
glVertexAttribPointer(KCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices)
|
|
109
|
+
glDrawArrays(GL_TRIANGLE_FAN, 0, vertex_count)
|
|
110
|
+
|
|
111
|
+
set_drawing_color(color, 1)
|
|
112
|
+
glDrawArrays(GL_LINE_LOOP, 0, vertex_count)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def draw_circle(center, radius, color)
|
|
116
|
+
vertex_count = 16
|
|
117
|
+
increment = 2.0 * Math::PI / vertex_count
|
|
118
|
+
theta = 0.0
|
|
119
|
+
|
|
120
|
+
vertices = Pointer.new(:float, vertex_count * 2)
|
|
121
|
+
vertex_count.times do |i|
|
|
122
|
+
vertex = center + radius * CGPointMake(Math.cos(theta), Math.sin(theta))
|
|
123
|
+
vertex = vertex.to_pixel_coordinates
|
|
124
|
+
|
|
125
|
+
vertices[i * 2] = vertex.x
|
|
126
|
+
vertices[i * 2 + 1] = vertex.y
|
|
127
|
+
theta += increment
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
set_drawing_color(color, 1.0)
|
|
131
|
+
glVertexAttribPointer(KCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices)
|
|
132
|
+
glDrawArrays(GL_LINE_LOOP, 0, vertex_count)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def draw_solid_circle(center, radius, axis, color)
|
|
136
|
+
vertex_count = 16
|
|
137
|
+
increment = 2.0 * Math::PI / vertex_count
|
|
138
|
+
theta = 0.0
|
|
139
|
+
|
|
140
|
+
vertices = Pointer.new(:float, vertex_count * 2)
|
|
141
|
+
vertex_count.times do |i|
|
|
142
|
+
vertex = center + radius * CGPointMake(Math.cos(theta), Math.sin(theta))
|
|
143
|
+
vertex = vertex.to_pixel_coordinates
|
|
144
|
+
|
|
145
|
+
vertices[i * 2] = vertex.x
|
|
146
|
+
vertices[i * 2 + 1] = vertex.y
|
|
147
|
+
theta += increment
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
set_drawing_color(color, 0.5)
|
|
151
|
+
glVertexAttribPointer(KCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices)
|
|
152
|
+
glDrawArrays(GL_TRIANGLE_FAN, 0, vertex_count)
|
|
153
|
+
|
|
154
|
+
set_drawing_color(color, 1.0)
|
|
155
|
+
glDrawArrays(GL_LINE_LOOP, 0, vertex_count)
|
|
156
|
+
|
|
157
|
+
draw_segment(center, center + radius * axis, color)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def draw_segment(first_point, second_point, color)
|
|
161
|
+
vertices = Pointer.new(:float, 4)
|
|
162
|
+
|
|
163
|
+
vertices = Pointer.new(:float, 4)
|
|
164
|
+
vertices[0] = first_point.x.to_pixels
|
|
165
|
+
vertices[1] = first_point.y.to_pixels
|
|
166
|
+
vertices[2] = second_point.x.to_pixels
|
|
167
|
+
vertices[3] = second_point.y.to_pixels
|
|
168
|
+
|
|
169
|
+
set_drawing_color(color, 1)
|
|
170
|
+
glVertexAttribPointer(KCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices)
|
|
171
|
+
glDrawArrays(GL_LINES, 0, 2)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def draw_transform(transform)
|
|
175
|
+
axis_scale = 0.4
|
|
176
|
+
first_point = transform.metric_position
|
|
177
|
+
|
|
178
|
+
angle_x_axis = CGPointMake(Math.cos(transform.angle), Math.sin(transform.angle))
|
|
179
|
+
angle_y_axis = CGPointMake(-Math.sin(transform.angle), Math.cos(transform.angle))
|
|
180
|
+
|
|
181
|
+
second_point = first_point + axis_scale * angle_x_axis
|
|
182
|
+
draw_segment(first_point, second_point, Color.new(1, 0, 0))
|
|
183
|
+
|
|
184
|
+
second_point = first_point + axis_scale * angle_y_axis
|
|
185
|
+
draw_segment(first_point, second_point, Color.new(0, 0, 1))
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
end
|
|
191
|
+
end
|