Permalink
Browse files

This version is the same as 0.2, with no example and cocos2d-iPhone 0…

….9.4 compatability

Signed-off-by: Nick Pannuto <sneakyness@sneakyness.com>
  • Loading branch information...
1 parent b48173a commit b0312c9ee10013157f2e2c55c773b5c8ef5e9439 @sneakyness committed Dec 4, 2010
Showing with 49,505 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +31 −0 Classes/ColoredCircleSprite.h
  3. +161 −0 Classes/ColoredCircleSprite.m
  4. +26 −0 Classes/HelloWorldScene.h
  5. +79 −0 Classes/HelloWorldScene.m
  6. +38 −0 Classes/SneakyButton.h
  7. +115 −0 Classes/SneakyButton.m
  8. +28 −0 Classes/SneakyButtonSkinnedBase.h
  9. +155 −0 Classes/SneakyButtonSkinnedBase.m
  10. +17 −0 Classes/SneakyInput_0_4_0AppDelegate.h
  11. +83 −0 Classes/SneakyInput_0_4_0AppDelegate.m
  12. +49 −0 Classes/SneakyJoystick.h
  13. +188 −0 Classes/SneakyJoystick.m
  14. +25 −0 Classes/SneakyJoystickSkinnedBase.h
  15. +100 −0 Classes/SneakyJoystickSkinnedBase.m
  16. +14 −0 Classes/SneakyJoystickSkinnedDPadExample.h
  17. +34 −0 Classes/SneakyJoystickSkinnedDPadExample.m
  18. +15 −0 Classes/SneakyJoystickSkinnedJoystickExample.h
  19. +33 −0 Classes/SneakyJoystickSkinnedJoystickExample.m
  20. +22 −0 LICENSE.cocos2d
  21. +21 −0 LICENSE.cocosdenshion
  22. BIN Resources/Default.png
  23. BIN Resources/Icon.png
  24. +33 −0 Resources/Info.plist
  25. BIN Resources/fps_images.png
  26. +1,373 −0 SneakyInput 0.4.0.xcodeproj/project.pbxproj
  27. +500 −0 SneakyInput 0.4.0.xcodeproj/sneaky.pbxuser
  28. +1,507 −0 SneakyInput 0.4.0.xcodeproj/sneaky.perspectivev3
  29. +8 −0 SneakyInput_0_4_0_Prefix.pch
  30. +227 −0 libs/CocosDenshion/CDAudioManager.h
  31. +794 −0 libs/CocosDenshion/CDAudioManager.m
  32. +60 −0 libs/CocosDenshion/CDConfig.h
  33. +77 −0 libs/CocosDenshion/CDOpenALSupport.h
  34. +246 −0 libs/CocosDenshion/CDOpenALSupport.m
  35. +419 −0 libs/CocosDenshion/CocosDenshion.h
  36. +1,682 −0 libs/CocosDenshion/CocosDenshion.m
  37. +90 −0 libs/CocosDenshion/SimpleAudioEngine.h
  38. +222 −0 libs/CocosDenshion/SimpleAudioEngine.m
  39. +44 −0 libs/FontLabel/FontLabel.h
  40. +186 −0 libs/FontLabel/FontLabel.m
  41. +69 −0 libs/FontLabel/FontLabelStringDrawing.h
  42. +890 −0 libs/FontLabel/FontLabelStringDrawing.m
  43. +85 −0 libs/FontLabel/FontManager.h
  44. +124 −0 libs/FontLabel/FontManager.m
  45. +77 −0 libs/FontLabel/ZAttributedString.h
  46. +596 −0 libs/FontLabel/ZAttributedString.m
  47. +24 −0 libs/FontLabel/ZAttributedStringPrivate.h
  48. +47 −0 libs/FontLabel/ZFont.h
  49. +170 −0 libs/FontLabel/ZFont.m
  50. +1 −0 libs/README
  51. +68 −0 libs/TouchJSON/CDataScanner.h
  52. +270 −0 libs/TouchJSON/CDataScanner.m
  53. +37 −0 libs/TouchJSON/Extensions/CDataScanner_Extensions.h
  54. +80 −0 libs/TouchJSON/Extensions/CDataScanner_Extensions.m
  55. +36 −0 libs/TouchJSON/Extensions/NSCharacterSet_Extensions.h
  56. +48 −0 libs/TouchJSON/Extensions/NSCharacterSet_Extensions.m
  57. +36 −0 libs/TouchJSON/Extensions/NSDictionary_JSONExtensions.h
  58. +41 −0 libs/TouchJSON/Extensions/NSDictionary_JSONExtensions.m
  59. +44 −0 libs/TouchJSON/Extensions/NSScanner_Extensions.h
  60. +118 −0 libs/TouchJSON/Extensions/NSScanner_Extensions.m
  61. +59 −0 libs/TouchJSON/JSON/CJSONDeserializer.h
  62. +84 −0 libs/TouchJSON/JSON/CJSONDeserializer.m
  63. +43 −0 libs/TouchJSON/JSON/CJSONScanner.h
  64. +536 −0 libs/TouchJSON/JSON/CJSONScanner.m
  65. +45 −0 libs/TouchJSON/JSON/CJSONSerializer.h
  66. +184 −0 libs/TouchJSON/JSON/CJSONSerializer.m
  67. +187 −0 libs/cocos2d/CCAction.h
  68. +358 −0 libs/cocos2d/CCAction.m
  69. +118 −0 libs/cocos2d/CCActionManager.h
  70. +353 −0 libs/cocos2d/CCActionManager.m
  71. +91 −0 libs/cocos2d/CCAtlasNode.h
  72. +211 −0 libs/cocos2d/CCAtlasNode.m
  73. +176 −0 libs/cocos2d/CCBitmapFontAtlas.h
  74. +624 −0 libs/cocos2d/CCBitmapFontAtlas.m
  75. +62 −0 libs/cocos2d/CCBlockSupport.h
  76. +46 −0 libs/cocos2d/CCBlockSupport.m
  77. +88 −0 libs/cocos2d/CCCamera.h
  78. +134 −0 libs/cocos2d/CCCamera.m
  79. +71 −0 libs/cocos2d/CCCameraAction.h
  80. +142 −0 libs/cocos2d/CCCameraAction.m
  81. +224 −0 libs/cocos2d/CCCompatibility.h
  82. +596 −0 libs/cocos2d/CCCompatibility.m
  83. +84 −0 libs/cocos2d/CCConfiguration.h
  84. +134 −0 libs/cocos2d/CCConfiguration.m
  85. +526 −0 libs/cocos2d/CCDirector.h
  86. +1,215 −0 libs/cocos2d/CCDirector.m
  87. +82 −0 libs/cocos2d/CCDrawingPrimitives.h
  88. +217 −0 libs/cocos2d/CCDrawingPrimitives.m
  89. +159 −0 libs/cocos2d/CCEaseAction.h
  90. +531 −0 libs/cocos2d/CCEaseAction.m
  91. +44 −0 libs/cocos2d/CCGrabber.h
  92. +95 −0 libs/cocos2d/CCGrabber.m
  93. +121 −0 libs/cocos2d/CCGrid.h
  94. +550 −0 libs/cocos2d/CCGrid.m
  95. +205 −0 libs/cocos2d/CCGrid3DAction.h
  96. +615 −0 libs/cocos2d/CCGrid3DAction.m
  97. +169 −0 libs/cocos2d/CCGridAction.h
  98. +391 −0 libs/cocos2d/CCGridAction.m
  99. +177 −0 libs/cocos2d/CCInstantAction.h
  100. +410 −0 libs/cocos2d/CCInstantAction.m
  101. +386 −0 libs/cocos2d/CCIntervalAction.h
  102. +1,216 −0 libs/cocos2d/CCIntervalAction.m
  103. +58 −0 libs/cocos2d/CCLabel.h
  104. +106 −0 libs/cocos2d/CCLabel.m
  105. +55 −0 libs/cocos2d/CCLabelAtlas.h
  106. +163 −0 libs/cocos2d/CCLabelAtlas.m
  107. +144 −0 libs/cocos2d/CCLayer.h
  108. +339 −0 libs/cocos2d/CCLayer.m
  109. +86 −0 libs/cocos2d/CCMenu.h
  110. +414 −0 libs/cocos2d/CCMenu.m
  111. +309 −0 libs/cocos2d/CCMenuItem.h
  112. +698 −0 libs/cocos2d/CCMenuItem.m
  113. +67 −0 libs/cocos2d/CCMotionStreak.h
  114. +104 −0 libs/cocos2d/CCMotionStreak.m
  115. +481 −0 libs/cocos2d/CCNode.h
  116. +790 −0 libs/cocos2d/CCNode.m
  117. +81 −0 libs/cocos2d/CCPVRTexture.h
  118. +284 −0 libs/cocos2d/CCPVRTexture.m
  119. +41 −0 libs/cocos2d/CCPageTurn3DAction.h
  120. +90 −0 libs/cocos2d/CCPageTurn3DAction.m
  121. +60 −0 libs/cocos2d/CCPageTurnTransition.h
  122. +115 −0 libs/cocos2d/CCPageTurnTransition.m
  123. +48 −0 libs/cocos2d/CCParallaxNode.h
  124. +161 −0 libs/cocos2d/CCParallaxNode.m
  125. +94 −0 libs/cocos2d/CCParticleExamples.h
  126. +925 −0 libs/cocos2d/CCParticleExamples.m
  127. +436 −0 libs/cocos2d/CCParticleSystem.h
  128. +760 −0 libs/cocos2d/CCParticleSystem.m
  129. +51 −0 libs/cocos2d/CCPointParticleSystem.h
  130. +191 −0 libs/cocos2d/CCPointParticleSystem.m
  131. +82 −0 libs/cocos2d/CCProgressTimer.h
  132. +488 −0 libs/cocos2d/CCProgressTimer.m
  133. +59 −0 libs/cocos2d/CCProgressTimerActions.h
  134. +102 −0 libs/cocos2d/CCProgressTimerActions.m
  135. +62 −0 libs/cocos2d/CCPropertyAction.h
  136. +75 −0 libs/cocos2d/CCPropertyAction.m
  137. +112 −0 libs/cocos2d/CCProtocols.h
  138. +71 −0 libs/cocos2d/CCQuadParticleSystem.h
  139. +299 −0 libs/cocos2d/CCQuadParticleSystem.m
  140. +39 −0 libs/cocos2d/CCRadialTransition.h
  141. +106 −0 libs/cocos2d/CCRadialTransition.m
  142. +76 −0 libs/cocos2d/CCRenderTexture.h
  143. +231 −0 libs/cocos2d/CCRenderTexture.m
  144. +117 −0 libs/cocos2d/CCRibbon.h
  145. +380 −0 libs/cocos2d/CCRibbon.m
  146. +45 −0 libs/cocos2d/CCScene.h
  147. +44 −0 libs/cocos2d/CCScene.m
  148. +213 −0 libs/cocos2d/CCScheduler.h
  149. +590 −0 libs/cocos2d/CCScheduler.m
  150. +333 −0 libs/cocos2d/CCSprite.h
  151. +914 −0 libs/cocos2d/CCSprite.m
  152. +145 −0 libs/cocos2d/CCSpriteFrame.h
  153. +174 −0 libs/cocos2d/CCSpriteFrame.m
  154. +109 −0 libs/cocos2d/CCSpriteFrameCache.h
  155. +228 −0 libs/cocos2d/CCSpriteFrameCache.m
  156. +136 −0 libs/cocos2d/CCSpriteSheet.h
  157. +488 −0 libs/cocos2d/CCSpriteSheet.m
  158. +153 −0 libs/cocos2d/CCTMXLayer.h
  159. +659 −0 libs/cocos2d/CCTMXLayer.m
  160. +66 −0 libs/cocos2d/CCTMXObjectGroup.h
  161. +83 −0 libs/cocos2d/CCTMXObjectGroup.m
  162. +145 −0 libs/cocos2d/CCTMXTiledMap.h
  163. +202 −0 libs/cocos2d/CCTMXTiledMap.m
  164. +192 −0 libs/cocos2d/CCTMXXMLParser.h
  165. +444 −0 libs/cocos2d/CCTMXXMLParser.m
  166. +249 −0 libs/cocos2d/CCTexture2D.h
  167. +590 −0 libs/cocos2d/CCTexture2D.m
  168. +137 −0 libs/cocos2d/CCTextureAtlas.h
  169. +337 −0 libs/cocos2d/CCTextureAtlas.m
  170. +117 −0 libs/cocos2d/CCTextureCache.h
  171. +342 −0 libs/cocos2d/CCTextureCache.m
  172. +19 −0 libs/cocos2d/CCTextureNode.h
  173. +19 −0 libs/cocos2d/CCTextureNode.m
  174. +81 −0 libs/cocos2d/CCTileMapAtlas.h
  175. +215 −0 libs/cocos2d/CCTileMapAtlas.m
  176. +211 −0 libs/cocos2d/CCTiledGridAction.h
  177. +765 −0 libs/cocos2d/CCTiledGridAction.m
  178. +68 −0 libs/cocos2d/CCTouchDelegateProtocol.h
  179. +116 −0 libs/cocos2d/CCTouchDispatcher.h
  180. +320 −0 libs/cocos2d/CCTouchDispatcher.m
  181. +87 −0 libs/cocos2d/CCTouchHandler.h
  182. +127 −0 libs/cocos2d/CCTouchHandler.m
  183. +295 −0 libs/cocos2d/CCTransition.h
  184. +1,046 −0 libs/cocos2d/CCTransition.m
  185. +96 −0 libs/cocos2d/Support/CCArray.h
  186. +234 −0 libs/cocos2d/Support/CCArray.m
  187. +36 −0 libs/cocos2d/Support/CCFileUtils.h
  188. +54 −0 libs/cocos2d/Support/CCFileUtils.m
  189. +53 −0 libs/cocos2d/Support/CCProfiling.h
  190. +117 −0 libs/cocos2d/Support/CCProfiling.m
  191. +315 −0 libs/cocos2d/Support/CGPointExtension.h
  192. +167 −0 libs/cocos2d/Support/CGPointExtension.m
  193. +146 −0 libs/cocos2d/Support/EAGLView.h
  194. +264 −0 libs/cocos2d/Support/EAGLView.m
  195. +58 −0 libs/cocos2d/Support/ES1Renderer.h
  196. +152 −0 libs/cocos2d/Support/ES1Renderer.m
  197. +42 −0 libs/cocos2d/Support/ESRenderer.h
  198. +80 −0 libs/cocos2d/Support/OpenGL_Internal.h
  199. +55 −0 libs/cocos2d/Support/TGAlib.h
  200. +272 −0 libs/cocos2d/Support/TGAlib.m
  201. +30 −0 libs/cocos2d/Support/TransformUtils.h
  202. +46 −0 libs/cocos2d/Support/TransformUtils.m
  203. +41 −0 libs/cocos2d/Support/ZipUtils.h
  204. +125 −0 libs/cocos2d/Support/ZipUtils.m
  205. +89 −0 libs/cocos2d/Support/base64.c
  206. +33 −0 libs/cocos2d/Support/base64.h
  207. +403 −0 libs/cocos2d/Support/ccCArray.h
  208. +108 −0 libs/cocos2d/Support/glu.c
  209. +21 −0 libs/cocos2d/Support/glu.h
  210. +956 −0 libs/cocos2d/Support/uthash.h
  211. +493 −0 libs/cocos2d/Support/utlist.h
  212. +178 −0 libs/cocos2d/ccConfig.h
  213. +30 −0 libs/cocos2d/ccExceptions.h
  214. +177 −0 libs/cocos2d/ccMacros.h
  215. +253 −0 libs/cocos2d/ccTypes.h
  216. +133 −0 libs/cocos2d/cocos2d.h
  217. +33 −0 libs/cocos2d/cocos2d.m
  218. +141 −0 libs/cocoslive/CLScoreServerPost.h
  219. +330 −0 libs/cocoslive/CLScoreServerPost.m
  220. +121 −0 libs/cocoslive/CLScoreServerRequest.h
  221. +254 −0 libs/cocoslive/CLScoreServerRequest.m
  222. +42 −0 libs/cocoslive/cocoslive.h
  223. +34 −0 libs/cocoslive/cocoslive.m
  224. +16 −0 main.m
