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,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2008-2010 Ricardo Quesada
|
|
5
|
+
* Copyright (c) 2011 Zynga Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#import "CCNode.h"
|
|
29
|
+
|
|
30
|
+
/** CCScene is a subclass of CCNode that is used only as an abstract concept.
|
|
31
|
+
|
|
32
|
+
CCScene an CCNode are almost identical with the difference that CCScene has its
|
|
33
|
+
anchor point (by default) at the center of the screen.
|
|
34
|
+
|
|
35
|
+
For the moment CCScene has no other logic than that, but in future releases it might have
|
|
36
|
+
additional logic.
|
|
37
|
+
|
|
38
|
+
It is a good practice to use and CCScene as the parent of all your nodes.
|
|
39
|
+
*/
|
|
40
|
+
@interface CCScene : CCNode
|
|
41
|
+
{
|
|
42
|
+
}
|
|
43
|
+
@end
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2008-2010 Ricardo Quesada
|
|
5
|
+
* Copyright (c) 2011 Zynga Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#import "Support/uthash.h"
|
|
29
|
+
#import "ccTypes.h"
|
|
30
|
+
|
|
31
|
+
// Priority level reserved for system services.
|
|
32
|
+
#define kCCPrioritySystem INT_MIN
|
|
33
|
+
|
|
34
|
+
// Minimum priority level for user scheduling.
|
|
35
|
+
#define kCCPriorityNonSystemMin (kCCPrioritySystem+1)
|
|
36
|
+
|
|
37
|
+
typedef void (*TICK_IMP)(id, SEL, ccTime);
|
|
38
|
+
|
|
39
|
+
//
|
|
40
|
+
// CCTimer
|
|
41
|
+
//
|
|
42
|
+
/** Light weight timer */
|
|
43
|
+
@interface CCTimer : NSObject
|
|
44
|
+
{
|
|
45
|
+
id target;
|
|
46
|
+
TICK_IMP impMethod;
|
|
47
|
+
|
|
48
|
+
ccTime elapsed;
|
|
49
|
+
BOOL runForever;
|
|
50
|
+
BOOL useDelay;
|
|
51
|
+
uint nTimesExecuted;
|
|
52
|
+
uint repeat; //0 = once, 1 is 2 x executed
|
|
53
|
+
ccTime delay;
|
|
54
|
+
|
|
55
|
+
@public // optimization
|
|
56
|
+
ccTime interval;
|
|
57
|
+
SEL selector;
|
|
58
|
+
}
|
|
59
|
+
/** interval in seconds */
|
|
60
|
+
@property (nonatomic,readwrite,assign) ccTime interval;
|
|
61
|
+
|
|
62
|
+
/** Allocates a timer with a target and a selector.
|
|
63
|
+
*/
|
|
64
|
+
+(id) timerWithTarget:(id) t selector:(SEL)s;
|
|
65
|
+
|
|
66
|
+
/** Allocates a timer with a target, a selector and an interval in seconds.
|
|
67
|
+
*/
|
|
68
|
+
+(id) timerWithTarget:(id) t selector:(SEL)s interval:(ccTime)seconds;
|
|
69
|
+
|
|
70
|
+
/** Initializes a timer with a target and a selector.
|
|
71
|
+
*/
|
|
72
|
+
-(id) initWithTarget:(id) t selector:(SEL)s;
|
|
73
|
+
|
|
74
|
+
/** Initializes a timer with a target, a selector, an interval in seconds, repeat in number of times to repeat, delay in seconds
|
|
75
|
+
*/
|
|
76
|
+
-(id) initWithTarget:(id)t selector:(SEL)s interval:(ccTime) seconds repeat:(uint) r delay:(ccTime) d;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/** triggers the timer */
|
|
80
|
+
-(void) update: (ccTime) dt;
|
|
81
|
+
@end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
//
|
|
86
|
+
// CCScheduler
|
|
87
|
+
//
|
|
88
|
+
/** CCScheduler is responsible of triggering the scheduled callbacks.
|
|
89
|
+
You should not use NSTimer. Instead use this class.
|
|
90
|
+
|
|
91
|
+
There are 2 different types of callbacks (selectors):
|
|
92
|
+
|
|
93
|
+
- update selector: the 'update' selector will be called every frame. You can customize the priority.
|
|
94
|
+
- custom selector: A custom selector will be called every frame, or with a custom interval of time
|
|
95
|
+
|
|
96
|
+
The 'custom selectors' should be avoided when possible. It is faster, and consumes less memory to use the 'update selector'.
|
|
97
|
+
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
struct _listEntry;
|
|
101
|
+
struct _hashSelectorEntry;
|
|
102
|
+
struct _hashUpdateEntry;
|
|
103
|
+
|
|
104
|
+
@interface CCScheduler : NSObject
|
|
105
|
+
{
|
|
106
|
+
ccTime timeScale_;
|
|
107
|
+
|
|
108
|
+
//
|
|
109
|
+
// "updates with priority" stuff
|
|
110
|
+
//
|
|
111
|
+
struct _listEntry *updatesNeg; // list of priority < 0
|
|
112
|
+
struct _listEntry *updates0; // list priority == 0
|
|
113
|
+
struct _listEntry *updatesPos; // list priority > 0
|
|
114
|
+
struct _hashUpdateEntry *hashForUpdates; // hash used to fetch quickly the list entries for pause,delete,etc.
|
|
115
|
+
|
|
116
|
+
// Used for "selectors with interval"
|
|
117
|
+
struct _hashSelectorEntry *hashForSelectors;
|
|
118
|
+
struct _hashSelectorEntry *currentTarget;
|
|
119
|
+
BOOL currentTargetSalvaged;
|
|
120
|
+
|
|
121
|
+
// Optimization
|
|
122
|
+
TICK_IMP impMethod;
|
|
123
|
+
SEL updateSelector;
|
|
124
|
+
|
|
125
|
+
BOOL updateHashLocked; // If true unschedule will not remove anything from a hash. Elements will only be marked for deletion.
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Modifies the time of all scheduled callbacks.
|
|
129
|
+
You can use this property to create a 'slow motion' or 'fast fordward' effect.
|
|
130
|
+
Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
|
|
131
|
+
To create a 'fast fordward' effect, use values higher than 1.0.
|
|
132
|
+
@since v0.8
|
|
133
|
+
@warning It will affect EVERY scheduled selector / action.
|
|
134
|
+
*/
|
|
135
|
+
@property (nonatomic,readwrite) ccTime timeScale;
|
|
136
|
+
|
|
137
|
+
/** 'update' the scheduler.
|
|
138
|
+
You should NEVER call this method, unless you know what you are doing.
|
|
139
|
+
*/
|
|
140
|
+
-(void) update:(ccTime)dt;
|
|
141
|
+
|
|
142
|
+
/** The scheduled method will be called every 'interval' seconds.
|
|
143
|
+
If paused is YES, then it won't be called until it is resumed.
|
|
144
|
+
If 'interval' is 0, it will be called every frame, but if so, it recommened to use 'scheduleUpdateForTarget:' instead.
|
|
145
|
+
If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
|
|
146
|
+
repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continiously
|
|
147
|
+
delay is the amount of time the action will wait before it'll start
|
|
148
|
+
|
|
149
|
+
@since v0.99.3, repeat and delay added in v1.1
|
|
150
|
+
*/
|
|
151
|
+
-(void) scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval paused:(BOOL)paused repeat: (uint) repeat delay: (ccTime) delay;
|
|
152
|
+
|
|
153
|
+
/** calls scheduleSelector with kCCRepeatForever and a 0 delay */
|
|
154
|
+
-(void) scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval paused:(BOOL)paused;
|
|
155
|
+
|
|
156
|
+
/** Schedules the 'update' selector for a given target with a given priority.
|
|
157
|
+
The 'update' selector will be called every frame.
|
|
158
|
+
The lower the priority, the earlier it is called.
|
|
159
|
+
@since v0.99.3
|
|
160
|
+
*/
|
|
161
|
+
-(void) scheduleUpdateForTarget:(id)target priority:(NSInteger)priority paused:(BOOL)paused;
|
|
162
|
+
|
|
163
|
+
/** Unshedules a selector for a given target.
|
|
164
|
+
If you want to unschedule the "update", use unscheudleUpdateForTarget.
|
|
165
|
+
@since v0.99.3
|
|
166
|
+
*/
|
|
167
|
+
-(void) unscheduleSelector:(SEL)selector forTarget:(id)target;
|
|
168
|
+
|
|
169
|
+
/** Unschedules the update selector for a given target
|
|
170
|
+
@since v0.99.3
|
|
171
|
+
*/
|
|
172
|
+
-(void) unscheduleUpdateForTarget:(id)target;
|
|
173
|
+
|
|
174
|
+
/** Unschedules all selectors for a given target.
|
|
175
|
+
This also includes the "update" selector.
|
|
176
|
+
@since v0.99.3
|
|
177
|
+
*/
|
|
178
|
+
-(void) unscheduleAllSelectorsForTarget:(id)target;
|
|
179
|
+
|
|
180
|
+
/** Unschedules all selectors from all targets.
|
|
181
|
+
You should NEVER call this method, unless you know what you are doing.
|
|
182
|
+
|
|
183
|
+
@since v0.99.3
|
|
184
|
+
*/
|
|
185
|
+
-(void) unscheduleAllSelectors;
|
|
186
|
+
|
|
187
|
+
/** Unschedules all selectors from all targets with a minimum priority.
|
|
188
|
+
You should only call this with kCCPriorityNonSystemMin or higher.
|
|
189
|
+
@since v2.0.0
|
|
190
|
+
*/
|
|
191
|
+
-(void) unscheduleAllSelectorsWithMinPriority:(NSInteger)minPriority;
|
|
192
|
+
|
|
193
|
+
/** Pauses the target.
|
|
194
|
+
All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
|
|
195
|
+
If the target is not present, nothing happens.
|
|
196
|
+
@since v0.99.3
|
|
197
|
+
*/
|
|
198
|
+
-(void) pauseTarget:(id)target;
|
|
199
|
+
|
|
200
|
+
/** Resumes the target.
|
|
201
|
+
The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
|
|
202
|
+
If the target is not present, nothing happens.
|
|
203
|
+
@since v0.99.3
|
|
204
|
+
*/
|
|
205
|
+
-(void) resumeTarget:(id)target;
|
|
206
|
+
|
|
207
|
+
/** Returns whether or not the target is paused
|
|
208
|
+
@since v1.0.0
|
|
209
|
+
*/
|
|
210
|
+
-(BOOL) isTargetPaused:(id)target;
|
|
211
|
+
|
|
212
|
+
/** Pause all selectors from all targets.
|
|
213
|
+
You should NEVER call this method, unless you know what you are doing.
|
|
214
|
+
@since v2.0.0
|
|
215
|
+
*/
|
|
216
|
+
-(NSSet*) pauseAllTargets;
|
|
217
|
+
|
|
218
|
+
/** Pause all selectors from all targets with a minimum priority.
|
|
219
|
+
You should only call this with kCCPriorityNonSystemMin or higher.
|
|
220
|
+
@since v2.0.0
|
|
221
|
+
*/
|
|
222
|
+
-(NSSet*) pauseAllTargetsWithMinPriority:(NSInteger)minPriority;
|
|
223
|
+
|
|
224
|
+
/** Resume selectors on a set of targets.
|
|
225
|
+
This can be useful for undoing a call to pauseAllSelectors.
|
|
226
|
+
@since v2.0.0
|
|
227
|
+
*/
|
|
228
|
+
-(void) resumeTargets:(NSSet *)targetsToResume;
|
|
229
|
+
|
|
230
|
+
@end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2008-2010 Ricardo Quesada
|
|
5
|
+
* Copyright (c) 2011 Zynga Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#import <Foundation/Foundation.h>
|
|
27
|
+
#import "ccMacros.h"
|
|
28
|
+
#ifdef __CC_PLATFORM_IOS
|
|
29
|
+
#import <OpenGLES/ES2/gl.h>
|
|
30
|
+
#endif // __CC_PLATFORM_IOS
|
|
31
|
+
|
|
32
|
+
@class CCGLProgram;
|
|
33
|
+
|
|
34
|
+
/** CCShaderCache
|
|
35
|
+
Singleton that stores manages GL shaders
|
|
36
|
+
@since v2.0
|
|
37
|
+
*/
|
|
38
|
+
@interface CCShaderCache : NSObject {
|
|
39
|
+
|
|
40
|
+
NSMutableDictionary *programs_;
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** returns the shared instance */
|
|
45
|
+
+ (CCShaderCache *)sharedShaderCache;
|
|
46
|
+
|
|
47
|
+
/** purges the cache. It releases the retained instance. */
|
|
48
|
+
+(void)purgeSharedShaderCache;
|
|
49
|
+
|
|
50
|
+
/** loads the default shaders */
|
|
51
|
+
-(void) loadDefaultShaders;
|
|
52
|
+
|
|
53
|
+
/** returns a GL program for a given key */
|
|
54
|
+
-(CCGLProgram *) programForKey:(NSString*)key;
|
|
55
|
+
|
|
56
|
+
/** adds a CCGLProgram to the cache for a given name */
|
|
57
|
+
- (void) addProgram:(CCGLProgram*)program forKey:(NSString*)key;
|
|
58
|
+
|
|
59
|
+
@end
|
|
60
|
+
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2008-2010 Ricardo Quesada
|
|
5
|
+
* Copyright (c) 2011 Zynga Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#import "CCNode.h"
|
|
29
|
+
#import "CCProtocols.h"
|
|
30
|
+
#import "CCTextureAtlas.h"
|
|
31
|
+
|
|
32
|
+
@class CCSpriteBatchNode;
|
|
33
|
+
@class CCSpriteFrame;
|
|
34
|
+
@class CCAnimation;
|
|
35
|
+
|
|
36
|
+
#pragma mark CCSprite
|
|
37
|
+
|
|
38
|
+
#define CCSpriteIndexNotInitialized 0xffffffff /// CCSprite invalid index on the CCSpriteBatchode
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/** CCSprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
|
|
42
|
+
*
|
|
43
|
+
* CCSprite can be created with an image, or with a sub-rectangle of an image.
|
|
44
|
+
*
|
|
45
|
+
* If the parent or any of its ancestors is a CCSpriteBatchNode then the following features/limitations are valid
|
|
46
|
+
* - Features when the parent is a CCBatchNode:
|
|
47
|
+
* - MUCH faster rendering, specially if the CCSpriteBatchNode has many children. All the children will be drawn in a single batch.
|
|
48
|
+
*
|
|
49
|
+
* - Limitations
|
|
50
|
+
* - Camera is not supported yet (eg: CCOrbitCamera action doesn't work)
|
|
51
|
+
* - GridBase actions are not supported (eg: CCLens, CCRipple, CCTwirl)
|
|
52
|
+
* - The Alias/Antialias property belongs to CCSpriteBatchNode, so you can't individually set the aliased property.
|
|
53
|
+
* - The Blending function property belongs to CCSpriteBatchNode, so you can't individually set the blending function property.
|
|
54
|
+
* - Parallax scroller is not supported, but can be simulated with a "proxy" sprite.
|
|
55
|
+
*
|
|
56
|
+
* If the parent is an standard CCNode, then CCSprite behaves like any other CCNode:
|
|
57
|
+
* - It supports blending functions
|
|
58
|
+
* - It supports aliasing / antialiasing
|
|
59
|
+
* - But the rendering will be slower: 1 draw per children.
|
|
60
|
+
*
|
|
61
|
+
* The default anchorPoint in CCSprite is (0.5, 0.5).
|
|
62
|
+
*/
|
|
63
|
+
@interface CCSprite : CCNode <CCRGBAProtocol, CCTextureProtocol>
|
|
64
|
+
{
|
|
65
|
+
|
|
66
|
+
//
|
|
67
|
+
// Data used when the sprite is rendered using a CCSpriteBatchNode
|
|
68
|
+
//
|
|
69
|
+
CCTextureAtlas *textureAtlas_; // Sprite Sheet texture atlas (weak reference)
|
|
70
|
+
NSUInteger atlasIndex_; // Absolute (real) Index on the batch node
|
|
71
|
+
CCSpriteBatchNode *batchNode_; // Used batch node (weak reference)
|
|
72
|
+
CGAffineTransform transformToBatch_; //
|
|
73
|
+
BOOL dirty_; // Sprite needs to be updated
|
|
74
|
+
BOOL recursiveDirty_; // Subchildren needs to be updated
|
|
75
|
+
BOOL hasChildren_; // optimization to check if it contain children
|
|
76
|
+
BOOL shouldBeHidden_; // should not be drawn because one of the ancestors is not visible
|
|
77
|
+
|
|
78
|
+
//
|
|
79
|
+
// Data used when the sprite is self-rendered
|
|
80
|
+
//
|
|
81
|
+
ccBlendFunc blendFunc_; // Needed for the texture protocol
|
|
82
|
+
CCTexture2D *texture_; // Texture used to render the sprite
|
|
83
|
+
|
|
84
|
+
//
|
|
85
|
+
// Shared data
|
|
86
|
+
//
|
|
87
|
+
|
|
88
|
+
// sprite rectangle
|
|
89
|
+
CGRect rect_;
|
|
90
|
+
|
|
91
|
+
// texture
|
|
92
|
+
BOOL rectRotated_;
|
|
93
|
+
|
|
94
|
+
// Offset Position (used by Zwoptex)
|
|
95
|
+
CGPoint offsetPosition_;
|
|
96
|
+
CGPoint unflippedOffsetPositionFromCenter_;
|
|
97
|
+
|
|
98
|
+
// vertex coords, texture coords and color info
|
|
99
|
+
ccV3F_C4B_T2F_Quad quad_;
|
|
100
|
+
|
|
101
|
+
// opacity and RGB protocol
|
|
102
|
+
GLubyte opacity_;
|
|
103
|
+
ccColor3B color_;
|
|
104
|
+
ccColor3B colorUnmodified_;
|
|
105
|
+
BOOL opacityModifyRGB_;
|
|
106
|
+
|
|
107
|
+
// image is flipped
|
|
108
|
+
BOOL flipX_;
|
|
109
|
+
BOOL flipY_;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** whether or not the Sprite needs to be updated in the Atlas */
|
|
113
|
+
@property (nonatomic,readwrite) BOOL dirty;
|
|
114
|
+
/** the quad (tex coords, vertex coords and color) information */
|
|
115
|
+
@property (nonatomic,readonly) ccV3F_C4B_T2F_Quad quad;
|
|
116
|
+
/** The index used on the TextureAtlas. Don't modify this value unless you know what you are doing */
|
|
117
|
+
@property (nonatomic,readwrite) NSUInteger atlasIndex;
|
|
118
|
+
/** returns the texture rect of the CCSprite in points */
|
|
119
|
+
@property (nonatomic,readonly) CGRect textureRect;
|
|
120
|
+
/** returns whether or not the texture rectangle is rotated */
|
|
121
|
+
@property (nonatomic,readonly) BOOL textureRectRotated;
|
|
122
|
+
/** whether or not the sprite is flipped horizontally.
|
|
123
|
+
It only flips the texture of the sprite, and not the texture of the sprite's children.
|
|
124
|
+
Also, flipping the texture doesn't alter the anchorPoint.
|
|
125
|
+
If you want to flip the anchorPoint too, and/or to flip the children too use:
|
|
126
|
+
|
|
127
|
+
sprite.scaleX *= -1;
|
|
128
|
+
*/
|
|
129
|
+
@property (nonatomic,readwrite) BOOL flipX;
|
|
130
|
+
/** whether or not the sprite is flipped vertically.
|
|
131
|
+
It only flips the texture of the sprite, and not the texture of the sprite's children.
|
|
132
|
+
Also, flipping the texture doesn't alter the anchorPoint.
|
|
133
|
+
If you want to flip the anchorPoint too, and/or to flip the children too use:
|
|
134
|
+
|
|
135
|
+
sprite.scaleY *= -1;
|
|
136
|
+
*/
|
|
137
|
+
@property (nonatomic,readwrite) BOOL flipY;
|
|
138
|
+
/** opacity: conforms to CCRGBAProtocol protocol */
|
|
139
|
+
@property (nonatomic,readwrite) GLubyte opacity;
|
|
140
|
+
/** RGB colors: conforms to CCRGBAProtocol protocol */
|
|
141
|
+
@property (nonatomic,readwrite) ccColor3B color;
|
|
142
|
+
/** weak reference of the CCTextureAtlas used when the sprite is rendered using a CCSpriteBatchNode */
|
|
143
|
+
@property (nonatomic,readwrite,assign) CCTextureAtlas *textureAtlas;
|
|
144
|
+
/** weak reference to the CCSpriteBatchNode that renders the CCSprite */
|
|
145
|
+
@property (nonatomic,readwrite,assign) CCSpriteBatchNode *batchNode;
|
|
146
|
+
/** offset position in points of the sprite in points. Calculated automatically by editors like Zwoptex.
|
|
147
|
+
@since v0.99.0
|
|
148
|
+
*/
|
|
149
|
+
@property (nonatomic,readonly) CGPoint offsetPosition;
|
|
150
|
+
/** conforms to CCTextureProtocol protocol */
|
|
151
|
+
@property (nonatomic,readwrite) ccBlendFunc blendFunc;
|
|
152
|
+
|
|
153
|
+
#pragma mark CCSprite - Initializers
|
|
154
|
+
|
|
155
|
+
/** Creates an sprite with a texture.
|
|
156
|
+
The rect used will be the size of the texture.
|
|
157
|
+
The offset will be (0,0).
|
|
158
|
+
*/
|
|
159
|
+
+(id) spriteWithTexture:(CCTexture2D*)texture;
|
|
160
|
+
|
|
161
|
+
/** Creates an sprite with a texture and a rect.
|
|
162
|
+
The offset will be (0,0).
|
|
163
|
+
*/
|
|
164
|
+
+(id) spriteWithTexture:(CCTexture2D*)texture rect:(CGRect)rect;
|
|
165
|
+
|
|
166
|
+
/** Creates an sprite with an sprite frame.
|
|
167
|
+
*/
|
|
168
|
+
+(id) spriteWithSpriteFrame:(CCSpriteFrame*)spriteFrame;
|
|
169
|
+
|
|
170
|
+
/** Creates an sprite with an sprite frame name.
|
|
171
|
+
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
|
|
172
|
+
If the CCSpriteFrame doesn't exist it will raise an exception.
|
|
173
|
+
@since v0.9
|
|
174
|
+
*/
|
|
175
|
+
+(id) spriteWithSpriteFrameName:(NSString*)spriteFrameName;
|
|
176
|
+
|
|
177
|
+
/** Creates an sprite with an image filename.
|
|
178
|
+
The rect used will be the size of the image.
|
|
179
|
+
The offset will be (0,0).
|
|
180
|
+
*/
|
|
181
|
+
+(id) spriteWithFile:(NSString*)filename;
|
|
182
|
+
|
|
183
|
+
/** Creates an sprite with an image filename and a rect.
|
|
184
|
+
The offset will be (0,0).
|
|
185
|
+
*/
|
|
186
|
+
+(id) spriteWithFile:(NSString*)filename rect:(CGRect)rect;
|
|
187
|
+
|
|
188
|
+
/** Creates an sprite with a CGImageRef and a key.
|
|
189
|
+
The key is used by the CCTextureCache to know if a texture was already created with this CGImage.
|
|
190
|
+
For example, a valid key is: @"sprite_frame_01".
|
|
191
|
+
If key is nil, then a new texture will be created each time by the CCTextureCache.
|
|
192
|
+
@since v0.99.0
|
|
193
|
+
*/
|
|
194
|
+
+(id) spriteWithCGImage: (CGImageRef)image key:(NSString*)key;
|
|
195
|
+
|
|
196
|
+
/** Initializes an sprite with a texture.
|
|
197
|
+
The rect used will be the size of the texture.
|
|
198
|
+
The offset will be (0,0).
|
|
199
|
+
*/
|
|
200
|
+
-(id) initWithTexture:(CCTexture2D*)texture;
|
|
201
|
+
|
|
202
|
+
/** Initializes an sprite with a texture and a rect in points (unrotated)
|
|
203
|
+
The offset will be (0,0).
|
|
204
|
+
*/
|
|
205
|
+
-(id) initWithTexture:(CCTexture2D*)texture rect:(CGRect)rect;
|
|
206
|
+
|
|
207
|
+
/** Initializes an sprite with a texture and a rect in points, optionally rotated.
|
|
208
|
+
The offset will be (0,0).
|
|
209
|
+
IMPORTANT: This is the designated initializer.
|
|
210
|
+
*/
|
|
211
|
+
- (id)initWithTexture:(CCTexture2D *)texture rect:(CGRect)rect rotated:(BOOL)rotated;
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
/** Initializes an sprite with an sprite frame.
|
|
215
|
+
*/
|
|
216
|
+
-(id) initWithSpriteFrame:(CCSpriteFrame*)spriteFrame;
|
|
217
|
+
|
|
218
|
+
/** Initializes an sprite with an sprite frame name.
|
|
219
|
+
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
|
|
220
|
+
If the CCSpriteFrame doesn't exist it will raise an exception.
|
|
221
|
+
@since v0.9
|
|
222
|
+
*/
|
|
223
|
+
-(id) initWithSpriteFrameName:(NSString*)spriteFrameName;
|
|
224
|
+
|
|
225
|
+
/** Initializes an sprite with an image filename.
|
|
226
|
+
The rect used will be the size of the image.
|
|
227
|
+
The offset will be (0,0).
|
|
228
|
+
*/
|
|
229
|
+
-(id) initWithFile:(NSString*)filename;
|
|
230
|
+
|
|
231
|
+
/** Initializes an sprite with an image filename, and a rect.
|
|
232
|
+
The offset will be (0,0).
|
|
233
|
+
*/
|
|
234
|
+
-(id) initWithFile:(NSString*)filename rect:(CGRect)rect;
|
|
235
|
+
|
|
236
|
+
/** Initializes an sprite with a CGImageRef and a key
|
|
237
|
+
The key is used by the CCTextureCache to know if a texture was already created with this CGImage.
|
|
238
|
+
For example, a valid key is: @"sprite_frame_01".
|
|
239
|
+
If key is nil, then a new texture will be created each time by the CCTextureCache.
|
|
240
|
+
@since v0.99.0
|
|
241
|
+
*/
|
|
242
|
+
-(id) initWithCGImage:(CGImageRef)image key:(NSString*)key;
|
|
243
|
+
|
|
244
|
+
#pragma mark CCSprite - BatchNode methods
|
|
245
|
+
|
|
246
|
+
/** updates the quad according the the rotation, position, scale values.
|
|
247
|
+
*/
|
|
248
|
+
-(void)updateTransform;
|
|
249
|
+
|
|
250
|
+
#pragma mark CCSprite - Texture methods
|
|
251
|
+
|
|
252
|
+
/** set the texture rect of the CCSprite in points.
|
|
253
|
+
It will call setTextureRect:rotated:untrimmedSize with rotated = NO, and utrimmedSize = rect.size.
|
|
254
|
+
*/
|
|
255
|
+
-(void) setTextureRect:(CGRect) rect;
|
|
256
|
+
|
|
257
|
+
/** set the texture rect, rectRotated and untrimmed size of the CCSprite in points.
|
|
258
|
+
It will update the texture coordinates and the vertex rectangle.
|
|
259
|
+
*/
|
|
260
|
+
-(void) setTextureRect:(CGRect)rect rotated:(BOOL)rotated untrimmedSize:(CGSize)size;
|
|
261
|
+
|
|
262
|
+
/** set the vertex rect.
|
|
263
|
+
It will be called internally by setTextureRect. Useful if you want to create 2x images from SD images in Retina Display.
|
|
264
|
+
Do not call it manually. Use setTextureRect instead.
|
|
265
|
+
*/
|
|
266
|
+
-(void)setVertexRect:(CGRect)rect;
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
#pragma mark CCSprite - Frames
|
|
270
|
+
|
|
271
|
+
/** sets a new display frame to the CCSprite. */
|
|
272
|
+
-(void) setDisplayFrame:(CCSpriteFrame*)newFrame;
|
|
273
|
+
|
|
274
|
+
/** returns whether or not a CCSpriteFrame is being displayed */
|
|
275
|
+
-(BOOL) isFrameDisplayed:(CCSpriteFrame*)frame;
|
|
276
|
+
|
|
277
|
+
/** returns the current displayed frame. */
|
|
278
|
+
-(CCSpriteFrame*) displayFrame;
|
|
279
|
+
|
|
280
|
+
#pragma mark CCSprite - Animation
|
|
281
|
+
|
|
282
|
+
/** changes the display frame with animation name and index.
|
|
283
|
+
The animation name will be get from the CCAnimationCache
|
|
284
|
+
@since v0.99.5
|
|
285
|
+
*/
|
|
286
|
+
-(void) setDisplayFrameWithAnimationName:(NSString*)animationName index:(int) frameIndex;
|
|
287
|
+
|
|
288
|
+
@end
|