joybox 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +4 -4
- data/README.md +66 -22
- data/Rakefile +22 -4
- data/app/ios/app_delegate.rb +48 -0
- data/app/osx/app_delegate.rb +26 -0
- data/app/osx/layers/game_layer.rb +5 -0
- data/app/osx/menu.rb +51 -0
- data/command/command/image.rb +26 -0
- data/command/command/string.rb +15 -0
- data/command/command/template.rb +59 -0
- data/command/command/tmx.rb +75 -0
- data/command/joybox_generate_command.rb +64 -110
- data/command/joybox_retina_command.rb +87 -0
- data/command/{joybox/templates → templates}/layer.erb +0 -0
- data/command/{joybox/templates → templates}/layer_spec.erb +0 -0
- data/command/{joybox/templates → templates}/scene.erb +0 -0
- data/command/{joybox/templates → templates}/scene_spec.erb +0 -0
- data/command/{joybox/templates → templates}/sprite.erb +0 -0
- data/command/{joybox/templates → templates}/sprite_spec.erb +0 -0
- data/ext/extconf.rb +34 -0
- data/joybox.gemspec +103 -50
- data/lib/joybox.rb +2 -0
- data/lib/joybox/joybox-ios.rb +18 -3
- data/lib/joybox/joybox-osx.rb +18 -2
- data/lib/joybox/version.rb +1 -1
- data/motion/joybox-ios/common/cg_point.rb +46 -16
- data/motion/joybox-ios/common/device.rb +56 -0
- data/motion/joybox-ios/common/ui_touch.rb +0 -2
- data/motion/joybox-ios/configuration/configuration.rb +10 -40
- data/motion/joybox-ios/configuration/file_utils.rb +0 -4
- data/motion/joybox-ios/configuration/gl_view.rb +14 -20
- data/motion/joybox-ios/configuration/texture_2d.rb +0 -4
- data/motion/joybox-ios/core/layer.rb +2 -8
- data/motion/joybox-ios/debug/proxy_view.rb +5 -5
- data/motion/joybox-ios/debug/{node.rb → repl.rb} +25 -19
- data/motion/joybox-ios/director.rb +15 -4
- data/motion/joybox-osx/common/ats_point.rb +45 -15
- data/motion/joybox-osx/common/device.rb +30 -0
- data/motion/joybox-osx/common/ns_event.rb +0 -1
- data/motion/joybox-osx/configuration/configuration.rb +6 -26
- data/motion/joybox-osx/configuration/gl_view.rb +16 -14
- data/motion/joybox-osx/core/layer.rb +45 -26
- data/motion/joybox-osx/debug/proxy_view.rb +5 -5
- data/motion/joybox-osx/debug/{node.rb → repl.rb} +13 -7
- data/motion/joybox-osx/director.rb +4 -3
- data/motion/joybox/actions/animate.rb +0 -1
- data/motion/joybox/actions/bezier.rb +2 -9
- data/motion/joybox/actions/blink.rb +1 -4
- data/motion/joybox/actions/callback.rb +19 -0
- data/motion/joybox/actions/d3/flip.rb +27 -0
- data/motion/joybox/actions/d3/jump.rb +30 -0
- data/motion/joybox/actions/d3/lens.rb +30 -0
- data/motion/joybox/actions/d3/shake.rb +32 -0
- data/motion/joybox/actions/d3/shatter.rb +30 -0
- data/motion/joybox/actions/d3/wave.rb +33 -0
- data/motion/joybox/actions/delay.rb +19 -0
- data/motion/joybox/actions/ease.rb +3 -21
- data/motion/joybox/actions/fade.rb +30 -6
- data/motion/joybox/actions/jump.rb +0 -5
- data/motion/joybox/actions/liquid.rb +28 -0
- data/motion/joybox/actions/move.rb +2 -9
- data/motion/joybox/actions/place.rb +0 -2
- data/motion/joybox/actions/repeat.rb +0 -2
- data/motion/joybox/actions/rotate.rb +2 -9
- data/motion/joybox/actions/scale.rb +2 -9
- data/motion/joybox/actions/sequence.rb +0 -1
- data/motion/joybox/actions/shuffle.rb +26 -0
- data/motion/joybox/actions/skew.rb +2 -11
- data/motion/joybox/actions/spawn.rb +0 -1
- data/motion/joybox/actions/split.rb +24 -0
- data/motion/joybox/actions/tint.rb +0 -5
- data/motion/joybox/actions/turn.rb +24 -0
- data/motion/joybox/actions/twirl.rb +30 -0
- data/motion/joybox/actions/visibility.rb +21 -0
- data/motion/joybox/actions/wave.rb +32 -0
- data/motion/joybox/animations/animation.rb +7 -11
- data/motion/joybox/audio/audio.rb +31 -0
- data/motion/joybox/audio/audio_effect.rb +69 -0
- data/motion/joybox/audio/background_audio.rb +77 -0
- data/motion/joybox/common/{gc_size.rb → cg_size.rb} +13 -12
- data/motion/joybox/common/color.rb +4 -13
- data/motion/joybox/common/initialize.rb +11 -0
- data/motion/joybox/common/ns_array.rb +15 -0
- data/motion/joybox/common/ns_string.rb +7 -0
- data/motion/joybox/common/numeric.rb +13 -4
- data/motion/joybox/common/screen.rb +4 -12
- data/motion/joybox/configuration/debug.rb +29 -0
- data/motion/joybox/core/layer.rb +0 -24
- data/motion/joybox/core/layer_color.rb +47 -0
- data/motion/joybox/core/node.rb +18 -8
- data/motion/joybox/core/scene.rb +0 -5
- data/motion/joybox/core/sprite.rb +43 -25
- data/motion/joybox/core/sprite_batch.rb +15 -6
- data/motion/joybox/core/sprite_frame_cache.rb +9 -58
- data/motion/joybox/debug/physics.rb +40 -0
- data/motion/joybox/debug/physics_draw.rb +191 -0
- data/motion/joybox/joybox.rb +9 -1
- data/motion/joybox/macros.rb +13 -13
- data/motion/joybox/physics/aabb.rb +28 -0
- data/motion/joybox/physics/body.rb +163 -68
- data/motion/joybox/physics/chain_shape.rb +71 -0
- data/motion/joybox/physics/circle_shape.rb +31 -0
- data/motion/joybox/physics/edge_shape.rb +37 -0
- data/motion/joybox/physics/filter.rb +17 -0
- data/motion/joybox/physics/fixture.rb +52 -0
- data/motion/joybox/physics/mass_data.rb +19 -0
- data/motion/joybox/physics/physics_sprite.rb +50 -16
- data/motion/joybox/physics/polygon_shape.rb +54 -0
- data/motion/joybox/physics/profile.rb +14 -0
- data/motion/joybox/physics/ray_cast_input.rb +30 -0
- data/motion/joybox/physics/ray_cast_output.rb +17 -0
- data/motion/joybox/physics/shape.rb +61 -0
- data/motion/joybox/physics/transform.rb +17 -0
- data/motion/joybox/physics/world.rb +101 -30
- data/motion/joybox/tmx/object_layer.rb +12 -0
- data/motion/joybox/tmx/tile_layer.rb +74 -0
- data/motion/joybox/tmx/tile_map.rb +112 -0
- data/motion/joybox/tmx/tile_set.rb +26 -0
- data/motion/joybox/tmx/tmx.rb +16 -0
- data/motion/joybox/ui/label.rb +44 -16
- data/motion/joybox/ui/menu.rb +7 -9
- data/motion/joybox/ui/menu_image.rb +11 -8
- data/motion/joybox/ui/menu_label.rb +14 -13
- data/resources/Default-568h@2x.png +0 -0
- data/resources/animation_frames-hd.plist +126 -0
- data/resources/animation_frames-ipadhd.plist +126 -0
- data/resources/animation_frames.plist +126 -0
- data/resources/animation_sprite_sheet-hd.png +0 -0
- data/resources/animation_sprite_sheet-ipadhd.png +0 -0
- data/resources/animation_sprite_sheet.png +0 -0
- data/resources/fps_images-hd.png +0 -0
- data/resources/fps_images-ipadhd.png +0 -0
- data/resources/fps_images.png +0 -0
- data/resources/sprite.png +0 -0
- data/resources/sprite_inverted.png +0 -0
- data/resources/sprite_sheet.png +0 -0
- data/spec/motion/joybox-ios/common/screen_spec.rb +21 -0
- data/spec/{main_spec.rb → motion/joybox-ios/main_spec.rb} +6 -2
- data/spec/motion/joybox-ios/ui/label_spec.rb +20 -0
- data/spec/motion/joybox-ios/ui/menu_label_spec.rb +15 -0
- data/spec/motion/joybox-ios/ui/menu_spec.rb +87 -0
- data/spec/motion/joybox-osx/common/screen_spec.rb +21 -0
- data/spec/motion/joybox-osx/main_spec.rb +13 -0
- data/spec/motion/joybox-osx/ui/label_spec.rb +18 -0
- data/spec/motion/joybox-osx/ui/menu_label_spec.rb +13 -0
- data/spec/motion/joybox-osx/ui/menu_spec.rb +87 -0
- data/spec/motion/joybox/actions/actions_spec.rb +11 -0
- data/spec/motion/joybox/actions/bezier_spec.rb +37 -0
- data/spec/motion/joybox/actions/blink_spec.rb +16 -0
- data/spec/motion/joybox/actions/fade_spec.rb +49 -0
- data/spec/motion/joybox/actions/jump_spec.rb +37 -0
- data/spec/motion/joybox/actions/move_spec.rb +37 -0
- data/spec/motion/joybox/actions/place_spec.rb +12 -0
- data/spec/motion/joybox/actions/rotate_spec.rb +35 -0
- data/spec/motion/joybox/actions/scale_spec.rb +43 -0
- data/spec/motion/joybox/actions/skew_spec.rb +43 -0
- data/spec/motion/joybox/common/cg_size_spec.rb +29 -0
- data/spec/motion/joybox/common/color_spec.rb +31 -0
- data/spec/motion/joybox/common/ns_string_spec.rb +8 -0
- data/spec/motion/joybox/common/numeric_spec.rb +13 -0
- data/spec/motion/joybox/core/node_spec.rb +36 -0
- data/spec/motion/joybox/core/sprite_batch_spec.rb +34 -0
- data/spec/motion/joybox/core/sprite_frame_cache_spec.rb +111 -0
- data/spec/motion/joybox/core/sprite_spec.rb +121 -0
- data/spec/motion/joybox/macros_spec.rb +280 -0
- data/spec/motion/joybox/physics/aabb_spec.rb +17 -0
- data/spec/motion/joybox/physics/body_spec.rb +318 -0
- data/spec/motion/joybox/physics/chain_shape_spec.rb +80 -0
- data/spec/motion/joybox/physics/circle_shape_spec.rb +63 -0
- data/spec/motion/joybox/physics/edge_shape_spec.rb +48 -0
- data/spec/motion/joybox/physics/fixture_spec.rb +106 -0
- data/spec/motion/joybox/physics/mass_data_spec.rb +13 -0
- data/spec/motion/joybox/physics/physics_sprite_spec.rb +50 -0
- data/spec/motion/joybox/physics/polygon_shape_spec.rb +92 -0
- data/spec/motion/joybox/physics/ray_cast_input_spec.rb +17 -0
- data/spec/motion/joybox/physics/ray_cast_output_spec.rb +13 -0
- data/spec/motion/joybox/physics/shape_spec.rb +50 -0
- data/spec/motion/joybox/physics/transform_spec.rb +13 -0
- data/spec/motion/joybox/physics/world_spec.rb +228 -0
- data/spec/motion/joybox/ui/label_spec.rb +53 -0
- data/spec/motion/joybox/ui/menu_image_spec.rb +51 -0
- data/spec/motion/joybox/ui/menu_label_spec.rb +68 -0
- data/spec/motion/joybox/ui/menu_spec.rb +26 -0
- data/spec/spec_helpers/cg_point.rb +5 -0
- data/spec/spec_helpers/cg_point_spec.rb +14 -0
- data/template/joybox-ios-example-repl/files/.gitignore +16 -0
- data/template/joybox-ios/files/.gitignore +16 -0
- data/template/joybox-osx-example-repl/files/.gitignore +16 -0
- data/template/joybox-osx/files/.gitignore +16 -0
- data/vendor/vendor-ios/box_2d/box_2d.bridgesupport +1201 -85
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DAABB.h +21 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DBody.h +58 -13
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DBodyDef.h +44 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DBodyTypes.h +20 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DChainShape.h +29 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DCircleShape.h +7 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DColor.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DContactFilter.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DContactListener.h +1 -1
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DDestructionListener.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DDraw.h +54 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DEdgeShape.h +13 -2
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DFilter.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DFixture.h +47 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DFixtureDef.h +29 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DMassData.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DPolygonShape.h +14 -1
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DProfile.h +31 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DQueryCallback.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DRayCastCallback.h +24 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DRayCastInput.h +23 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DRayCastOutput.h +21 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DShape.h +23 -3
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DShapeTypes.h +22 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DTransform.h +21 -0
- data/vendor/vendor-ios/box_2d/box_2d_include/B2DWorld.h +40 -19
- data/vendor/vendor-ios/box_2d/libBox2D.a +0 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d.bridgesupport +808 -1578
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCActionEase.h +47 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCFontDefinition.h +85 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCLabelTTF.h +54 -6
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCMenuItem.h +1 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCTMXLayer.h +2 -2
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/CCTexture2D.h +4 -0
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/ccTypes.h +51 -1
- data/vendor/vendor-ios/cocos_2d/libcocos2d.a +0 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader.bridgesupport +510 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBAnimationManager.h +149 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBKeyframe.h +40 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBReader.h +176 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBSequence.h +49 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCBSequenceProperty.h +38 -0
- data/vendor/vendor-ios/cocos_builder_reader/cocos_builder_reader_include/CCNode+CCBRelativePositioning.h +65 -0
- data/vendor/vendor-ios/cocos_builder_reader/libCocosBuilderReader.a +0 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion.bridgesupport +1001 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDAudioManager.h +243 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDConfig.h +60 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDOpenALSupport.h +77 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDXMacOSXSupport.h +232 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CDXPropertyModifierAction.h +45 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/CocosDenshion.h +440 -0
- data/vendor/vendor-ios/cocos_denshion/cocos_denshion_include/SimpleAudioEngine.h +90 -0
- data/vendor/vendor-ios/cocos_denshion/libCocosDenshion.a +0 -0
- data/vendor/vendor-ios/kazmath/kazmath.bridgesupport +865 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/GL/mat4stack.h +51 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/GL/matrix.h +58 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/aabb.h +53 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/kazmath.h +39 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/mat3.h +75 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/mat4.h +93 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/neon_matrix_impl.h +41 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/plane.h +70 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/quaternion.h +113 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/ray2.h +50 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/utility.h +74 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/vec2.h +64 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/vec3.h +68 -0
- data/vendor/vendor-ios/kazmath/kazmath_include/vec4.h +68 -0
- data/vendor/vendor-ios/kazmath/libkazmath.a +0 -0
- data/vendor/vendor-osx/box_2d/box_2d.bridgesupport +1199 -83
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DAABB.h +21 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DBody.h +58 -13
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DBodyDef.h +44 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DBodyTypes.h +20 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DChainShape.h +29 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DCircleShape.h +7 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DColor.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DContactFilter.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DContactListener.h +1 -1
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DDestructionListener.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DDraw.h +54 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DEdgeShape.h +13 -2
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DFilter.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DFixture.h +47 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DFixtureDef.h +29 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DMassData.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DPolygonShape.h +14 -1
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DProfile.h +31 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DQueryCallback.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DRayCastCallback.h +24 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DRayCastInput.h +23 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DRayCastOutput.h +21 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DShape.h +23 -3
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DShapeTypes.h +22 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DTransform.h +21 -0
- data/vendor/vendor-osx/box_2d/box_2d_include/B2DWorld.h +40 -19
- data/vendor/vendor-osx/box_2d/libBox2D.a +0 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d.bridgesupport +2820 -2633
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCActionEase.h +47 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCFontDefinition.h +85 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCLabelTTF.h +54 -6
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCMenuItem.h +1 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCTMXLayer.h +2 -2
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/CCTexture2D.h +4 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCDirectorIOS.h +111 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCES2Renderer.h +83 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCESRenderer.h +54 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCGLView.h +175 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCTouchDelegateProtocol.h +75 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCTouchDispatcher.h +120 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/Platforms/iOS/CCTouchHandler.h +93 -0
- data/vendor/vendor-osx/cocos_2d/cocos_2d_include/ccTypes.h +65 -1
- data/vendor/vendor-osx/cocos_2d/libcocos2d.a +0 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader.bridgesupport +510 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBAnimationManager.h +149 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBKeyframe.h +40 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBReader.h +176 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBSequence.h +49 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCBSequenceProperty.h +38 -0
- data/vendor/vendor-osx/cocos_builder_reader/cocos_builder_reader_include/CCNode+CCBRelativePositioning.h +65 -0
- data/vendor/vendor-osx/cocos_builder_reader/libCocosBuilderReader.a +0 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion.bridgesupport +1001 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDAudioManager.h +243 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDConfig.h +60 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDOpenALSupport.h +77 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDXMacOSXSupport.h +232 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CDXPropertyModifierAction.h +45 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/CocosDenshion.h +440 -0
- data/vendor/vendor-osx/cocos_denshion/cocos_denshion_include/SimpleAudioEngine.h +90 -0
- data/vendor/vendor-osx/cocos_denshion/libCocosDenshion.a +0 -0
- data/vendor/vendor-osx/kazmath/kazmath.bridgesupport +865 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/GL/mat4stack.h +51 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/GL/matrix.h +58 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/aabb.h +53 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/kazmath.h +39 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/mat3.h +75 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/mat4.h +93 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/neon_matrix_impl.h +41 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/plane.h +70 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/quaternion.h +113 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/ray2.h +50 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/utility.h +74 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/vec2.h +64 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/vec3.h +68 -0
- data/vendor/vendor-osx/kazmath/kazmath_include/vec4.h +68 -0
- data/vendor/vendor-osx/kazmath/libkazmath.a +0 -0
- metadata +353 -57
- checksums.yaml +0 -15
- data/bin/joybox +0 -49
- data/command/joybox/USAGE +0 -24
- data/motion/joybox-ios/configuration/debug.rb +0 -27
- data/motion/joybox-ios/debug/debug.rb +0 -10
- data/motion/joybox-osx/configuration/debug.rb +0 -27
- data/motion/joybox-osx/configuration/sprite_view.rb +0 -91
- data/motion/joybox-osx/debug/debug.rb +0 -10
- data/motion/joybox/core/ns_object.rb +0 -8
- data/spec/lib/joybox/cocos2d/cocos2d_spec.rb +0 -7
- data/spec/lib/joybox/cocos2d/macros_spec.rb +0 -37
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/cocos2d-ios-exceptions.bridgesupport +0 -39
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/gen_cocos2d_bridgesupport.sh +0 -17
- data/vendor/vendor-ios/cocos_2d/cocos_2d_include/gen_cocos2d_complement.sh +0 -17
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
joybox (
|
4
|
+
joybox (1.1.0)
|
5
5
|
rake
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
diff-lcs (1.2.
|
11
|
-
rake (10.0
|
10
|
+
diff-lcs (1.2.4)
|
11
|
+
rake (10.1.0)
|
12
12
|
rspec (2.13.0)
|
13
13
|
rspec-core (~> 2.13.0)
|
14
14
|
rspec-expectations (~> 2.13.0)
|
@@ -23,5 +23,5 @@ PLATFORMS
|
|
23
23
|
|
24
24
|
DEPENDENCIES
|
25
25
|
joybox!
|
26
|
-
rake
|
26
|
+
rake
|
27
27
|
rspec
|
data/README.md
CHANGED
@@ -1,24 +1,63 @@
|
|
1
|
-
# Joybox
|
1
|
+
# Joybox [![Build Status](https://travis-ci.org/rubymotion/Joybox.png?branch=master)](https://travis-ci.org/rubymotion/Joybox)
|
2
2
|
Introduced at [#Inspect 2013](http://www.rubymotion.com/conference/), Joybox is the easiest way to build 2D games for iPhones and iPads using [RubyMotion](http://www.rubymotion.com/). Joybox combines the most popular and widely used 2D game engine for iOS, [Cocos2D](http://www.cocos2d-iphone.org/), folds in the amazing [Box2D](http://box2d.org/) physics engine, and then wraps them up into a clean Ruby API that will make game development faster and more enjoyable for both beginners and experts alike.
|
3
3
|
|
4
4
|
For more information, see the presentation: [Cocos2D, an Easier Way](https://speakerdeck.com/curveberyl/cocos2d-an-easier-way).
|
5
5
|
|
6
|
-
## Latest version (
|
7
|
-
|
8
|
-
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
*
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
*
|
6
|
+
## Latest version (1.1.0)
|
7
|
+
**Physics**
|
8
|
+
|
9
|
+
* Support for all Shapes and Listeners.
|
10
|
+
* Filters, AABB computations, Queries and Ray Casts.
|
11
|
+
* Collision support for Physics Sprites.
|
12
|
+
* Experimental support for actions on Physics Sprites.
|
13
|
+
* Physics Debug Draw.
|
14
|
+
|
15
|
+
**Effects and Background Music**
|
16
|
+
|
17
|
+
* AudioEffect and BackgroundAudio to playback background music and special effects.
|
18
|
+
|
19
|
+
**Tile Maps Support**
|
20
|
+
|
21
|
+
* Support for TMX Maps using the TileMap class.
|
22
|
+
|
23
|
+
**Actions**
|
24
|
+
|
25
|
+
* Complete actions
|
26
|
+
|
27
|
+
**Gestures**
|
28
|
+
|
29
|
+
* Support the default gestures on OSX.
|
30
|
+
|
31
|
+
**Commands**
|
32
|
+
|
33
|
+
* Adds joybox:retina command to create a Retina version of a TMX Map.
|
34
|
+
|
35
|
+
**Sprites**
|
36
|
+
|
37
|
+
* Support for custom options on the Sprite initialization.
|
38
|
+
|
39
|
+
**Source Code**
|
40
|
+
|
41
|
+
* The commands and templates now install automatically.
|
42
|
+
* Added 218 specifications and 617 requirements.
|
43
|
+
|
44
|
+
**Critical Changes**
|
45
|
+
|
46
|
+
* Node: The method add_childs is now add_children.
|
47
|
+
|
48
|
+
* SpriteFrameCache: The method where now starts from 1 instead of 0.
|
49
|
+
|
50
|
+
* Animation: The delay method is now delay_units, and total_delay is now delay_per_unit.
|
51
|
+
|
52
|
+
* Menu: The method align_items_in_columns now receive an array for defining how many columns and how many items in which of them.
|
53
|
+
|
54
|
+
* Physics: Now every object returns their values in pixel coordinates and degrees, if you still need to use the metric values you can access them with the prefix metric_. For example: metric_position.
|
55
|
+
|
56
|
+
* World: The Method continuos_physics is now deprecated.
|
57
|
+
|
58
|
+
* Physics Collisions: Now for use when_collide method of the World instance, you need to pass an instance of a PhysicsSprite and it will return in the block the colliding physics sprite if available, or the body that is colliding.
|
59
|
+
|
60
|
+
* Point: The methods to and from pixel coordinates are now inverted, there was an incorrect naming.
|
22
61
|
|
23
62
|
## Documentation and Getting Started
|
24
63
|
If you are looking for the installation process and the documentation, please visit: [joybox.io](http://joybox.io)
|
@@ -39,11 +78,17 @@ rake clean
|
|
39
78
|
rake
|
40
79
|
```
|
41
80
|
|
81
|
+
## Troubleshoot the REPL
|
82
|
+
If the iOS application starts in landscape orientation, please rotate and return it to the original orientation.
|
83
|
+
|
84
|
+
(cmd + <= & cmd + =>)
|
85
|
+
|
42
86
|
## Feedback and Help
|
43
|
-
For questions
|
87
|
+
For questions and feedback use the project's [Google Group](https://groups.google.com/forum/?fromgroups#!forum/joybox-wrapper)
|
44
88
|
|
45
|
-
|
89
|
+
For bug reports use the project's [Issue Tracker](https://github.com/rubymotion/Joybox/issues).
|
46
90
|
|
91
|
+
## Contributions
|
47
92
|
If you wish to help us to stop the madness, there are some ways you can do it:
|
48
93
|
|
49
94
|
* Joybox Wrapper (Ruby): This repository ;)
|
@@ -59,12 +104,11 @@ To contribute just:
|
|
59
104
|
5. Create new Pull Request
|
60
105
|
|
61
106
|
## License
|
62
|
-
|
63
107
|
Joybox is released under the MIT License.
|
64
|
-
|
65
108
|
|
66
109
|
## Authors
|
67
|
-
|
68
110
|
**Cocos2D**: Ricardo Quesada, Zynga and contributors [cocos2d for iPhone](http://www.cocos2d-iphone.org)
|
111
|
+
|
69
112
|
**Box2D**: Erin Catto [Box2D | A 2D Physics Engine for Games](http://box2d.org)
|
113
|
+
|
70
114
|
**Joybox**: [Juan José Karam](https://github.com/CurveBeryl) [@JuanKaram](https://twitter.com/JuanKaram) and [Gabriel Sosa](https://github.com/mexinsane) [@mexinsane](https://twitter.com/mexinsane) and contributors
|
data/Rakefile
CHANGED
@@ -1,12 +1,30 @@
|
|
1
1
|
$:.unshift("/Library/RubyMotion/lib")
|
2
|
-
require 'motion/project/template/osx'
|
2
|
+
require 'motion/project/template/osx' if ENV['osx']
|
3
|
+
require 'motion/project/template/ios' unless ENV['osx']
|
3
4
|
require 'bundler'
|
4
5
|
Bundler.require
|
5
6
|
|
7
|
+
# Borrowed from BubbleWrap: https://github.com/rubymotion/BubbleWrap
|
8
|
+
# Thanks BubbleWrap Team! http://bubblewrap.io
|
9
|
+
module Motion; module Project
|
10
|
+
class Config
|
11
|
+
def spec_files=(spec_files)
|
12
|
+
@spec_files = spec_files
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end; end
|
6
16
|
|
7
17
|
Motion::Project::App.setup do |app|
|
8
|
-
# Use `rake config' to see complete project settings.
|
9
18
|
app.name = 'Joybox'
|
10
19
|
app.identifier = 'com.rubymotion.joybox'
|
11
|
-
app.version = "0.0
|
12
|
-
|
20
|
+
app.version = "1.0.0"
|
21
|
+
|
22
|
+
if app.template != :ios
|
23
|
+
app.spec_files -= Dir.glob("./spec/motion/joybox-ios/**/*.rb")
|
24
|
+
app.files -= Dir.glob("./app/ios/**/*.rb")
|
25
|
+
else
|
26
|
+
app.interface_orientations = [:landscape_left, :landscape_right]
|
27
|
+
app.spec_files -= Dir.glob("./spec/motion/joybox-osx/**/*.rb")
|
28
|
+
app.files -= Dir.glob("./app/osx/**/*.rb")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
|
3
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
4
|
+
|
5
|
+
@director = Joybox::Configuration.setup do
|
6
|
+
director display_stats: true
|
7
|
+
debug repl: true,
|
8
|
+
physics: [:shapes, :aabb]
|
9
|
+
end
|
10
|
+
|
11
|
+
@navigation_controller = UINavigationController.alloc.initWithRootViewController(@director)
|
12
|
+
@navigation_controller.navigationBarHidden = true
|
13
|
+
|
14
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
15
|
+
@window.setRootViewController(@navigation_controller)
|
16
|
+
@window.makeKeyAndVisible
|
17
|
+
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def applicationWillResignActive(app)
|
22
|
+
@director.pause if @navigation_controller.visibleViewController == @director
|
23
|
+
end
|
24
|
+
|
25
|
+
def applicationDidBecomeActive(app)
|
26
|
+
@director.resume if @navigation_controller.visibleViewController == @director
|
27
|
+
end
|
28
|
+
|
29
|
+
def applicationDidEnterBackground(app)
|
30
|
+
@director.stop_animation if @navigation_controller.visibleViewController == @director
|
31
|
+
end
|
32
|
+
|
33
|
+
def applicationWillEnterForeground(app)
|
34
|
+
@director.start_animation if @navigation_controller.visibleViewController == @director
|
35
|
+
end
|
36
|
+
|
37
|
+
def applicationWillTerminate(app)
|
38
|
+
@director.end
|
39
|
+
end
|
40
|
+
|
41
|
+
def applicationDidReceiveMemoryWarning(app)
|
42
|
+
@director.purge_cached_data
|
43
|
+
end
|
44
|
+
|
45
|
+
def applicationSignificantTimeChange(app)
|
46
|
+
@director.set_next_delta_time_zero true
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
|
3
|
+
def applicationDidFinishLaunching(notification)
|
4
|
+
buildMenu
|
5
|
+
buildWindow
|
6
|
+
end
|
7
|
+
|
8
|
+
def buildWindow
|
9
|
+
@director = Joybox::Configuration.setup do
|
10
|
+
director display_stats: true
|
11
|
+
debug repl:true,
|
12
|
+
physics: [:shapes, :aabb, :center_of_mass]
|
13
|
+
end
|
14
|
+
|
15
|
+
@main_window = NSWindow.alloc.initWithContentRect([[240, 180], [480, 320]],
|
16
|
+
styleMask: NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
|
17
|
+
backing: NSBackingStoreBuffered,
|
18
|
+
defer: false)
|
19
|
+
|
20
|
+
@main_window.title = NSBundle.mainBundle.infoDictionary['CFBundleName']
|
21
|
+
@main_window.contentView.addSubview(@director.view)
|
22
|
+
@main_window.orderFrontRegardless
|
23
|
+
|
24
|
+
@director.run_with_scene(GameLayer.scene)
|
25
|
+
end
|
26
|
+
end
|
data/app/osx/menu.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
def buildMenu
|
3
|
+
@mainMenu = NSMenu.new
|
4
|
+
|
5
|
+
appName = NSBundle.mainBundle.infoDictionary['CFBundleName']
|
6
|
+
addMenu(appName) do
|
7
|
+
addItemWithTitle("About #{appName}", action: 'orderFrontStandardAboutPanel:', keyEquivalent: '')
|
8
|
+
addItem(NSMenuItem.separatorItem)
|
9
|
+
addItemWithTitle('Preferences', action: 'openPreferences:', keyEquivalent: ',')
|
10
|
+
addItem(NSMenuItem.separatorItem)
|
11
|
+
servicesItem = addItemWithTitle('Services', action: nil, keyEquivalent: '')
|
12
|
+
NSApp.servicesMenu = servicesItem.submenu = NSMenu.new
|
13
|
+
addItem(NSMenuItem.separatorItem)
|
14
|
+
addItemWithTitle("Hide #{appName}", action: 'hide:', keyEquivalent: 'h')
|
15
|
+
item = addItemWithTitle('Hide Others', action: 'hideOtherApplications:', keyEquivalent: 'H')
|
16
|
+
item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
|
17
|
+
addItemWithTitle('Show All', action: 'unhideAllApplications:', keyEquivalent: '')
|
18
|
+
addItem(NSMenuItem.separatorItem)
|
19
|
+
addItemWithTitle("Quit #{appName}", action: 'terminate:', keyEquivalent: 'q')
|
20
|
+
end
|
21
|
+
|
22
|
+
NSApp.windowsMenu = addMenu('Window') do
|
23
|
+
addItemWithTitle('Minimize', action: 'performMiniaturize:', keyEquivalent: 'm')
|
24
|
+
addItemWithTitle('Zoom', action: 'performZoom:', keyEquivalent: '')
|
25
|
+
addItem(NSMenuItem.separatorItem)
|
26
|
+
addItemWithTitle('Bring All To Front', action: 'arrangeInFront:', keyEquivalent: '')
|
27
|
+
end.menu
|
28
|
+
|
29
|
+
NSApp.helpMenu = addMenu('Help') do
|
30
|
+
addItemWithTitle("#{appName} Help", action: 'showHelp:', keyEquivalent: '?')
|
31
|
+
end.menu
|
32
|
+
|
33
|
+
NSApp.mainMenu = @mainMenu
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def addMenu(title, &b)
|
39
|
+
item = createMenu(title, &b)
|
40
|
+
@mainMenu.addItem item
|
41
|
+
item
|
42
|
+
end
|
43
|
+
|
44
|
+
def createMenu(title, &b)
|
45
|
+
menu = NSMenu.alloc.initWithTitle(title)
|
46
|
+
menu.instance_eval(&b) if b
|
47
|
+
item = NSMenuItem.alloc.initWithTitle(title, action: nil, keyEquivalent: '')
|
48
|
+
item.submenu = menu
|
49
|
+
item
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Joybox
|
2
|
+
module Command
|
3
|
+
class Image
|
4
|
+
|
5
|
+
def initialize(file_path, suffix)
|
6
|
+
@file_path = file_path
|
7
|
+
@suffix = suffix
|
8
|
+
end
|
9
|
+
|
10
|
+
def scale(scale_factor)
|
11
|
+
retina_file_path = File.basename(@file_path, '.*') + @suffix + File.extname(@file_path)
|
12
|
+
|
13
|
+
if File.exists? retina_file_path
|
14
|
+
Motion::Project::App.log 'Warning', "Tileset image #{retina_file_path} already exists"
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
FileUtils.copy(@file_path, retina_file_path)
|
19
|
+
image_height = `sips -g pixelHeight #{retina_file_path}`.scan(/pixelHeight: (\d+)/).last.first
|
20
|
+
image_width = `sips -g pixelWidth #{retina_file_path}`.scan(/pixelWidth: (\d+)/).last.first
|
21
|
+
`sips -z #{image_height.to_i * scale_factor} #{image_width.to_i * scale_factor} #{retina_file_path}`
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
def underscore
|
4
|
+
gsub(/::/, '/').
|
5
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
6
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
7
|
+
tr("-", "_").
|
8
|
+
downcase
|
9
|
+
end
|
10
|
+
|
11
|
+
def titleize
|
12
|
+
gsub(/([A-Z])/, '_\1').split(/_/).map(&:capitalize).join
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path('../string.rb', __FILE__)
|
2
|
+
|
3
|
+
module Joybox
|
4
|
+
module Command
|
5
|
+
class Template
|
6
|
+
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
def initialize(name, klass)
|
10
|
+
@name = name.titleize
|
11
|
+
@klass = klass.downcase
|
12
|
+
|
13
|
+
templates_directory = File.expand_path("../../templates/", __FILE__)
|
14
|
+
@template_class_file = File.expand_path("#{klass}.erb", templates_directory)
|
15
|
+
@template_spec_file = File.expand_path("#{klass}_spec.erb", templates_directory)
|
16
|
+
end
|
17
|
+
|
18
|
+
def save
|
19
|
+
begin
|
20
|
+
app_directory = find_directory('app')
|
21
|
+
spec_directory = find_directory('spec')
|
22
|
+
rescue
|
23
|
+
Motion::Project::App.log 'Error', 'The command needs to be run inside of a RubyMotion project'
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
class_file = File.join(app_directory, "#{@klass}s/#{name.underscore}_#{@klass}.rb")
|
28
|
+
test_file = File.join(spec_directory, "#{@klass}s/#{name.underscore}_#{@klass}_spec.rb")
|
29
|
+
|
30
|
+
create_file(class_file, @template_class_file)
|
31
|
+
create_file(test_file, @template_spec_file)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def find_directory(directory)
|
37
|
+
finded_directories = Dir.glob(directory)
|
38
|
+
|
39
|
+
if finded_directories.size != 1
|
40
|
+
find_app_directory(File.join('..', directory))
|
41
|
+
else
|
42
|
+
finded_directories[0]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_file(file_path, template_path)
|
47
|
+
return Motion::Project::App.log 'Warning', "#{file_path} exists" if File.exists?(file_path)
|
48
|
+
|
49
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
50
|
+
File.open(file_path, "w") do |file|
|
51
|
+
file << ERB.new(File.read(template_path)).result(binding)
|
52
|
+
end
|
53
|
+
|
54
|
+
Motion::Project::App.log 'Create', "#{file_path}"
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "rexml/document"
|
2
|
+
|
3
|
+
module Joybox
|
4
|
+
module Command
|
5
|
+
class TMX
|
6
|
+
|
7
|
+
include REXML
|
8
|
+
|
9
|
+
def initialize(file_path, suffix)
|
10
|
+
@file_path = File.basename(file_path, '.*') + suffix + File.extname(file_path)
|
11
|
+
@suffix = suffix
|
12
|
+
@map_document = Document.new File.read(file_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def scale(scale_factor)
|
16
|
+
@scale_factor = scale_factor
|
17
|
+
|
18
|
+
scale_map(XPath.first(@map_document, "//map"))
|
19
|
+
XPath.each(@map_document, "//map/tileset") { |tileset| scale_tileset(tileset) }
|
20
|
+
XPath.each(@map_document, "//map/tileset/image") { |image| scale_image(image) }
|
21
|
+
XPath.each(@map_document, "//map/objectgroup/object") { |object| scale_object(object) }
|
22
|
+
|
23
|
+
save
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def scale_map(map)
|
29
|
+
scale_attribute(map, 'tilewidth')
|
30
|
+
scale_attribute(map, 'tileheight')
|
31
|
+
end
|
32
|
+
|
33
|
+
def scale_tileset(tileset)
|
34
|
+
scale_attribute(tileset, 'tilewidth')
|
35
|
+
scale_attribute(tileset, 'tileheight')
|
36
|
+
scale_attribute(tileset, 'margin')
|
37
|
+
scale_attribute(tileset, 'spacing')
|
38
|
+
end
|
39
|
+
|
40
|
+
def scale_image(image)
|
41
|
+
scale_attribute(image, 'width')
|
42
|
+
scale_attribute(image, 'height')
|
43
|
+
|
44
|
+
image_file = image.attributes['source']
|
45
|
+
|
46
|
+
if File.exists? image_file
|
47
|
+
image = Image.new(image_file, @suffix)
|
48
|
+
image.scale(@scale_factor)
|
49
|
+
else
|
50
|
+
Motion::Project::App.log 'Warning', "Tileset image #{image_file} does not exist"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def scale_object(object)
|
55
|
+
scale_attribute(object, 'x')
|
56
|
+
scale_attribute(object, 'y')
|
57
|
+
scale_attribute(object, 'width')
|
58
|
+
scale_attribute(object, 'height')
|
59
|
+
end
|
60
|
+
|
61
|
+
def scale_attribute(element, attribute)
|
62
|
+
if element.attributes.has_key? attribute
|
63
|
+
element.attributes[attribute] = element.attributes[attribute].to_i * @scale_factor
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def save
|
68
|
+
File.open(@file_path, "w") do |file|
|
69
|
+
file << @map_document
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|