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
|
@@ -3,29 +3,41 @@ module Joybox
|
|
|
3
3
|
|
|
4
4
|
class World < B2DWorld
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
extend Joybox::Common::Initialize
|
|
7
|
+
|
|
8
|
+
alias_method :bodies, :bodyList
|
|
9
|
+
alias_method :allows_sleeping?, :allowsSleeping
|
|
10
|
+
alias_method :allows_sleeping=, :setAllowsSleeping
|
|
11
|
+
alias_method :proxy_count, :proxyCount
|
|
12
|
+
alias_method :body_count, :bodyCount
|
|
13
|
+
alias_method :joint_count, :jointCount
|
|
14
|
+
alias_method :contact_count, :contactCount
|
|
15
|
+
alias_method :tree_height, :treeHeight
|
|
16
|
+
alias_method :tree_balance, :treeBalance
|
|
17
|
+
alias_method :tree_quality, :treeQuality
|
|
18
|
+
alias_method :locked?, :isLocked
|
|
19
|
+
alias_method :auto_clear_forces?, :autoClearForces
|
|
20
|
+
alias_method :auto_clear_forces=, :setAutoClearForces
|
|
21
|
+
alias_method :create_body, :createBody
|
|
22
|
+
alias_method :clear_forces, :clearForces
|
|
23
|
+
alias_method :draw_debug_data, :drawDebugData
|
|
24
|
+
alias_method :continuous_physics, :continuousPhysics
|
|
25
|
+
|
|
26
|
+
def defaults
|
|
7
27
|
{
|
|
8
28
|
gravity: [0, 0],
|
|
9
|
-
allows_sleeping: true
|
|
10
|
-
continuous_physics: true
|
|
29
|
+
allows_sleeping: true
|
|
11
30
|
}
|
|
12
31
|
end
|
|
13
32
|
|
|
14
|
-
|
|
15
|
-
def self.new(options)
|
|
16
|
-
|
|
33
|
+
def initialize(options = {})
|
|
17
34
|
options = options.nil? ? defaults : defaults.merge!(options)
|
|
18
35
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
world.allowsSleeping = options[:allows_sleeping]
|
|
23
|
-
world.continuousPhysics = options[:continuous_physics]
|
|
24
|
-
|
|
25
|
-
world
|
|
36
|
+
init
|
|
37
|
+
self.gravity = options[:gravity]
|
|
38
|
+
self.allowsSleeping = options[:allows_sleeping]
|
|
26
39
|
end
|
|
27
40
|
|
|
28
|
-
|
|
29
41
|
def step_defaults
|
|
30
42
|
{
|
|
31
43
|
velocity_interactions: 8,
|
|
@@ -33,44 +45,103 @@ module Joybox
|
|
|
33
45
|
}
|
|
34
46
|
end
|
|
35
47
|
|
|
36
|
-
|
|
37
48
|
def step(options = {})
|
|
38
|
-
|
|
39
49
|
options = options.nil? ? step_defaults : step_defaults.merge!(options)
|
|
40
50
|
|
|
41
51
|
stepWithDelta(options[:delta],
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
velocityInteractions: options[:velocity_interactions],
|
|
53
|
+
positionInteractions: options[:position_interactions])
|
|
44
54
|
end
|
|
45
55
|
|
|
46
|
-
|
|
47
56
|
def new_body(options = {}, &block)
|
|
48
57
|
body = Body.new(self, options)
|
|
49
58
|
body.instance_eval(&block) if block
|
|
50
59
|
body
|
|
51
60
|
end
|
|
52
61
|
|
|
62
|
+
def destroy_body(body)
|
|
63
|
+
destroyBody(body)
|
|
64
|
+
@listening_sprites.delete(body[:sprite]) unless @listening_sprites.nil?
|
|
65
|
+
end
|
|
53
66
|
|
|
54
|
-
def
|
|
67
|
+
def should_collide(&block)
|
|
68
|
+
@should_collide = block
|
|
55
69
|
|
|
56
|
-
@
|
|
57
|
-
|
|
70
|
+
@contact_filter = B2DContactFilter.new;
|
|
71
|
+
@contact_filter.shouldCollide = lambda do |first_fixture, second_fixture|
|
|
72
|
+
@should_collide.call(first_fixture, second_fixture)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
setContactFilter(@contact_filter)
|
|
76
|
+
end
|
|
58
77
|
|
|
59
|
-
|
|
78
|
+
def setup_collision_listener
|
|
79
|
+
@contact_listener = B2DContactListener.new
|
|
80
|
+
setContactListener(@contact_listener)
|
|
81
|
+
|
|
82
|
+
@listening_sprites = Hash.new
|
|
83
|
+
|
|
84
|
+
@contact_listener.beginContact = lambda do |first_body, second_body, is_touching|
|
|
85
|
+
# TODO: Find a better way to do this assignment
|
|
86
|
+
collision = [first_body, second_body] if @listening_sprites.has_key? first_body[:sprite]
|
|
87
|
+
collision = [second_body, first_body] if @listening_sprites.has_key? second_body[:sprite]
|
|
88
|
+
|
|
89
|
+
unless collision.nil?
|
|
90
|
+
object = collision[1][:sprite].nil? ? collision[1] : collision[1][:sprite]
|
|
91
|
+
@listening_sprites[collision[0][:sprite]].call(object, is_touching)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
@on_collision.call(first_body, second_body, is_touching) unless @on_collision.nil?
|
|
95
|
+
end
|
|
96
|
+
end
|
|
60
97
|
|
|
61
|
-
|
|
98
|
+
def when_collide(sprite, &block)
|
|
99
|
+
setup_collision_listener unless @contact_listener
|
|
100
|
+
@listening_sprites[sprite] = block
|
|
101
|
+
end
|
|
62
102
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
103
|
+
def on_collision(&block)
|
|
104
|
+
setup_collision_listener unless @contact_listener
|
|
105
|
+
@on_collision = block
|
|
66
106
|
end
|
|
67
107
|
|
|
108
|
+
def on_fixture_destroyed(&block)
|
|
109
|
+
@when_fixture_destroyed = block
|
|
68
110
|
|
|
69
|
-
|
|
111
|
+
@destruction_listener = B2DDestructionListener.new;
|
|
112
|
+
@destruction_listener.fixtureSayGoodbye = lambda do |fixture|
|
|
113
|
+
@when_fixture_destroyed.call(fixture)
|
|
114
|
+
end
|
|
70
115
|
|
|
71
|
-
|
|
116
|
+
setDestructionListener(@destruction_listener)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def query(options = {}, &block)
|
|
120
|
+
@query = block
|
|
121
|
+
@query_callback = B2DQueryCallback.new
|
|
122
|
+
@query_callback.reportFixture = lambda do |fixture|
|
|
123
|
+
@query.call(fixture)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
aabb = AABB.new
|
|
127
|
+
aabb.lower_bound = CGPointMake(options[:lower_bound][0], options[:lower_bound][1])
|
|
128
|
+
aabb.upper_bound = CGPointMake(options[:upper_bound][0], options[:upper_bound][1])
|
|
129
|
+
queryAABBWithCallback(@query_callback, andAABB:aabb)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def ray_cast(options = {}, &block)
|
|
133
|
+
@ray_cast = block
|
|
134
|
+
@ray_cast_callback = B2DRayCastCallback.new
|
|
135
|
+
@ray_cast_callback.reportFixture = lambda do |fixture, point, normal, fraction|
|
|
136
|
+
@ray_cast.call(fixture, point.from_pixel_coordinates, normal, fraction)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
first_point = CGPointMake(options[:first_point][0], options[:first_point][1])
|
|
140
|
+
second_point = CGPointMake(options[:second_point][0], options[:second_point][1])
|
|
72
141
|
|
|
73
|
-
@
|
|
142
|
+
rayCastWithCallback(@ray_cast_callback,
|
|
143
|
+
andPoint1:first_point.from_pixel_coordinates,
|
|
144
|
+
andPoint2:second_point.from_pixel_coordinates)
|
|
74
145
|
end
|
|
75
146
|
|
|
76
147
|
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Joybox::TMX::TileLayer = CCTMXLayer
|
|
2
|
+
|
|
3
|
+
class CCTMXLayer
|
|
4
|
+
|
|
5
|
+
include Joybox::Common
|
|
6
|
+
|
|
7
|
+
alias_method :name, :layerName
|
|
8
|
+
alias_method :name=, :setLayerName
|
|
9
|
+
alias_method :tiles_size, :layerSize
|
|
10
|
+
alias_method :tiles_size=, :setLayerSize
|
|
11
|
+
alias_method :map_of_tiles, :tiles
|
|
12
|
+
alias_method :map_of_tiles=, :setTiles
|
|
13
|
+
alias_method :tile_set, :tileset
|
|
14
|
+
alias_method :tile_set=, :setTileset
|
|
15
|
+
alias_method :orientation, :layerOrientation
|
|
16
|
+
alias_method :orientation=, :setLayerOrientation
|
|
17
|
+
alias_method :release_map, :releaseMap
|
|
18
|
+
alias_method :setup_tiles, :setupTiles
|
|
19
|
+
|
|
20
|
+
Orthogonal = 0
|
|
21
|
+
Hexagonal = 1
|
|
22
|
+
Isometric = 2
|
|
23
|
+
|
|
24
|
+
def tile_size
|
|
25
|
+
return mapTileSize unless Device.retina?
|
|
26
|
+
return mapTileSize.half if Device.retina?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def size
|
|
30
|
+
[layerSize.width * tile_size.width, layerSize.height * tile_size.height].to_size
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def point_for_coordinate(coordinate)
|
|
34
|
+
positionAt(coordinate)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def coordinate_for_point(point)
|
|
38
|
+
point = point.to_point unless point.is_a? (CGPoint)
|
|
39
|
+
x = point.x / tile_size.width
|
|
40
|
+
y = (size.height - point.y) / tile_size.height
|
|
41
|
+
[x.floor, y.floor].to_point
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def sprite_at(point)
|
|
45
|
+
coordinate = coordinate_for_point(point)
|
|
46
|
+
tileAt(coordinate)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def tile_type_at(point)
|
|
50
|
+
coordinate = coordinate_for_point(point)
|
|
51
|
+
tileGIDAt(coordinate)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def remove_tile_at(point)
|
|
55
|
+
coordinate = coordinate_for_point(point)
|
|
56
|
+
removeTileAt(coordinate)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def set_tile_type_at(point, tile_type)
|
|
60
|
+
coordinate = coordinate_for_point(point)
|
|
61
|
+
setTileGID(tile_type, at: coordinate)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def [](point)
|
|
65
|
+
coordinate = coordinate_for_point(point)
|
|
66
|
+
tileGIDAt(coordinate)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def []=(point, tile_type)
|
|
70
|
+
coordinate = coordinate_for_point(point)
|
|
71
|
+
setTileGID(tile_type, at: coordinate)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
module Joybox
|
|
2
|
+
module TMX
|
|
3
|
+
|
|
4
|
+
class ObjectLayers
|
|
5
|
+
def initialize(map); @map = map; end
|
|
6
|
+
def [](key); @map.objectGroupNamed(key); end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class TileLayers
|
|
10
|
+
def initialize(map); @map = map; end
|
|
11
|
+
def [](key); @map.layerNamed(key); end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class Tiles
|
|
15
|
+
def initialize(map); @map = map; end
|
|
16
|
+
def [](key); @map.propertiesForGID(key) || Hash.new; end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class TileMap < CCTMXTiledMap
|
|
20
|
+
|
|
21
|
+
include Joybox::Common
|
|
22
|
+
extend Joybox::Common::Initialize
|
|
23
|
+
|
|
24
|
+
alias_method :tiles_size, :mapSize
|
|
25
|
+
alias_method :orientation, :mapOrientation
|
|
26
|
+
alias_method :objects, :objectGroups
|
|
27
|
+
alias_method :objects=, :setObjectGroups
|
|
28
|
+
alias_method :properties_for_tile_type, :propertiesForGID
|
|
29
|
+
|
|
30
|
+
Orthogonal = 0
|
|
31
|
+
Hexagonal = 1
|
|
32
|
+
Isometric = 2
|
|
33
|
+
|
|
34
|
+
def initialize(options = {})
|
|
35
|
+
# Todo print error message on the console
|
|
36
|
+
return unless [:file_name, :xml].any? { |k| options.has_key? k }
|
|
37
|
+
|
|
38
|
+
initWithTMXFile(options[:file_name]) unless options.has_key? :xml
|
|
39
|
+
initWithXML(options[:xml], resourcePath: options[:resource_path]) unless options.has_key? :file_name
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def object(query)
|
|
43
|
+
keys = query.split('#')
|
|
44
|
+
key = keys.shift
|
|
45
|
+
|
|
46
|
+
layer = objectGroupNamed(key) unless key.nil?
|
|
47
|
+
return layer unless key = keys.shift
|
|
48
|
+
object = layer[key]
|
|
49
|
+
return object unless key = keys.shift
|
|
50
|
+
|
|
51
|
+
if key.casecmp(:position)
|
|
52
|
+
position = [object[:x], object[:y]].to_point
|
|
53
|
+
position = position.half if Device.retina?
|
|
54
|
+
position
|
|
55
|
+
else
|
|
56
|
+
object[key]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def tile_layers
|
|
61
|
+
TileLayers.new(self)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def object_layers
|
|
65
|
+
ObjectLayers.new(self)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def tiles
|
|
69
|
+
Tiles.new(self)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def tile_size
|
|
73
|
+
return tileSize unless Device.retina?
|
|
74
|
+
return tileSize.half if Device.retina?
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def size
|
|
78
|
+
[mapSize.width * tile_size.width, mapSize.height * tile_size.height].to_size
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def bounding_box
|
|
82
|
+
[position.x, position.y, size.width, size.height].to_rect
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def contains_point?(point)
|
|
86
|
+
point = point.to_point unless point.is_a? (CGPoint)
|
|
87
|
+
CGRectContainsPoint(bounding_box, point)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def coordinate_for_point(point)
|
|
91
|
+
point = point.to_point unless point.is_a? (CGPoint)
|
|
92
|
+
x = point.x / tile_size.width
|
|
93
|
+
y = (size.height - point.y) / tile_size.height
|
|
94
|
+
[x.floor, y.floor].to_point
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def step_by(position, new_position)
|
|
98
|
+
delta = new_position - position
|
|
99
|
+
if delta.x.abs > delta.y.abs
|
|
100
|
+
position.x += tile_size.width if delta.x > 0
|
|
101
|
+
position.x -= tile_size.width unless delta.x > 0
|
|
102
|
+
else
|
|
103
|
+
position.y += tile_size.height if delta.y > 0
|
|
104
|
+
position.y -= tile_size.height unless delta.y > 0
|
|
105
|
+
end
|
|
106
|
+
position
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Joybox::TMX::TileSet = CCTMXTilesetInfo
|
|
2
|
+
|
|
3
|
+
class CCTMXTilesetInfo
|
|
4
|
+
|
|
5
|
+
include Joybox::Common
|
|
6
|
+
|
|
7
|
+
alias_method :first_tile_type, :firstGid
|
|
8
|
+
alias_method :first_tile_type, :setFirstGid
|
|
9
|
+
alias_method :image_file_name, :sourceImage
|
|
10
|
+
alias_method :image_file_name=, :setSourceImage
|
|
11
|
+
alias_method :image_size, :imageSize
|
|
12
|
+
alias_method :image_size=, :setImageSize
|
|
13
|
+
alias_method :tile_offset, :tileOffset
|
|
14
|
+
alias_method :tile_offset=, :setTileOffset
|
|
15
|
+
alias_method :anchor_point, :tileAnchorPoint
|
|
16
|
+
|
|
17
|
+
def tile_size
|
|
18
|
+
return tileSize unless Device.retina?
|
|
19
|
+
return tileSize.half if Device.retina?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def rect_for_tile_type(tile_type)
|
|
23
|
+
rectForGID(tile_type)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Joybox
|
|
2
|
+
module TMX
|
|
3
|
+
|
|
4
|
+
include Joybox::Common
|
|
5
|
+
|
|
6
|
+
def center_at(position)
|
|
7
|
+
x = [position.x, Screen.half_width].max
|
|
8
|
+
y = [position.y, Screen.half_height].max
|
|
9
|
+
x = [x, @tile_map.size.width - Screen.half_width].min
|
|
10
|
+
y = [y, @tile_map.size.height - Screen.half_height].min
|
|
11
|
+
|
|
12
|
+
self.position = Screen.center - [x, y].to_point
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
data/motion/joybox/ui/label.rb
CHANGED
|
@@ -3,33 +3,61 @@ module Joybox
|
|
|
3
3
|
|
|
4
4
|
class Label < CCLabelTTF
|
|
5
5
|
|
|
6
|
+
extend Joybox::Common::Initialize
|
|
7
|
+
|
|
6
8
|
alias_method :text=, :setString
|
|
7
9
|
alias_method :set_text, :setString
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
alias_method :text, :string
|
|
11
|
+
alias_method :alignment, :horizontalAlignment
|
|
12
|
+
alias_method :alignment=, :setHorizontalAlignment
|
|
13
|
+
alias_method :vertical_alignment, :verticalAlignment
|
|
14
|
+
alias_method :vertical_alignment=, :setVerticalAlignment
|
|
15
|
+
alias_method :font_name, :fontName
|
|
16
|
+
alias_method :font_name=, :setFontName
|
|
17
|
+
alias_method :font_size, :fontSize
|
|
18
|
+
alias_method :font_size=, :setFontSize
|
|
19
|
+
|
|
20
|
+
TextAlignmentLeft = 0
|
|
21
|
+
TextAlignmentCenter = 1
|
|
22
|
+
TextAlignmentRight = 2
|
|
23
|
+
|
|
24
|
+
TextAlignmentTop = 0
|
|
25
|
+
TextAlignmentBottom = 2
|
|
26
|
+
|
|
27
|
+
LineBreakWordWrap = 0
|
|
28
|
+
LineBreakCharacterWrap = 1
|
|
29
|
+
LineBreakClip = 2
|
|
30
|
+
LineBreakHeadTruncation = 3
|
|
31
|
+
LineBreakTailTruncation = 4
|
|
32
|
+
LineBreakMiddleTruncation = 5
|
|
33
|
+
|
|
34
|
+
def defaults
|
|
10
35
|
{
|
|
11
36
|
text: '',
|
|
37
|
+
dimensions: CGSizeZero,
|
|
38
|
+
alignment: TextAlignmentCenter,
|
|
39
|
+
vertical_alignment: TextAlignmentTop,
|
|
12
40
|
font_name: 'Marker Felt',
|
|
13
|
-
font_size: 12
|
|
41
|
+
font_size: 12,
|
|
42
|
+
line_break_mode: LineBreakWordWrap
|
|
14
43
|
}
|
|
15
44
|
end
|
|
16
45
|
|
|
17
|
-
|
|
18
|
-
def self.new(options = {})
|
|
19
|
-
|
|
46
|
+
def initialize(options = {})
|
|
20
47
|
options = options.nil? ? defaults : defaults.merge!(options)
|
|
21
48
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
49
|
+
self.initWithString(options[:text],
|
|
50
|
+
fontName: options[:font_name],
|
|
51
|
+
fontSize: options[:font_size],
|
|
52
|
+
dimensions: options[:dimensions],
|
|
53
|
+
hAlignment: options[:alignment],
|
|
54
|
+
vAlignment: options[:vertical_alignment],
|
|
55
|
+
lineBreakMode: options[:line_break_mode])
|
|
56
|
+
|
|
57
|
+
self.position = options[:position] if options.has_key? (:position)
|
|
58
|
+
self.color = options[:color] if options.has_key? (:color)
|
|
30
59
|
end
|
|
31
|
-
|
|
32
60
|
end
|
|
33
61
|
|
|
34
62
|
end
|
|
35
|
-
end
|
|
63
|
+
end
|