View
@@ -0,0 +1 @@
+/build/
@@ -0,0 +1,31 @@
+#import "cocos2d.h"
+
+@interface ColoredCircleSprite : CCNode <CCRGBAProtocol, CCBlendProtocol> {
+ float radius_;
+ GLubyte opacity_;
+ ccColor3B color_;
+
+ NSUInteger numberOfSegments;
+ GLfloat *circleVertices_;
+
+ ccBlendFunc blendFunc_;
+}
+
+@property (nonatomic,readwrite) float radius;
+
+/** Opacity: conforms to CCRGBAProtocol protocol */
+@property (nonatomic,readonly) GLubyte opacity;
+/** Opacity: conforms to CCRGBAProtocol protocol */
+@property (nonatomic,readonly) ccColor3B color;
+/** BlendFunction. Conforms to CCBlendProtocol protocol */
+@property (nonatomic,readwrite) ccBlendFunc blendFunc;
+
+/** creates a Circle with color and radius */
++ (id) circleWithColor: (ccColor4B)color radius:(GLfloat)r;
+
+/** initializes a Circle with color and radius */
+- (id) initWithColor:(ccColor4B)color radius:(GLfloat)r;
+
+- (BOOL) containsPoint:(CGPoint)point;
+
+@end
@@ -0,0 +1,161 @@
+
+#import "ColoredCircleSprite.h"
+
+@interface ColoredCircleSprite (privateMethods)
+- (void) updateContentSize;
+- (void) updateColor;
+@end
+
+
+@implementation ColoredCircleSprite
+
+@synthesize radius=radius_;
+ // Opacity and RGB color protocol
+@synthesize opacity=opacity_, color=color_;
+@synthesize blendFunc=blendFunc_;
+
++ (id) circleWithColor: (ccColor4B)color radius:(GLfloat)r
+{
+ return [[[self alloc] initWithColor:color radius:r] autorelease];
+}
+
+- (id) initWithColor:(ccColor4B)color radius:(GLfloat)r
+{
+ if( (self=[self init]) ) {
+ self.radius = r;
+
+ color_.r = color.r;
+ color_.g = color.g;
+ color_.b = color.b;
+ opacity_ = color.a;
+ }
+ return self;
+}
+
+- (void) dealloc
+{
+ free(circleVertices_);
+ [super dealloc];
+}
+
+- (id) init
+{
+ if((self = [super init])){
+ radius_ = 10.0f;
+ numberOfSegments = 36U;
+
+ // default blend function
+ blendFunc_ = (ccBlendFunc) { CC_BLEND_SRC, CC_BLEND_DST };
+
+ color_.r =
+ color_.g =
+ color_.b = 0U;
+ opacity_ = 255U;
+
+ circleVertices_ = malloc(sizeof(GLfloat)*2*(numberOfSegments));
+ if(!circleVertices_){
+ NSLog(@"Ack!! malloc in colored circle failed");
+ [self release];
+ return nil;
+ }
+ memset(circleVertices_, 0, sizeof(GLfloat)*2*(numberOfSegments));
+
+ self.radius = radius_;
+ }
+ return self;
+}
+
+-(void) setRadius: (float) size
+{
+ radius_ = size;
+ const float theta_inc = 2.0f * 3.14159265359f/numberOfSegments;
+ float theta = 0.0f;
+
+ for(int i=0; i<numberOfSegments; i++)
+ {
+ float j = radius_ * cosf(theta) + position_.x;
+ float k = radius_ * sinf(theta) + position_.y;
+
+ circleVertices_[i*2] = j;
+ circleVertices_[i*2+1] = k;
+
+ theta += theta_inc;
+ }
+
+ [self updateContentSize];
+}
+
+-(void) setContentSize: (CGSize) size
+{
+ self.radius = size.width/2;
+}
+
+- (void) updateContentSize
+{
+ [super setContentSize:CGSizeMake(radius_*2, radius_*2)];
+}
+
+- (void)draw
+{
+ // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
+ // Needed states: GL_VERTEX_ARRAY
+ // Unneeded states: GL_COLOR_ARRAY, GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisable(GL_TEXTURE_2D);
+
+ glVertexPointer(2, GL_FLOAT, 0, circleVertices_);
+ glColor4f(color_.r/255.0f, color_.g/255.0f, color_.b/255.0f, opacity_/255.0f);
+
+ BOOL newBlend = NO;
+ if( blendFunc_.src != CC_BLEND_SRC || blendFunc_.dst != CC_BLEND_DST ) {
+ newBlend = YES;
+ glBlendFunc(blendFunc_.src, blendFunc_.dst);
+ }else if( opacity_ == 255 ) {
+ newBlend = YES;
+ glBlendFunc(GL_ONE, GL_ZERO);
+ }else{
+ newBlend = YES;
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, numberOfSegments);
+
+ if( newBlend )
+ glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
+
+ // restore default GL state
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+}
+
+#pragma mark Protocols
+ // Color Protocol
+
+-(void) setColor:(ccColor3B)color
+{
+ color_ = color;
+}
+
+-(void) setOpacity: (GLubyte) o
+{
+ opacity_ = o;
+ [self updateColor];
+}
+
+#pragma mark Touch
+
+- (BOOL) containsPoint:(CGPoint)point
+{
+ float dSq = point.x * point.x + point.y * point.y;
+ float rSq = radius_ * radius_;
+ return (dSq <= rSq );
+}
+
+- (NSString*) description
+{
+ return [NSString stringWithFormat:@"<%@ = %08X | Tag = %i | Color = %02X%02X%02X%02X | Radius = %1.2f>", [self class], self, tag_, color_.r, color_.g, color_.b, opacity_, radius_];
+}
+
+@end
View
@@ -0,0 +1,26 @@
+//
+// HelloWorldLayer.h
+// SneakyInput 0.4.0
+//
+// Created by Nick Pannuto on 12/3/10.
+// Copyright Sneakyness, llc. 2010. All rights reserved.
+//
+
+
+// When you import this file, you import all the cocos2d classes
+#import "cocos2d.h"
+
+@class SneakyJoystick;
+@class SneakyButton;
+
+// HelloWorld Layer
+@interface HelloWorld : CCLayer
+{
+ SneakyJoystick *leftJoystick;
+ SneakyButton *rightButton;
+}
+
+// returns a Scene that contains the HelloWorld as the only child
++(id) scene;
+
+@end
View
@@ -0,0 +1,79 @@
+//
+// HelloWorldLayer.m
+// SneakyInput 0.4.0
+//
+// Created by Nick Pannuto on 12/3/10.
+// Copyright Sneakyness, llc. 2010. All rights reserved.
+//
+
+// Import the interfaces
+#import "HelloWorldScene.h"
+#import "SneakyJoystick.h"
+#import "SneakyJoystickSkinnedJoystickExample.h"
+#import "SneakyJoystickSkinnedDPadExample.h"
+#import "SneakyButton.h"
+#import "SneakyButtonSkinnedBase.h"
+#import "ColoredCircleSprite.h"
+
+// HelloWorld implementation
+@implementation HelloWorld
+
++(id) scene
+{
+ // 'scene' is an autorelease object.
+ CCScene *scene = [CCScene node];
+
+ // 'layer' is an autorelease object.
+ HelloWorld *layer = [HelloWorld node];
+
+ // add layer as a child to scene
+ [scene addChild: layer];
+
+ // return the scene
+ return scene;
+}
+
+// on "init" you need to initialize your instance
+-(id) init
+{
+ // always call "super" init
+ // Apple recommends to re-assign "self" with the "super" return value
+ if( (self=[super init] )) {
+ self.isTouchEnabled = YES;
+
+ SneakyJoystickSkinnedBase *leftJoy = [[[SneakyJoystickSkinnedBase alloc] init] autorelease];
+ leftJoy.position = ccp(64,64);
+ leftJoy.backgroundSprite = [ColoredCircleSprite circleWithColor:ccc4(255, 0, 0, 128) radius:64];
+ leftJoy.thumbSprite = [ColoredCircleSprite circleWithColor:ccc4(0, 0, 255, 200) radius:32];
+ leftJoy.joystick = [[SneakyJoystick alloc] initWithRect:CGRectMake(0,0,128,128)];
+ leftJoystick = [leftJoy.joystick retain];
+ [self addChild:leftJoy];
+
+ SneakyButtonSkinnedBase *rightBut = [[[SneakyButtonSkinnedBase alloc] init] autorelease];
+ rightBut.position = ccp(448,32);
+ rightBut.defaultSprite = [ColoredCircleSprite circleWithColor:ccc4(255, 255, 255, 128) radius:32];
+ rightBut.activatedSprite = [ColoredCircleSprite circleWithColor:ccc4(255, 255, 255, 255) radius:32];
+ rightBut.pressSprite = [ColoredCircleSprite circleWithColor:ccc4(255, 0, 0, 255) radius:32];
+ rightBut.button = [[SneakyButton alloc] initWithRect:CGRectMake(0, 0, 64, 64)];
+ rightButton = [rightBut.button retain];
+ rightButton.isToggleable = YES;
+ [self addChild:rightBut];
+
+ [[CCDirector sharedDirector] setAnimationInterval:1.0f/60.0f];
+
+ //[self schedule:@selector(tick:) interval:1.0f/120.0f];
+ }
+ return self;
+}
+
+// on "dealloc" you need to release all your retained objects
+- (void) dealloc
+{
+ // in case you have something to dealloc, do it in this method
+ // in this particular example nothing needs to be released.
+ // cocos2d will automatically release all the children (Label)
+
+ // don't forget to call "super dealloc"
+ [super dealloc];
+}
+@end
View
@@ -0,0 +1,38 @@
+//
+// button.h
+// Classroom Demo
+//
+// Created by Nick Pannuto on 2/10/10.
+// Copyright 2010 Sneakyness, llc.. All rights reserved.
+//
+
+#import "cocos2d.h"
+
+@interface SneakyButton : CCNode <CCTargetedTouchDelegate> {
+ CGPoint center;
+
+ float radius;
+ float radiusSq;
+
+ CGRect bounds;
+ BOOL active;
+ BOOL status;
+ BOOL value;
+ BOOL isHoldable;
+ BOOL isToggleable;
+ float rateLimit;
+}
+
+@property (nonatomic, assign) BOOL status;
+@property (nonatomic, readonly) BOOL value;
+@property (nonatomic, readonly) BOOL active;
+@property (nonatomic, assign) BOOL isHoldable;
+@property (nonatomic, assign) BOOL isToggleable;
+@property (nonatomic, assign) float rateLimit;
+
+//Optimizations (keep Squared values of all radii for faster calculations) (updated internally when changing radii)
+@property (nonatomic, assign) float radius;
+
+-(id)initWithRect:(CGRect)rect;
+
+@end
Oops, something went wrong.

0 comments on commit b0312c9

Please sign in to comment.