joybox 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +27 -0
- data/LICENSE +22 -0
- data/README.md +86 -0
- data/Rakefile +14 -0
- data/app/app_delegate.rb +49 -0
- data/app/layers/box2d_layer.rb +109 -0
- data/app/layers/cocos2d_layer.rb +14 -0
- data/app/layers/cocos_motion_layer.rb +145 -0
- data/app/layers/menu_layer.rb +59 -0
- data/joybox.gemspec +25 -0
- data/lib/joybox.rb +47 -0
- data/lib/joybox/box2d/body.rb +106 -0
- data/lib/joybox/box2d/world.rb +79 -0
- data/lib/joybox/cocos2d/actions/actions.rb +7 -0
- data/lib/joybox/cocos2d/actions/move.rb +31 -0
- data/lib/joybox/cocos2d/actions/repeat.rb +24 -0
- data/lib/joybox/cocos2d/actions/rotate.rb +31 -0
- data/lib/joybox/cocos2d/actions/scale.rb +31 -0
- data/lib/joybox/cocos2d/actions/sequence.rb +22 -0
- data/lib/joybox/cocos2d/actions/skew.rb +36 -0
- data/lib/joybox/cocos2d/cocos2d.rb +15 -0
- data/lib/joybox/cocos2d/common/cg_point.rb +37 -0
- data/lib/joybox/cocos2d/common/color.rb +49 -0
- data/lib/joybox/cocos2d/common/gc_size.rb +39 -0
- data/lib/joybox/cocos2d/common/ns_set.rb +5 -0
- data/lib/joybox/cocos2d/common/numeric.rb +14 -0
- data/lib/joybox/cocos2d/common/screen.rb +39 -0
- data/lib/joybox/cocos2d/common/ui_touch.rb +15 -0
- data/lib/joybox/cocos2d/configuration/configuration.rb +68 -0
- data/lib/joybox/cocos2d/configuration/file_utils.rb +33 -0
- data/lib/joybox/cocos2d/configuration/gl_view.rb +44 -0
- data/lib/joybox/cocos2d/configuration/texture_2d.rb +27 -0
- data/lib/joybox/cocos2d/core/layer.rb +87 -0
- data/lib/joybox/cocos2d/core/node.rb +26 -0
- data/lib/joybox/cocos2d/core/physics_sprite.rb +52 -0
- data/lib/joybox/cocos2d/core/scene.rb +24 -0
- data/lib/joybox/cocos2d/core/sprite.rb +43 -0
- data/lib/joybox/cocos2d/core/sprite_batch.rb +24 -0
- data/lib/joybox/cocos2d/director.rb +43 -0
- data/lib/joybox/cocos2d/macros.rb +234 -0
- data/lib/joybox/cocos2d/ui/label.rb +34 -0
- data/lib/joybox/cocos2d/ui/menu.rb +25 -0
- data/lib/joybox/cocos2d/ui/menu_image.rb +22 -0
- data/lib/joybox/cocos2d/ui/menu_label.rb +45 -0
- data/lib/joybox/cocos2d/ui/ui.rb +7 -0
- data/lib/joybox/version.rb +3 -0
- data/resources/box2d/blocks_sprite_sheet.png +0 -0
- data/resources/cocos_motion/dot.png +0 -0
- data/resources/cocos_motion/dot_selected.png +0 -0
- data/resources/cocos_motion/grossini.png +0 -0
- data/resources/cocos_motion/grossinis_sister.png +0 -0
- data/resources/cocos_motion/grossinis_sister_two.png +0 -0
- data/resources/cocos_motion/left_arrow.png +0 -0
- data/resources/cocos_motion/left_arrow_selected.png +0 -0
- data/resources/cocos_motion/right_arrow.png +0 -0
- data/resources/cocos_motion/right_arrow_selected.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/spec/lib/joybox/cocos2d/cocos2d_spec.rb +7 -0
- data/spec/lib/joybox/cocos2d/macros_spec.rb +37 -0
- data/spec/main_spec.rb +9 -0
- data/vendor/Box2D.framework/Box2D +0 -0
- data/vendor/Box2D.framework/Box2D.framework.bridgesupport +166 -0
- data/vendor/Box2D.framework/Versions/A/Box2D +0 -0
- data/vendor/Box2D.framework/Versions/A/Headers/Collision/B2DContactListener.h +25 -0
- data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DEdgeShape.h +17 -0
- data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DPolygonShape.h +16 -0
- data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DShape.h +15 -0
- data/vendor/Box2D.framework/Versions/A/Headers/Dynamics/B2DBody.h +43 -0
- data/vendor/Box2D.framework/Versions/A/Headers/Dynamics/B2DWorld.h +41 -0
- data/vendor/Box2D.framework/Versions/A/Resources/Box2DConfig.cmake +3 -0
- data/vendor/Box2D.framework/Versions/A/Resources/CMakeLists.txt +205 -0
- data/vendor/Cocos2D/Cocos2D.bridgesupport +7808 -0
- data/vendor/Cocos2D/include/CCAction.h +195 -0
- data/vendor/Cocos2D/include/CCActionCamera.h +73 -0
- data/vendor/Cocos2D/include/CCActionCatmullRom.h +139 -0
- data/vendor/Cocos2D/include/CCActionEase.h +159 -0
- data/vendor/Cocos2D/include/CCActionGrid.h +165 -0
- data/vendor/Cocos2D/include/CCActionGrid3D.h +205 -0
- data/vendor/Cocos2D/include/CCActionInstant.h +227 -0
- data/vendor/Cocos2D/include/CCActionInterval.h +431 -0
- data/vendor/Cocos2D/include/CCActionManager.h +113 -0
- data/vendor/Cocos2D/include/CCActionPageTurn3D.h +42 -0
- data/vendor/Cocos2D/include/CCActionProgressTimer.h +59 -0
- data/vendor/Cocos2D/include/CCActionTiledGrid.h +211 -0
- data/vendor/Cocos2D/include/CCActionTween.h +62 -0
- data/vendor/Cocos2D/include/CCAnimation.h +150 -0
- data/vendor/Cocos2D/include/CCAnimationCache.h +74 -0
- data/vendor/Cocos2D/include/CCArray.h +119 -0
- data/vendor/Cocos2D/include/CCAtlasNode.h +96 -0
- data/vendor/Cocos2D/include/CCCamera.h +98 -0
- data/vendor/Cocos2D/include/CCConfiguration.h +126 -0
- data/vendor/Cocos2D/include/CCDirector.h +344 -0
- data/vendor/Cocos2D/include/CCDirectorIOS.h +104 -0
- data/vendor/Cocos2D/include/CCDrawingPrimitives.h +139 -0
- data/vendor/Cocos2D/include/CCES2Renderer.h +83 -0
- data/vendor/Cocos2D/include/CCESRenderer.h +54 -0
- data/vendor/Cocos2D/include/CCFileUtils.h +188 -0
- data/vendor/Cocos2D/include/CCGL.h +72 -0
- data/vendor/Cocos2D/include/CCGLProgram.h +150 -0
- data/vendor/Cocos2D/include/CCGLView.h +160 -0
- data/vendor/Cocos2D/include/CCGrabber.h +44 -0
- data/vendor/Cocos2D/include/CCGrid.h +130 -0
- data/vendor/Cocos2D/include/CCLabelAtlas.h +68 -0
- data/vendor/Cocos2D/include/CCLabelBMFont.h +216 -0
- data/vendor/Cocos2D/include/CCLabelTTF.h +132 -0
- data/vendor/Cocos2D/include/CCLayer.h +280 -0
- data/vendor/Cocos2D/include/CCMenu.h +100 -0
- data/vendor/Cocos2D/include/CCMenuItem.h +423 -0
- data/vendor/Cocos2D/include/CCMotionStreak.h +87 -0
- data/vendor/Cocos2D/include/CCNS.h +54 -0
- data/vendor/Cocos2D/include/CCNode+Debug.h +39 -0
- data/vendor/Cocos2D/include/CCNode.h +569 -0
- data/vendor/Cocos2D/include/CCParallaxNode.h +50 -0
- data/vendor/Cocos2D/include/CCParticleBatchNode.h +99 -0
- data/vendor/Cocos2D/include/CCParticleExamples.h +95 -0
- data/vendor/Cocos2D/include/CCParticleSystem.h +453 -0
- data/vendor/Cocos2D/include/CCParticleSystemQuad.h +73 -0
- data/vendor/Cocos2D/include/CCProfiling.h +89 -0
- data/vendor/Cocos2D/include/CCProgressTimer.h +94 -0
- data/vendor/Cocos2D/include/CCProtocols.h +132 -0
- data/vendor/Cocos2D/include/CCRenderTexture.h +139 -0
- data/vendor/Cocos2D/include/CCScene.h +43 -0
- data/vendor/Cocos2D/include/CCScheduler.h +230 -0
- data/vendor/Cocos2D/include/CCShaderCache.h +60 -0
- data/vendor/Cocos2D/include/CCSprite.h +288 -0
- data/vendor/Cocos2D/include/CCSpriteBatchNode.h +138 -0
- data/vendor/Cocos2D/include/CCSpriteFrame.h +126 -0
- data/vendor/Cocos2D/include/CCSpriteFrameCache.h +121 -0
- data/vendor/Cocos2D/include/CCTMXLayer.h +164 -0
- data/vendor/Cocos2D/include/CCTMXObjectGroup.h +67 -0
- data/vendor/Cocos2D/include/CCTMXTiledMap.h +145 -0
- data/vendor/Cocos2D/include/CCTMXXMLParser.h +217 -0
- data/vendor/Cocos2D/include/CCTexture2D.h +357 -0
- data/vendor/Cocos2D/include/CCTextureAtlas.h +188 -0
- data/vendor/Cocos2D/include/CCTextureCache.h +146 -0
- data/vendor/Cocos2D/include/CCTexturePVR.h +129 -0
- data/vendor/Cocos2D/include/CCTileMapAtlas.h +83 -0
- data/vendor/Cocos2D/include/CCTouchDelegateProtocol.h +75 -0
- data/vendor/Cocos2D/include/CCTouchDispatcher.h +120 -0
- data/vendor/Cocos2D/include/CCTouchHandler.h +93 -0
- data/vendor/Cocos2D/include/CCTransition.h +296 -0
- data/vendor/Cocos2D/include/CCTransitionPageTurn.h +60 -0
- data/vendor/Cocos2D/include/CCTransitionProgress.h +62 -0
- data/vendor/Cocos2D/include/CCVertex.h +36 -0
- data/vendor/Cocos2D/include/CGPointExtension.h +344 -0
- data/vendor/Cocos2D/include/CocosDenshion/CDAudioManager.h +243 -0
- data/vendor/Cocos2D/include/CocosDenshion/CDConfig.h +60 -0
- data/vendor/Cocos2D/include/CocosDenshion/CDOpenALSupport.h +77 -0
- data/vendor/Cocos2D/include/CocosDenshion/CDXPropertyModifierAction.h +45 -0
- data/vendor/Cocos2D/include/CocosDenshion/CocosDenshion.h +440 -0
- data/vendor/Cocos2D/include/CocosDenshion/SimpleAudioEngine.h +90 -0
- data/vendor/Cocos2D/include/NSThread+performBlock.h +22 -0
- data/vendor/Cocos2D/include/OpenGL_Internal.h +86 -0
- data/vendor/Cocos2D/include/RubyMotionSchedule.h +7 -0
- data/vendor/Cocos2D/include/TGAlib.h +55 -0
- data/vendor/Cocos2D/include/TransformUtils.h +36 -0
- data/vendor/Cocos2D/include/ZipUtils.h +91 -0
- data/vendor/Cocos2D/include/base64.h +33 -0
- data/vendor/Cocos2D/include/ccCArray.h +229 -0
- data/vendor/Cocos2D/include/ccConfig.h +245 -0
- data/vendor/Cocos2D/include/ccDeprecated.h +300 -0
- data/vendor/Cocos2D/include/ccGLStateCache.h +138 -0
- data/vendor/Cocos2D/include/ccMacros.h +353 -0
- data/vendor/Cocos2D/include/ccShader_PositionColor_frag.h +12 -0
- data/vendor/Cocos2D/include/ccShader_PositionColor_vert.h +17 -0
- data/vendor/Cocos2D/include/ccShader_PositionTextureA8Color_frag.h +16 -0
- data/vendor/Cocos2D/include/ccShader_PositionTextureA8Color_vert.h +21 -0
- data/vendor/Cocos2D/include/ccShader_PositionTextureColorAlphaTest_frag.h +23 -0
- data/vendor/Cocos2D/include/ccShader_PositionTextureColor_frag.h +14 -0
- data/vendor/Cocos2D/include/ccShader_PositionTextureColor_vert.h +22 -0
- data/vendor/Cocos2D/include/ccShader_PositionTexture_frag.h +13 -0
- data/vendor/Cocos2D/include/ccShader_PositionTexture_uColor_frag.h +16 -0
- data/vendor/Cocos2D/include/ccShader_PositionTexture_uColor_vert.h +18 -0
- data/vendor/Cocos2D/include/ccShader_PositionTexture_vert.h +17 -0
- data/vendor/Cocos2D/include/ccShader_Position_uColor_frag.h +12 -0
- data/vendor/Cocos2D/include/ccShader_Position_uColor_vert.h +19 -0
- data/vendor/Cocos2D/include/ccShaders.h +45 -0
- data/vendor/Cocos2D/include/ccTypes.h +374 -0
- data/vendor/Cocos2D/include/ccUtils.h +36 -0
- data/vendor/Cocos2D/include/cocos2d.h +178 -0
- data/vendor/Cocos2D/include/kazmath/GL/mat4stack.h +51 -0
- data/vendor/Cocos2D/include/kazmath/GL/matrix.h +58 -0
- data/vendor/Cocos2D/include/kazmath/aabb.h +53 -0
- data/vendor/Cocos2D/include/kazmath/kazmath.h +39 -0
- data/vendor/Cocos2D/include/kazmath/mat3.h +75 -0
- data/vendor/Cocos2D/include/kazmath/mat4.h +93 -0
- data/vendor/Cocos2D/include/kazmath/neon_matrix_impl.h +41 -0
- data/vendor/Cocos2D/include/kazmath/plane.h +70 -0
- data/vendor/Cocos2D/include/kazmath/quaternion.h +113 -0
- data/vendor/Cocos2D/include/kazmath/ray2.h +50 -0
- data/vendor/Cocos2D/include/kazmath/utility.h +74 -0
- data/vendor/Cocos2D/include/kazmath/vec2.h +64 -0
- data/vendor/Cocos2D/include/kazmath/vec3.h +68 -0
- data/vendor/Cocos2D/include/kazmath/vec4.h +68 -0
- data/vendor/Cocos2D/include/uthash.h +972 -0
- data/vendor/Cocos2D/include/utlist.h +490 -0
- data/vendor/Cocos2D/libCocosDenshion.a +0 -0
- data/vendor/Cocos2D/libcocos2d.a +0 -0
- metadata +277 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDgxOGZjNTYyYjQwZDVhOGEyNmUxYjRmNzY0YzAzOTRlY2MwYmUyMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmVkYzQ0NGZjZGQxZjY2ZDVjZjFlZGNjZWJiOWVmZDhhYmIxNjk5Nw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjBiOWZlNGZhY2UwZWVmNzZmMDA1MWRiZDY3N2Y2YjhiMzQxYzNhNDMyNmE1
|
10
|
+
NjVmNDc5NWE4OGNiNjRiOWMwOTg2MjhiMThkMmI4MGI0ZmUzYTVlYzk2ZjA5
|
11
|
+
N2JmN2E5OTNkZDVjNTdjN2NiM2NhYWE1MDM5MjYzOGRkMjg4NDE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDliOGUwNDhlMDA1N2QzZGFiOWIzNDU1NDE4NWNhMjA1NTdlYjAwMGViOTE2
|
14
|
+
YTNiMTJmOTZiYjhlM2Y1ZDI4ZjkxNzRlODhkNzg4NTFlZmE1YTFlYmUyNzY3
|
15
|
+
MWIyZjY2ZWM5MGJjOTQxMzc3NDI1MjAyYzI2ZGFhOTFlMmI5OTE=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
joybox (0.0.1)
|
5
|
+
rake
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.3)
|
11
|
+
rake (10.0.4)
|
12
|
+
rspec (2.13.0)
|
13
|
+
rspec-core (~> 2.13.0)
|
14
|
+
rspec-expectations (~> 2.13.0)
|
15
|
+
rspec-mocks (~> 2.13.0)
|
16
|
+
rspec-core (2.13.1)
|
17
|
+
rspec-expectations (2.13.0)
|
18
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
19
|
+
rspec-mocks (2.13.1)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
joybox!
|
26
|
+
rake (= 10.0.4)
|
27
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Juan Jose Karam
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Joybox
|
2
|
+
|
3
|
+
Introduced at [#Inspect 2013](http://www.rubymotion.com/conference/),
|
4
|
+
Joybox is the easiest way to build 2D games for iPhones and iPads
|
5
|
+
using [RubyMotion](http://www.rubymotion.com/). Joybox combines the
|
6
|
+
most popular and widely used 2D game engine for iOS,
|
7
|
+
[Cocos2D](http://www.cocos2d-iphone.org/), folds in the amazing
|
8
|
+
[Box2D](http://box2d.org/) physics engine, and then wraps them up into
|
9
|
+
a clean Ruby API that will make game development faster and more
|
10
|
+
enjoyable for both beginners and experts alike.
|
11
|
+
|
12
|
+
For more information, see the presentation: [Cocos2D, an Easier
|
13
|
+
Way](https://speakerdeck.com/curveberyl/cocos2d-an-easier-way).
|
14
|
+
|
15
|
+
## Feedback and Help
|
16
|
+
|
17
|
+
For questions, feedback, bug reports, use the project's [Issue
|
18
|
+
Tracker](https://github.com/rubymotion/Joybox/issues).
|
19
|
+
|
20
|
+
## Getting Started
|
21
|
+
|
22
|
+
### Installation with RubyGems
|
23
|
+
|
24
|
+
First install Joybox from RubyGems. Run:
|
25
|
+
|
26
|
+
gem install joybox
|
27
|
+
|
28
|
+
Next, add to your Rakefile:
|
29
|
+
|
30
|
+
require 'joybox'
|
31
|
+
|
32
|
+
### Installation with Bundler
|
33
|
+
|
34
|
+
First, add to your Gemfile:
|
35
|
+
|
36
|
+
gem 'joybox'
|
37
|
+
|
38
|
+
Next, install the Joybox gem by running:
|
39
|
+
|
40
|
+
bundle
|
41
|
+
|
42
|
+
## Core Classes
|
43
|
+
|
44
|
+
For building games, the core classes are Director, Scene, Layer, and Sprite.
|
45
|
+
|
46
|
+
For more info, see: [cocos2d Basic Concepts](http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:basic_concepts)
|
47
|
+
|
48
|
+
### Director
|
49
|
+
|
50
|
+
The director presents scenes, manages flow from one scene to another,
|
51
|
+
manages the game loop, and responds to interruptions.
|
52
|
+
|
53
|
+
### Scene
|
54
|
+
|
55
|
+
A scene is composed of multiple layers. Examples of scenes are: menus,
|
56
|
+
game levels, cut scenes, and high score screen.
|
57
|
+
|
58
|
+
### Layer
|
59
|
+
|
60
|
+
Layers are primarily where a game's sprites are placed. Layers handle
|
61
|
+
user interaction, for example screen touches or device orientation.
|
62
|
+
|
63
|
+
### Sprite
|
64
|
+
|
65
|
+
Sprites are 2D images that have independent movement, such as
|
66
|
+
rotation, scaling, translation and animation.
|
67
|
+
|
68
|
+
## Contributions
|
69
|
+
|
70
|
+
1. Fork it
|
71
|
+
2. Create your feature branch (git checkout -b my-new-feature)
|
72
|
+
3. Commit your changes (git commit -am 'Added some feature')
|
73
|
+
4. Push to the branch (git push origin my-new-feature)
|
74
|
+
5. Create new Pull Request
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
Joybox is released under the MIT License.
|
79
|
+
|
80
|
+
## Authors
|
81
|
+
|
82
|
+
[Juan Karam](https://github.com/CurveBeryl) [@JuanKaram](https://twitter.com/JuanKaram)
|
83
|
+
|
84
|
+
## Box 2D Wrapper
|
85
|
+
|
86
|
+
If you wish to download or contribute to the Objective-C Box 2D wrapper, the repository URL is the following: https://github.com/CurveBeryl/Joybox-Box2D
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift("/Library/RubyMotion/lib")
|
2
|
+
require 'motion/project'
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.require
|
5
|
+
|
6
|
+
|
7
|
+
Motion::Project::App.setup do |app|
|
8
|
+
# Use `rake config' to see complete project settings.
|
9
|
+
app.name = 'Joybox'
|
10
|
+
app.identifier = 'curveberyl.joybox'
|
11
|
+
app.version = "0.0.1"
|
12
|
+
|
13
|
+
|
14
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
|
3
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
4
|
+
|
5
|
+
@director = Joybox::Configuration.setup do
|
6
|
+
|
7
|
+
director display_stats: true
|
8
|
+
end
|
9
|
+
|
10
|
+
@navigation_controller = UINavigationController.alloc.initWithRootViewController(@director)
|
11
|
+
@navigation_controller.navigationBarHidden = true
|
12
|
+
|
13
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
14
|
+
@window.setRootViewController(@navigation_controller)
|
15
|
+
@window.makeKeyAndVisible
|
16
|
+
|
17
|
+
@director << MenuLayer.scene
|
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
|
+
|
49
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
class Box2DLayer < Joybox::Core::Layer
|
2
|
+
|
3
|
+
scene
|
4
|
+
|
5
|
+
def on_enter
|
6
|
+
|
7
|
+
init_physics
|
8
|
+
layout_menu
|
9
|
+
layout_title
|
10
|
+
|
11
|
+
@sprite_batch = SpriteBatch.new file_name: "box2d/blocks_sprite_sheet.png"
|
12
|
+
self << @sprite_batch
|
13
|
+
|
14
|
+
|
15
|
+
on_touches_ended do |touches, event|
|
16
|
+
|
17
|
+
touch = touches.any_object
|
18
|
+
|
19
|
+
touch_location = touch.location
|
20
|
+
|
21
|
+
add_new_sprite(touch_location)
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
schedule_update do |dt|
|
26
|
+
|
27
|
+
@world.step delta: dt
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def init_physics
|
33
|
+
|
34
|
+
@world = World.new gravity:[0, -10]
|
35
|
+
|
36
|
+
body = @world.new_body position:[0,0] do
|
37
|
+
|
38
|
+
edge_fixure start_point: [0, 0],
|
39
|
+
end_point: [Screen.width, 0]
|
40
|
+
|
41
|
+
edge_fixure start_point: [0, Screen.height],
|
42
|
+
end_point: [Screen.width, Screen.height]
|
43
|
+
|
44
|
+
edge_fixure start_point: [0, Screen.height],
|
45
|
+
end_point: [0, 0]
|
46
|
+
|
47
|
+
edge_fixure start_point: [Screen.width, Screen.height],
|
48
|
+
end_point: [Screen.width, 0]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def layout_title
|
55
|
+
|
56
|
+
title = Label.new text: 'Tap Screen',
|
57
|
+
font_size: 40,
|
58
|
+
color: Color.new(0, 0, 255),
|
59
|
+
position: [Screen.half_width, Screen.height - 50]
|
60
|
+
|
61
|
+
self << title
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def layout_menu
|
66
|
+
|
67
|
+
MenuLabel.default_font_size = 32
|
68
|
+
|
69
|
+
reset_menu_item = MenuLabel.new text: 'Reset' do |menu_item|
|
70
|
+
|
71
|
+
director.replace_scene(Box2DLayer.scene)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
menu = Menu.new items: [reset_menu_item],
|
76
|
+
position: [Screen.half_width, Screen.half_height]
|
77
|
+
|
78
|
+
menu.align_items_vertically
|
79
|
+
|
80
|
+
self.add_child(menu, z: 1)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def add_new_sprite(position)
|
85
|
+
|
86
|
+
@random ||= Random.new
|
87
|
+
|
88
|
+
block_column = @random.rand > 0.5 ? 0 : 1
|
89
|
+
block_row = @random.rand > 0.5 ? 0 : 1
|
90
|
+
|
91
|
+
body = @world.new_body position: position,
|
92
|
+
type: KDynamicBodyType do
|
93
|
+
|
94
|
+
polygon_fixure box: [16, 16],
|
95
|
+
friction: 0.3,
|
96
|
+
density: 1.0
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
block_sprite = PhysicsSprite.new texture: @sprite_batch.texture,
|
101
|
+
rect: [[32 * block_column, 32 * block_row], [32, 32]],
|
102
|
+
position: position
|
103
|
+
|
104
|
+
block_sprite.body = body
|
105
|
+
|
106
|
+
@sprite_batch << block_sprite
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# A Joybox translate of the Cocos Motion example created by:
|
2
|
+
#
|
3
|
+
# Sean Scally => https://github.com/scally
|
4
|
+
# Ricardo Quesada => https://github.com/ricardoquesada
|
5
|
+
# Cocos Motion => https://github.com/scally/cocosmotion
|
6
|
+
#
|
7
|
+
# Thank you guys!
|
8
|
+
class CocosMotionLayer < Joybox::Core::Layer
|
9
|
+
|
10
|
+
scene
|
11
|
+
|
12
|
+
def on_enter
|
13
|
+
|
14
|
+
layout_sprites
|
15
|
+
|
16
|
+
layout_title
|
17
|
+
|
18
|
+
layout_menu
|
19
|
+
|
20
|
+
simple_sprite_animation
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def layout_sprites
|
25
|
+
|
26
|
+
@left_sprite = Sprite.new file_name:'cocos_motion/grossinis_sister.png',
|
27
|
+
position: [Screen.width / 4 * 1, Screen.half_height]
|
28
|
+
|
29
|
+
@center_sprite = Sprite.new file_name:'cocos_motion/grossini.png',
|
30
|
+
position: [Screen.width / 4 * 2, Screen.half_height]
|
31
|
+
|
32
|
+
@right_sprite = Sprite.new file_name:'cocos_motion/grossinis_sister_two.png',
|
33
|
+
position: [Screen.width / 4 * 3, Screen.half_height]
|
34
|
+
|
35
|
+
self.add_childs(@left_sprite, @center_sprite, @right_sprite)
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def layout_title
|
40
|
+
|
41
|
+
@title = Label.new font_name: 'Arial',
|
42
|
+
font_size: 32,
|
43
|
+
position: [Screen.half_width, Screen.height - 50]
|
44
|
+
|
45
|
+
|
46
|
+
@subtitle = Label.new font_name: 'Arial',
|
47
|
+
font_size: 16,
|
48
|
+
position: [Screen.half_width, Screen.height - 80]
|
49
|
+
|
50
|
+
|
51
|
+
self.add_childs(@title, @subtitle)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def layout_menu
|
56
|
+
|
57
|
+
back_item = MenuImage.new image_file_name: 'cocos_motion/left_arrow.png',
|
58
|
+
selected_image_file_name: 'cocos_motion/left_arrow_selected.png' do |menu_item|
|
59
|
+
|
60
|
+
skew_sprite_animation
|
61
|
+
end
|
62
|
+
|
63
|
+
reset_item = MenuImage.new image_file_name: 'cocos_motion/dot.png',
|
64
|
+
selected_image_file_name: 'cocos_motion/dot_selected.png' do |menu_item|
|
65
|
+
|
66
|
+
director.replace_scene(CocosMotionLayer.scene)
|
67
|
+
end
|
68
|
+
|
69
|
+
next_item = MenuImage.new image_file_name: 'cocos_motion/right_arrow.png',
|
70
|
+
selected_image_file_name: 'cocos_motion/right_arrow_selected.png' do |menu_item|
|
71
|
+
|
72
|
+
simple_sprite_animation
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
menu = Menu.new items: [back_item, reset_item, next_item],
|
77
|
+
position: [0, 0]
|
78
|
+
|
79
|
+
back_item.position = [Screen.half_width - reset_item.content_size.double_width,
|
80
|
+
reset_item.content_size.half_height]
|
81
|
+
|
82
|
+
reset_item.position = [Screen.half_width,
|
83
|
+
reset_item.content_size.half_height]
|
84
|
+
|
85
|
+
next_item.position = [Screen.half_width + reset_item.content_size.double_width,
|
86
|
+
reset_item.content_size.half_height]
|
87
|
+
|
88
|
+
self << menu
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
def simple_sprite_animation
|
93
|
+
|
94
|
+
@title.text = 'Basic Actions'
|
95
|
+
@subtitle.text = 'Rotate, Scale and Translate actions'
|
96
|
+
|
97
|
+
@left_sprite.stop_all_actions
|
98
|
+
@center_sprite.stop_all_actions
|
99
|
+
@right_sprite.stop_all_actions
|
100
|
+
|
101
|
+
rotate = Rotate.by duration: 2, angle:360
|
102
|
+
rotate_reverse = rotate.reverse
|
103
|
+
rotate_sequence = Sequence.new items: [rotate, rotate_reverse]
|
104
|
+
|
105
|
+
scale = Scale.by duration: 2, scale:4
|
106
|
+
scale_reverse = scale.reverse
|
107
|
+
scale_sequence = Sequence.new items: [scale, scale_reverse]
|
108
|
+
|
109
|
+
move = Move.by duration: 2, position: [-200, 0]
|
110
|
+
move_reverse = move.reverse
|
111
|
+
move_sequence = Sequence.new items: [move, move_reverse]
|
112
|
+
|
113
|
+
@left_sprite.run_action(Repeat.forever action:rotate_sequence)
|
114
|
+
@center_sprite.run_action(Repeat.forever action:scale_sequence)
|
115
|
+
@right_sprite.run_action(Repeat.forever action:move_sequence)
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def skew_sprite_animation
|
120
|
+
|
121
|
+
@title.text = 'Skew Actions'
|
122
|
+
@subtitle.text = 'Testing skew actions'
|
123
|
+
|
124
|
+
@left_sprite.stop_all_actions
|
125
|
+
@center_sprite.stop_all_actions
|
126
|
+
@right_sprite.stop_all_actions
|
127
|
+
|
128
|
+
first_skew = Skew.by duration:2, x:37, y:-37
|
129
|
+
first_skew_reverse = first_skew.reverse
|
130
|
+
first_sequence = Sequence.new items: [first_skew, first_skew_reverse]
|
131
|
+
|
132
|
+
second_skew = Skew.by duration:2, x:0, y:-90
|
133
|
+
second_skew_reverse = second_skew.reverse
|
134
|
+
second_sequence = Sequence.new items: [second_skew, second_skew_reverse]
|
135
|
+
|
136
|
+
third_skew = Skew.by duration:2, x:45, y:45
|
137
|
+
third_skew_reverse = third_skew.reverse
|
138
|
+
third_sequence = Sequence.new items: [third_skew, third_skew_reverse]
|
139
|
+
|
140
|
+
@left_sprite.run_action(Repeat.forever action:first_sequence)
|
141
|
+
@center_sprite.run_action(Repeat.forever action:second_sequence)
|
142
|
+
@right_sprite.run_action(Repeat.forever action:third_sequence)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|