joybox 0.0.3
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.
- 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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2010 Steve Oldmeadow
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
$Id$
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
#import "CDAudioManager.h"
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
A wrapper to the CDAudioManager object.
|
|
30
|
+
This is recommended for basic audio requirements. If you just want to play some sound fx
|
|
31
|
+
and some background music and have no interest in learning the lower level workings then
|
|
32
|
+
this is the interface to use.
|
|
33
|
+
|
|
34
|
+
Requirements:
|
|
35
|
+
- Firmware: OS 2.2 or greater
|
|
36
|
+
- Files: SimpleAudioEngine.*, CocosDenshion.*
|
|
37
|
+
- Frameworks: OpenAL, AudioToolbox, AVFoundation
|
|
38
|
+
@since v0.8
|
|
39
|
+
*/
|
|
40
|
+
@interface SimpleAudioEngine : NSObject <CDAudioInterruptProtocol> {
|
|
41
|
+
|
|
42
|
+
BOOL mute_;
|
|
43
|
+
BOOL enabled_;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Background music volume. Range is 0.0f to 1.0f. This will only have an effect if willPlayBackgroundMusic returns YES */
|
|
47
|
+
@property (readwrite) float backgroundMusicVolume;
|
|
48
|
+
/** Effects volume. Range is 0.0f to 1.0f */
|
|
49
|
+
@property (readwrite) float effectsVolume;
|
|
50
|
+
/** If NO it indicates background music will not be played either because no background music is loaded or the audio session does not permit it.*/
|
|
51
|
+
@property (readonly) BOOL willPlayBackgroundMusic;
|
|
52
|
+
|
|
53
|
+
/** returns the shared instance of the SimpleAudioEngine object */
|
|
54
|
+
+ (SimpleAudioEngine*) sharedEngine;
|
|
55
|
+
|
|
56
|
+
/** Preloads a music file so it will be ready to play as background music */
|
|
57
|
+
-(void) preloadBackgroundMusic:(NSString*) filePath;
|
|
58
|
+
|
|
59
|
+
/** plays background music in a loop*/
|
|
60
|
+
-(void) playBackgroundMusic:(NSString*) filePath;
|
|
61
|
+
/** plays background music, if loop is true the music will repeat otherwise it will be played once */
|
|
62
|
+
-(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop;
|
|
63
|
+
/** stops playing background music */
|
|
64
|
+
-(void) stopBackgroundMusic;
|
|
65
|
+
/** pauses the background music */
|
|
66
|
+
-(void) pauseBackgroundMusic;
|
|
67
|
+
/** resume background music that has been paused */
|
|
68
|
+
-(void) resumeBackgroundMusic;
|
|
69
|
+
/** rewind the background music */
|
|
70
|
+
-(void) rewindBackgroundMusic;
|
|
71
|
+
/** returns whether or not the background music is playing */
|
|
72
|
+
-(BOOL) isBackgroundMusicPlaying;
|
|
73
|
+
|
|
74
|
+
/** plays an audio effect with a file path*/
|
|
75
|
+
-(ALuint) playEffect:(NSString*) filePath;
|
|
76
|
+
/** stop a sound that is playing, note you must pass in the soundId that is returned when you started playing the sound with playEffect */
|
|
77
|
+
-(void) stopEffect:(ALuint) soundId;
|
|
78
|
+
/** plays an audio effect with a file path, pitch, pan and gain */
|
|
79
|
+
-(ALuint) playEffect:(NSString*) filePath pitch:(Float32) pitch pan:(Float32) pan gain:(Float32) gain;
|
|
80
|
+
/** preloads an audio effect */
|
|
81
|
+
-(void) preloadEffect:(NSString*) filePath;
|
|
82
|
+
/** unloads an audio effect from memory */
|
|
83
|
+
-(void) unloadEffect:(NSString*) filePath;
|
|
84
|
+
/** Gets a CDSoundSource object set up to play the specified file. */
|
|
85
|
+
-(CDSoundSource *) soundSourceForFile:(NSString*) filePath;
|
|
86
|
+
|
|
87
|
+
/** Shuts down the shared audio engine instance so that it can be reinitialised */
|
|
88
|
+
+(void) end;
|
|
89
|
+
|
|
90
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* cocos2d for iPhone
|
|
2
|
+
*
|
|
3
|
+
* http://www.cocos2d-iphone.org
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Idea taken from: http://stackoverflow.com/a/3940757
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <Foundation/Foundation.h>
|
|
11
|
+
|
|
12
|
+
@interface NSThread (sendBlockToBackground)
|
|
13
|
+
/** performs a block on the thread. It won't wait until it is done. */
|
|
14
|
+
- (void) performBlock:(void (^)(void))block;
|
|
15
|
+
|
|
16
|
+
/** performs a block on the thread. */
|
|
17
|
+
- (void) performBlock:(void (^)(void))block waitUntilDone:(BOOL)wait;
|
|
18
|
+
|
|
19
|
+
/** performs a block on the thread. */
|
|
20
|
+
- (void) performBlock:(void (^)(id param))block withObject:(id)object waitUntilDone:(BOOL)wait;
|
|
21
|
+
|
|
22
|
+
@end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
===== IMPORTANT =====
|
|
4
|
+
|
|
5
|
+
This is sample code demonstrating API, technology or techniques in development.
|
|
6
|
+
Although this sample code has been reviewed for technical accuracy, it is not
|
|
7
|
+
final. Apple is supplying this information to help you plan for the adoption of
|
|
8
|
+
the technologies and programming interfaces described herein. This information
|
|
9
|
+
is subject to change, and software implemented based on this sample code should
|
|
10
|
+
be tested with final operating system software and final documentation. Newer
|
|
11
|
+
versions of this sample code may be provided with future seeds of the API or
|
|
12
|
+
technology. For information about updates to this and other developer
|
|
13
|
+
documentation, view the New & Updated sidebars in subsequent documentation
|
|
14
|
+
seeds.
|
|
15
|
+
|
|
16
|
+
=====================
|
|
17
|
+
|
|
18
|
+
File: OpenGL_Internal.h
|
|
19
|
+
Abstract: This file is included for support purposes and isn't necessary for
|
|
20
|
+
understanding this sample.
|
|
21
|
+
|
|
22
|
+
Version: 1.0
|
|
23
|
+
|
|
24
|
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
|
|
25
|
+
("Apple") in consideration of your agreement to the following terms, and your
|
|
26
|
+
use, installation, modification or redistribution of this Apple software
|
|
27
|
+
constitutes acceptance of these terms. If you do not agree with these terms,
|
|
28
|
+
please do not use, install, modify or redistribute this Apple software.
|
|
29
|
+
|
|
30
|
+
In consideration of your agreement to abide by the following terms, and subject
|
|
31
|
+
to these terms, Apple grants you a personal, non-exclusive license, under
|
|
32
|
+
Apple's copyrights in this original Apple software (the "Apple Software"), to
|
|
33
|
+
use, reproduce, modify and redistribute the Apple Software, with or without
|
|
34
|
+
modifications, in source and/or binary forms; provided that if you redistribute
|
|
35
|
+
the Apple Software in its entirety and without modifications, you must retain
|
|
36
|
+
this notice and the following text and disclaimers in all such redistributions
|
|
37
|
+
of the Apple Software.
|
|
38
|
+
Neither the name, trademarks, service marks or logos of Apple Inc. may be used
|
|
39
|
+
to endorse or promote products derived from the Apple Software without specific
|
|
40
|
+
prior written permission from Apple. Except as expressly stated in this notice,
|
|
41
|
+
no other rights or licenses, express or implied, are granted by Apple herein,
|
|
42
|
+
including but not limited to any patent rights that may be infringed by your
|
|
43
|
+
derivative works or by other works in which the Apple Software may be
|
|
44
|
+
incorporated.
|
|
45
|
+
|
|
46
|
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
|
|
47
|
+
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
|
|
48
|
+
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
49
|
+
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
|
|
50
|
+
COMBINATION WITH YOUR PRODUCTS.
|
|
51
|
+
|
|
52
|
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
|
|
53
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
54
|
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
55
|
+
ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
|
|
56
|
+
DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
|
|
57
|
+
CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
|
58
|
+
APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
59
|
+
|
|
60
|
+
Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|
61
|
+
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/* Generic error reporting */
|
|
65
|
+
#define REPORT_ERROR(__FORMAT__, ...) printf("%s: %s\n", __FUNCTION__, [[NSString stringWithFormat:__FORMAT__, __VA_ARGS__] UTF8String])
|
|
66
|
+
|
|
67
|
+
/* EAGL and GL functions calling wrappers that log on error */
|
|
68
|
+
#define CALL_EAGL_FUNCTION(__FUNC__, ...) ({ EAGLError __error = __FUNC__( __VA_ARGS__ ); if(__error != kEAGLErrorSuccess) printf("%s() called from %s returned error %i\n", #__FUNC__, __FUNCTION__, __error); (__error ? NO : YES); })
|
|
69
|
+
//#define CHECK_GL_ERROR() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s\n", __error, __FUNCTION__); (__error ? NO : YES); })
|
|
70
|
+
#define CHECK_GL_ERROR() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s %d\n", __error, __FUNCTION__, __LINE__); })
|
|
71
|
+
|
|
72
|
+
#if DEBUG
|
|
73
|
+
#define CHECK_GL_ERROR_DEBUG() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s %d\n", __error, __FUNCTION__, __LINE__); })
|
|
74
|
+
#else
|
|
75
|
+
#define CHECK_GL_ERROR_DEBUG()
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
/* Optional delegate methods support */
|
|
79
|
+
#ifndef __DELEGATE_IVAR__
|
|
80
|
+
#define __DELEGATE_IVAR__ _delegate
|
|
81
|
+
#endif
|
|
82
|
+
#ifndef __DELEGATE_METHODS_IVAR__
|
|
83
|
+
#define __DELEGATE_METHODS_IVAR__ _delegateMethods
|
|
84
|
+
#endif
|
|
85
|
+
#define TEST_DELEGATE_METHOD_BIT(__BIT__) (self->__DELEGATE_METHODS_IVAR__ & (1 << __BIT__))
|
|
86
|
+
#define SET_DELEGATE_METHOD_BIT(__BIT__, __NAME__) { if([self->__DELEGATE_IVAR__ respondsToSelector:@selector(__NAME__)]) self->__DELEGATE_METHODS_IVAR__ |= (1 << __BIT__); else self->__DELEGATE_METHODS_IVAR__ &= ~(1 << __BIT__); }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//
|
|
2
|
+
// TGA lib for cocos2d-iphone
|
|
3
|
+
//
|
|
4
|
+
// sources from: http://www.lighthouse3d.com/opengl/terrain/index.php3?tgasource
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
//#ifndef TGA_LIB
|
|
8
|
+
//#define TGA_LIB
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
@file
|
|
12
|
+
TGA image support
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
enum {
|
|
16
|
+
TGA_OK,
|
|
17
|
+
TGA_ERROR_FILE_OPEN,
|
|
18
|
+
TGA_ERROR_READING_FILE,
|
|
19
|
+
TGA_ERROR_INDEXED_COLOR,
|
|
20
|
+
TGA_ERROR_MEMORY,
|
|
21
|
+
TGA_ERROR_COMPRESSED_FILE,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** TGA format */
|
|
25
|
+
typedef struct sImageTGA {
|
|
26
|
+
int status;
|
|
27
|
+
unsigned char type, pixelDepth;
|
|
28
|
+
|
|
29
|
+
/** map width */
|
|
30
|
+
short int width;
|
|
31
|
+
|
|
32
|
+
/** map height */
|
|
33
|
+
short int height;
|
|
34
|
+
|
|
35
|
+
/** raw data */
|
|
36
|
+
unsigned char *imageData;
|
|
37
|
+
int flipped;
|
|
38
|
+
} tImageTGA;
|
|
39
|
+
|
|
40
|
+
/// load the image header fields. We only keep those that matter!
|
|
41
|
+
void tgaLoadHeader(FILE *file, tImageTGA *info);
|
|
42
|
+
|
|
43
|
+
/// loads the image pixels. You shouldn't call this function directly
|
|
44
|
+
void tgaLoadImageData(FILE *file, tImageTGA *info);
|
|
45
|
+
|
|
46
|
+
/// this is the function to call when we want to load an image
|
|
47
|
+
tImageTGA * tgaLoad(const char *filename);
|
|
48
|
+
|
|
49
|
+
// /converts RGB to greyscale
|
|
50
|
+
void tgaRGBtogreyscale(tImageTGA *info);
|
|
51
|
+
|
|
52
|
+
/// releases the memory used for the image
|
|
53
|
+
void tgaDestroy(tImageTGA *info);
|
|
54
|
+
|
|
55
|
+
//#endif // TGA_LIB
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2009 Valentin Milea
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
* THE SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#import "../ccMacros.h"
|
|
27
|
+
#import "../Platforms/CCGL.h"
|
|
28
|
+
|
|
29
|
+
#ifdef __CC_PLATFORM_IOS
|
|
30
|
+
#import <UIKit/UIKit.h>
|
|
31
|
+
#elif defined(__CC_PLATFORM_MAC)
|
|
32
|
+
#import <Foundation/Foundation.h>
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
void CGAffineToGL(const CGAffineTransform *t, GLfloat *m);
|
|
36
|
+
void GLToCGAffine(const GLfloat *m, CGAffineTransform *t);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* cocos2d for iPhone
|
|
2
|
+
*
|
|
3
|
+
* http://www.cocos2d-iphone.org
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* inflateMemory_ based on zlib example code
|
|
7
|
+
* http://www.zlib.net
|
|
8
|
+
*
|
|
9
|
+
* Some ideas were taken from:
|
|
10
|
+
* http://themanaworld.org/
|
|
11
|
+
* from the mapreader.cpp file
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
#ifndef __CC_ZIP_UTILS_H
|
|
16
|
+
#define __CC_ZIP_UTILS_H
|
|
17
|
+
|
|
18
|
+
#import <stdint.h>
|
|
19
|
+
|
|
20
|
+
#ifdef __cplusplus
|
|
21
|
+
extern "C" {
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
/* XXX: pragma pack ??? */
|
|
25
|
+
/** @struct CCZHeader
|
|
26
|
+
*/
|
|
27
|
+
struct CCZHeader {
|
|
28
|
+
uint8_t sig[4]; // signature. Should be 'CCZ!' 4 bytes
|
|
29
|
+
uint16_t compression_type; // should 0
|
|
30
|
+
uint16_t version; // should be 2 (although version type==1 is also supported)
|
|
31
|
+
uint32_t reserved; // Reserverd for users.
|
|
32
|
+
uint32_t len; // size of the uncompressed file
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
enum {
|
|
36
|
+
CCZ_COMPRESSION_ZLIB, // zlib format.
|
|
37
|
+
CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet)
|
|
38
|
+
CCZ_COMPRESSION_GZIP, // gzip format (not supported yet)
|
|
39
|
+
CCZ_COMPRESSION_NONE, // plain (not supported yet)
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** @file
|
|
43
|
+
* Zip helper functions
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Inflates either zlib or gzip deflated memory. The inflated memory is
|
|
48
|
+
* expected to be freed by the caller.
|
|
49
|
+
*
|
|
50
|
+
* It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory.
|
|
51
|
+
* @returns the length of the deflated buffer
|
|
52
|
+
*
|
|
53
|
+
@since v0.8.1
|
|
54
|
+
*/
|
|
55
|
+
int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Inflates either zlib or gzip deflated memory. The inflated memory is
|
|
59
|
+
* expected to be freed by the caller.
|
|
60
|
+
*
|
|
61
|
+
* outLenghtHint is assumed to be the needed room to allocate the inflated buffer.
|
|
62
|
+
*
|
|
63
|
+
* @returns the length of the deflated buffer
|
|
64
|
+
*
|
|
65
|
+
@since v1.0.0
|
|
66
|
+
*/
|
|
67
|
+
int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLenghtHint );
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
/** inflates a GZip file into memory
|
|
71
|
+
*
|
|
72
|
+
* @returns the length of the deflated buffer
|
|
73
|
+
*
|
|
74
|
+
* @since v0.99.5
|
|
75
|
+
*/
|
|
76
|
+
int ccInflateGZipFile(const char *filename, unsigned char **out);
|
|
77
|
+
|
|
78
|
+
/** inflates a CCZ file into memory
|
|
79
|
+
*
|
|
80
|
+
* @returns the length of the deflated buffer
|
|
81
|
+
*
|
|
82
|
+
* @since v0.99.5
|
|
83
|
+
*/
|
|
84
|
+
int ccInflateCCZFile(const char *filename, unsigned char **out);
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#ifdef __cplusplus
|
|
88
|
+
}
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
#endif // __CC_ZIP_UTILS_H
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
public domain BASE64 code
|
|
3
|
+
|
|
4
|
+
modified for cocos2d-iphone: http://www.cocos2d-iphone.org
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef __CC_BASE64_DECODE_H
|
|
8
|
+
#define __CC_BASE64_DECODE_H
|
|
9
|
+
|
|
10
|
+
#ifdef __cplusplus
|
|
11
|
+
extern "C" {
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/** @file
|
|
16
|
+
base64 helper functions
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Decodes a 64base encoded memory. The decoded memory is
|
|
21
|
+
* expected to be freed by the caller.
|
|
22
|
+
*
|
|
23
|
+
* @returns the length of the out buffer
|
|
24
|
+
*
|
|
25
|
+
@since v0.8.1
|
|
26
|
+
*/
|
|
27
|
+
int base64Decode(unsigned char *in, unsigned int inLength, unsigned char **out);
|
|
28
|
+
|
|
29
|
+
#ifdef __cplusplus
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#endif // __CC_BASE64_DECODE_H
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/* Copyright (c) 2007 Scott Lembcke
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
* in the Software without restriction, including without limitation the rights
|
|
6
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
* SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
@file
|
|
24
|
+
based on Chipmunk cpArray.
|
|
25
|
+
ccArray is a faster alternative to NSMutableArray, it does pretty much the
|
|
26
|
+
same thing (stores NSObjects and retains/releases them appropriately). It's
|
|
27
|
+
faster because:
|
|
28
|
+
- it uses a plain C interface so it doesn't incur Objective-c messaging overhead
|
|
29
|
+
- it assumes you know what you're doing, so it doesn't spend time on safety checks
|
|
30
|
+
(index out of bounds, required capacity etc.)
|
|
31
|
+
- comparisons are done using pointer equality instead of isEqual
|
|
32
|
+
|
|
33
|
+
There are 2 kind of functions:
|
|
34
|
+
- ccArray functions that manipulates objective-c objects (retain and release are performanced)
|
|
35
|
+
- ccCArray functions that manipulates values like if they were standard C structures (no retain/release is performed)
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
#ifndef CC_ARRAY_H
|
|
39
|
+
#define CC_ARRAY_H
|
|
40
|
+
|
|
41
|
+
#import <Foundation/Foundation.h>
|
|
42
|
+
|
|
43
|
+
#import <stdlib.h>
|
|
44
|
+
#import <string.h>
|
|
45
|
+
|
|
46
|
+
#import "../ccMacros.h"
|
|
47
|
+
|
|
48
|
+
#ifdef __cplusplus
|
|
49
|
+
extern "C" {
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
#pragma mark -
|
|
53
|
+
#pragma mark ccArray for Objects
|
|
54
|
+
|
|
55
|
+
// Easy integration
|
|
56
|
+
#define CCARRAYDATA_FOREACH(__array__, __object__) \
|
|
57
|
+
__object__=__array__->arr[0]; for(NSUInteger i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
|
|
58
|
+
|
|
59
|
+
#if defined(__has_feature) && __has_feature(objc_arc)
|
|
60
|
+
typedef __strong id CCARRAY_ID;
|
|
61
|
+
#else
|
|
62
|
+
typedef id CCARRAY_ID;
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
typedef struct ccArray {
|
|
66
|
+
NSUInteger num, max;
|
|
67
|
+
CCARRAY_ID *arr;
|
|
68
|
+
} ccArray;
|
|
69
|
+
|
|
70
|
+
typedef int (*cc_comparator)(const void *, const void *);
|
|
71
|
+
|
|
72
|
+
/** Allocates and initializes a new array with specified capacity */
|
|
73
|
+
ccArray* ccArrayNew(NSUInteger capacity);
|
|
74
|
+
|
|
75
|
+
/** Frees array after removing all remaining objects. Silently ignores nil arr. */
|
|
76
|
+
void ccArrayFree(ccArray *arr);
|
|
77
|
+
|
|
78
|
+
/** Doubles array capacity */
|
|
79
|
+
void ccArrayDoubleCapacity(ccArray *arr);
|
|
80
|
+
|
|
81
|
+
/** Increases array capacity such that max >= num + extra. */
|
|
82
|
+
void ccArrayEnsureExtraCapacity(ccArray *arr, NSUInteger extra);
|
|
83
|
+
|
|
84
|
+
/** shrinks the array so the memory footprint corresponds with the number of items */
|
|
85
|
+
void ccArrayShrink(ccArray *arr);
|
|
86
|
+
|
|
87
|
+
/** Returns index of first occurence of object, NSNotFound if object not found. */
|
|
88
|
+
NSUInteger ccArrayGetIndexOfObject(ccArray *arr, id object);
|
|
89
|
+
|
|
90
|
+
/** Returns a Boolean value that indicates whether object is present in array. */
|
|
91
|
+
BOOL ccArrayContainsObject(ccArray *arr, id object);
|
|
92
|
+
|
|
93
|
+
/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */
|
|
94
|
+
void ccArrayAppendObject(ccArray *arr, id object);
|
|
95
|
+
|
|
96
|
+
/** Appends an object. Capacity of arr is increased if needed. */
|
|
97
|
+
void ccArrayAppendObjectWithResize(ccArray *arr, id object);
|
|
98
|
+
|
|
99
|
+
/** Appends objects from plusArr to arr.
|
|
100
|
+
Behaviour undefined if arr doesn't have enough capacity. */
|
|
101
|
+
void ccArrayAppendArray(ccArray *arr, ccArray *plusArr);
|
|
102
|
+
|
|
103
|
+
/** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */
|
|
104
|
+
void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr);
|
|
105
|
+
|
|
106
|
+
/** Inserts an object at index */
|
|
107
|
+
void ccArrayInsertObjectAtIndex(ccArray *arr, id object, NSUInteger index);
|
|
108
|
+
|
|
109
|
+
/** Swaps two objects */
|
|
110
|
+
void ccArraySwapObjectsAtIndexes(ccArray *arr, NSUInteger index1, NSUInteger index2);
|
|
111
|
+
|
|
112
|
+
/** Removes all objects from arr */
|
|
113
|
+
void ccArrayRemoveAllObjects(ccArray *arr);
|
|
114
|
+
|
|
115
|
+
/** Removes object at specified index and pushes back all subsequent objects.
|
|
116
|
+
Behaviour undefined if index outside [0, num-1]. */
|
|
117
|
+
void ccArrayRemoveObjectAtIndex(ccArray *arr, NSUInteger index);
|
|
118
|
+
|
|
119
|
+
/** Removes object at specified index and fills the gap with the last object,
|
|
120
|
+
thereby avoiding the need to push back subsequent objects.
|
|
121
|
+
Behaviour undefined if index outside [0, num-1]. */
|
|
122
|
+
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, NSUInteger index);
|
|
123
|
+
|
|
124
|
+
void ccArrayFastRemoveObject(ccArray *arr, id object);
|
|
125
|
+
|
|
126
|
+
/** Searches for the first occurance of object and removes it. If object is not
|
|
127
|
+
found the function has no effect. */
|
|
128
|
+
void ccArrayRemoveObject(ccArray *arr, id object);
|
|
129
|
+
|
|
130
|
+
/** Removes from arr all objects in minusArr. For each object in minusArr, the
|
|
131
|
+
first matching instance in arr will be removed. */
|
|
132
|
+
void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr);
|
|
133
|
+
|
|
134
|
+
/** Removes from arr all objects in minusArr. For each object in minusArr, all
|
|
135
|
+
matching instances in arr will be removed. */
|
|
136
|
+
void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr);
|
|
137
|
+
|
|
138
|
+
/** Sends to each object in arr the message identified by given selector. */
|
|
139
|
+
void ccArrayMakeObjectsPerformSelector(ccArray *arr, SEL sel);
|
|
140
|
+
|
|
141
|
+
void ccArrayMakeObjectsPerformSelectorWithObject(ccArray *arr, SEL sel, id object);
|
|
142
|
+
|
|
143
|
+
void ccArrayMakeObjectPerformSelectorWithArrayObjects(ccArray *arr, SEL sel, id object);
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
#pragma mark -
|
|
147
|
+
#pragma mark ccCArray for Values (c structures)
|
|
148
|
+
|
|
149
|
+
typedef ccArray ccCArray;
|
|
150
|
+
|
|
151
|
+
/** Allocates and initializes a new C array with specified capacity */
|
|
152
|
+
ccCArray* ccCArrayNew(NSUInteger capacity);
|
|
153
|
+
|
|
154
|
+
/** Frees C array after removing all remaining values. Silently ignores nil arr. */
|
|
155
|
+
void ccCArrayFree(ccCArray *arr);
|
|
156
|
+
|
|
157
|
+
/** Doubles C array capacity */
|
|
158
|
+
void ccCArrayDoubleCapacity(ccCArray *arr);
|
|
159
|
+
|
|
160
|
+
/** Increases array capacity such that max >= num + extra. */
|
|
161
|
+
void ccCArrayEnsureExtraCapacity(ccCArray *arr, NSUInteger extra);
|
|
162
|
+
|
|
163
|
+
/** Returns index of first occurence of value, NSNotFound if value not found. */
|
|
164
|
+
NSUInteger ccCArrayGetIndexOfValue(ccCArray *arr, CCARRAY_ID value);
|
|
165
|
+
|
|
166
|
+
/** Returns a Boolean value that indicates whether value is present in the C array. */
|
|
167
|
+
BOOL ccCArrayContainsValue(ccCArray *arr, CCARRAY_ID value);
|
|
168
|
+
|
|
169
|
+
/** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */
|
|
170
|
+
void ccCArrayInsertValueAtIndex( ccCArray *arr, CCARRAY_ID value, NSUInteger index);
|
|
171
|
+
|
|
172
|
+
/** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */
|
|
173
|
+
void ccCArrayAppendValue(ccCArray *arr, CCARRAY_ID value);
|
|
174
|
+
|
|
175
|
+
/** Appends an value. Capacity of arr is increased if needed. */
|
|
176
|
+
void ccCArrayAppendValueWithResize(ccCArray *arr, CCARRAY_ID value);
|
|
177
|
+
|
|
178
|
+
/** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have
|
|
179
|
+
enough capacity. */
|
|
180
|
+
void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr);
|
|
181
|
+
|
|
182
|
+
/** Appends values from plusArr to arr. Capacity of arr is increased if needed. */
|
|
183
|
+
void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr);
|
|
184
|
+
|
|
185
|
+
/** Removes all values from arr */
|
|
186
|
+
void ccCArrayRemoveAllValues(ccCArray *arr);
|
|
187
|
+
|
|
188
|
+
/** Removes value at specified index and pushes back all subsequent values.
|
|
189
|
+
Behaviour undefined if index outside [0, num-1].
|
|
190
|
+
@since v0.99.4
|
|
191
|
+
*/
|
|
192
|
+
void ccCArrayRemoveValueAtIndex(ccCArray *arr, NSUInteger index);
|
|
193
|
+
|
|
194
|
+
/** Removes value at specified index and fills the gap with the last value,
|
|
195
|
+
thereby avoiding the need to push back subsequent values.
|
|
196
|
+
Behaviour undefined if index outside [0, num-1].
|
|
197
|
+
@since v0.99.4
|
|
198
|
+
*/
|
|
199
|
+
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, NSUInteger index);
|
|
200
|
+
|
|
201
|
+
/** Searches for the first occurance of value and removes it. If value is not found the function has no effect.
|
|
202
|
+
@since v0.99.4
|
|
203
|
+
*/
|
|
204
|
+
void ccCArrayRemoveValue(ccCArray *arr, CCARRAY_ID value);
|
|
205
|
+
|
|
206
|
+
/** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed.
|
|
207
|
+
@since v0.99.4
|
|
208
|
+
*/
|
|
209
|
+
void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr);
|
|
210
|
+
|
|
211
|
+
/** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed.
|
|
212
|
+
@since v0.99.4
|
|
213
|
+
*/
|
|
214
|
+
void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr);
|
|
215
|
+
|
|
216
|
+
// iterative mergesort arrd on
|
|
217
|
+
// http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergiter.htm
|
|
218
|
+
int cc_mergesortL(ccCArray* array, size_t width, cc_comparator comparator);
|
|
219
|
+
|
|
220
|
+
void cc_insertionSort(ccCArray* arr, cc_comparator comparator);
|
|
221
|
+
|
|
222
|
+
void cc_pointerswap(void* a, void* b, size_t width);
|
|
223
|
+
|
|
224
|
+
#ifdef __cplusplus
|
|
225
|
+
}
|
|
226
|
+
#endif
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
#endif // CC_ARRAY_H
|