Permalink
Browse files

xcode project misc changes

  • Loading branch information...
1 parent 2add5ae commit b705ac96938df1140462c9c86a31c4c4b7344cdb @ricardoquesada ricardoquesada committed Jul 26, 2010
View
282 Resources/zwoptex/grossini-generic.plist
@@ -0,0 +1,282 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>frames</key>
+ <dict>
+ <key>grossini_dance_generic_01.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 7}, {51, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, 0}</string>
+ <key>spriteSize</key>
+ <string>{85, 121}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <false/>
+ <key>textureRect</key>
+ <string>{{2, 125}, {121, 85}}</string>
+ <key>textureRotated</key>
+ <true/>
+ </dict>
+ <key>grossini_dance_generic_02.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{5, 7}, {63, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, 0}</string>
+ <key>spriteSize</key>
+ <string>{85, 121}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <false/>
+ <key>textureRect</key>
+ <string>{{299, 2}, {85, 121}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_03.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{5, 7}, {63, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{-6, -1}</string>
+ <key>spriteSize</key>
+ <string>{63, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{2, 236}, {109, 63}}</string>
+ <key>textureRotated</key>
+ <true/>
+ </dict>
+ <key>grossini_dance_generic_04.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{5, 7}, {75, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, -1}</string>
+ <key>spriteSize</key>
+ <string>{75, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{202, 125}, {75, 109}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_05.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{5, 7}, {75, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, -1}</string>
+ <key>spriteSize</key>
+ <string>{75, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{125, 125}, {75, 109}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_06.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{5, 7}, {63, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, 0}</string>
+ <key>spriteSize</key>
+ <string>{85, 121}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <false/>
+ <key>textureRect</key>
+ <string>{{212, 2}, {85, 121}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_07.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{5, 7}, {63, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{-6, -1}</string>
+ <key>spriteSize</key>
+ <string>{63, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{279, 125}, {63, 109}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_08.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 7}, {51, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, -1}</string>
+ <key>spriteSize</key>
+ <string>{51, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{409, 125}, {51, 109}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_09.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 7}, {51, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, -1}</string>
+ <key>spriteSize</key>
+ <string>{51, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{224, 236}, {109, 51}}</string>
+ <key>textureRotated</key>
+ <true/>
+ </dict>
+ <key>grossini_dance_generic_10.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 7}, {63, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{6, -1}</string>
+ <key>spriteSize</key>
+ <string>{63, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{344, 125}, {63, 109}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_11.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 7}, {63, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{6, -1}</string>
+ <key>spriteSize</key>
+ <string>{63, 109}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <true/>
+ <key>textureRect</key>
+ <string>{{113, 236}, {109, 63}}</string>
+ <key>textureRotated</key>
+ <true/>
+ </dict>
+ <key>grossini_dance_generic_12.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 10}, {51, 107}}</string>
+ <key>spriteOffset</key>
+ <string>{0, 0}</string>
+ <key>spriteSize</key>
+ <string>{85, 121}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <false/>
+ <key>textureRect</key>
+ <string>{{2, 2}, {85, 121}}</string>
+ <key>textureRotated</key>
+ <false/>
+ </dict>
+ <key>grossini_dance_generic_13.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 7}, {51, 109}}</string>
+ <key>spriteOffset</key>
+ <string>{0, 0}</string>
+ <key>spriteSize</key>
+ <string>{85, 121}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <false/>
+ <key>textureRect</key>
+ <string>{{386, 2}, {121, 85}}</string>
+ <key>textureRotated</key>
+ <true/>
+ </dict>
+ <key>grossini_dance_generic_14.png</key>
+ <dict>
+ <key>aliases</key>
+ <array/>
+ <key>spriteColorRect</key>
+ <string>{{17, 10}, {51, 107}}</string>
+ <key>spriteOffset</key>
+ <string>{0, 0}</string>
+ <key>spriteSize</key>
+ <string>{85, 121}</string>
+ <key>spriteSourceSize</key>
+ <string>{85, 121}</string>
+ <key>spriteTrimmed</key>
+ <false/>
+ <key>textureRect</key>
+ <string>{{89, 2}, {121, 85}}</string>
+ <key>textureRotated</key>
+ <true/>
+ </dict>
+ </dict>
+ <key>metadata</key>
+ <dict>
+ <key>format</key>
+ <integer>3</integer>
+ <key>size</key>
+ <string>{512, 512}</string>
+ </dict>
+</dict>
+</plist>
View
BIN Resources/zwoptex/grossini-generic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
198 Resources/zwoptex/grossini.plist
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>frames</key>
+ <dict>
+ <key>grossini_dance_01.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{2, 125}, {85, 121}}</string>
+ <key>offset</key>
+ <string>{0, 0}</string>
+ <key>rotated</key>
+ <true/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_02.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{299, 2}, {85, 121}}</string>
+ <key>offset</key>
+ <string>{0, 0}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_03.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{2, 236}, {63, 109}}</string>
+ <key>offset</key>
+ <string>{-6, -1}</string>
+ <key>rotated</key>
+ <true/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_04.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{202, 125}, {75, 109}}</string>
+ <key>offset</key>
+ <string>{0, -1}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_05.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{125, 125}, {75, 109}}</string>
+ <key>offset</key>
+ <string>{0, -1}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_06.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{212, 2}, {85, 121}}</string>
+ <key>offset</key>
+ <string>{0, 0}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_07.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{279, 125}, {63, 109}}</string>
+ <key>offset</key>
+ <string>{-6, -1}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_08.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{409, 125}, {51, 109}}</string>
+ <key>offset</key>
+ <string>{0, -1}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_09.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{224, 236}, {51, 109}}</string>
+ <key>offset</key>
+ <string>{0, -1}</string>
+ <key>rotated</key>
+ <true/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_10.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{344, 125}, {63, 109}}</string>
+ <key>offset</key>
+ <string>{6, -1}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_11.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{113, 236}, {63, 109}}</string>
+ <key>offset</key>
+ <string>{6, -1}</string>
+ <key>rotated</key>
+ <true/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_12.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{2, 2}, {85, 121}}</string>
+ <key>offset</key>
+ <string>{0, 0}</string>
+ <key>rotated</key>
+ <false/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_13.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{386, 2}, {85, 121}}</string>
+ <key>offset</key>
+ <string>{0, 0}</string>
+ <key>rotated</key>
+ <true/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ <key>grossini_dance_14.png</key>
+ <dict>
+ <key>frame</key>
+ <string>{{89, 2}, {85, 121}}</string>
+ <key>offset</key>
+ <string>{0, 0}</string>
+ <key>rotated</key>
+ <true/>
+ <key>sourceColorRect</key>
+ <string>{85, 121}</string>
+ <key>sourceSize</key>
+ <string>{85, 121}</string>
+ </dict>
+ </dict>
+ <key>metadata</key>
+ <dict>
+ <key>format</key>
+ <integer>2</integer>
+ <key>size</key>
+ <string>{512, 512}</string>
+ </dict>
+</dict>
+</plist>
View
BIN Resources/zwoptex/grossini.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Resources/zwoptex/grossini.zss
Binary file not shown.
View
24 ZwoptexTest.h
@@ -0,0 +1,24 @@
+#import "cocos2d.h"
+
+//CLASS INTERFACE
+@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate, UIApplicationDelegate>
+{
+ UIWindow *window;
+}
+@end
+
+@interface SpriteDemo: CCLayer
+{
+ CCTextureAtlas *atlas;
+}
+-(NSString*) title;
+-(NSString*) subtitle;
+@end
+
+
+@interface SpriteFrameCacheTests : SpriteDemo
+{
+ CCSprite *sprite1, *sprite2;
+ int counter;
+}
+@end
View
339 ZwoptexTest.m
@@ -0,0 +1,339 @@
+//
+// Sprite Demo
+// a cocos2d example
+// http://www.cocos2d-iphone.org
+//
+
+// cocos import
+#import "cocos2d.h"
+
+// local import
+#import "SpriteTest.h"
+
+static int sceneIdx=-1;
+static NSString *transitions[] = {
+ @"SpriteFrameCacheTests",
+};
+
+Class nextAction()
+{
+
+ sceneIdx++;
+ sceneIdx = sceneIdx % ( sizeof(transitions) / sizeof(transitions[0]) );
+ NSString *r = transitions[sceneIdx];
+ Class c = NSClassFromString(r);
+ return c;
+}
+
+Class backAction()
+{
+ sceneIdx--;
+ int total = ( sizeof(transitions) / sizeof(transitions[0]) );
+ if( sceneIdx < 0 )
+ sceneIdx += total;
+
+ NSString *r = transitions[sceneIdx];
+ Class c = NSClassFromString(r);
+ return c;
+}
+
+Class restartAction()
+{
+ NSString *r = transitions[sceneIdx];
+ Class c = NSClassFromString(r);
+ return c;
+}
+
+#pragma mark -
+#pragma mark SpriteDemo
+
+@implementation SpriteDemo
+-(id) init
+{
+ if( (self = [super init]) ) {
+
+
+ CGSize s = [[CCDirector sharedDirector] winSize];
+
+ CCLabel* label = [CCLabel labelWithString:[self title] fontName:@"Arial" fontSize:26];
+ [self addChild: label z:1];
+ [label setPosition: ccp(s.width/2, s.height-50)];
+
+ NSString *subtitle = [self subtitle];
+ if( subtitle ) {
+ CCLabel* l = [CCLabel labelWithString:subtitle fontName:@"Thonburi" fontSize:16];
+ [self addChild:l z:1];
+ [l setPosition:ccp(s.width/2, s.height-80)];
+ }
+
+ /*
+ CCMenuItemImage *item1 = [CCMenuItemImage itemFromNormalImage:@"b1.png" selectedImage:@"b2.png" target:self selector:@selector(backCallback:)];
+ CCMenuItemImage *item2 = [CCMenuItemImage itemFromNormalImage:@"r1.png" selectedImage:@"r2.png" target:self selector:@selector(restartCallback:)];
+ CCMenuItemImage *item3 = [CCMenuItemImage itemFromNormalImage:@"f1.png" selectedImage:@"f2.png" target:self selector:@selector(nextCallback:)];
+
+ CCMenu *menu = [CCMenu menuWithItems:item1, item2, item3, nil];
+
+ menu.position = CGPointZero;
+ item1.position = ccp( s.width/2 - 100,30);
+ item2.position = ccp( s.width/2, 30);
+ item3.position = ccp( s.width/2 + 100,30);
+ [self addChild: menu z:1];
+ */
+ }
+ return self;
+}
+
+-(void) dealloc
+{
+ [super dealloc];
+}
+
+-(void) restartCallback: (id) sender
+{
+ CCScene *s = [CCScene node];
+ [s addChild: [restartAction() node]];
+ [[CCDirector sharedDirector] replaceScene: s];
+}
+
+-(void) nextCallback: (id) sender
+{
+ CCScene *s = [CCScene node];
+ [s addChild: [nextAction() node]];
+ [[CCDirector sharedDirector] replaceScene: s];
+}
+
+-(void) backCallback: (id) sender
+{
+ CCScene *s = [CCScene node];
+ [s addChild: [backAction() node]];
+ [[CCDirector sharedDirector] replaceScene: s];
+}
+
+-(NSString*) title
+{
+ return @"No title";
+}
+
+-(NSString*) subtitle
+{
+ return nil;
+}
+@end
+
+
+
+#pragma mark -
+#pragma mark Sprite CCSpriteFrameCache Tests
+
+@implementation SpriteFrameCacheTests
+
+-(id) init
+{
+ if( (self=[super init]) ) {
+
+ CGSize s = [[CCDirector sharedDirector] winSize];
+
+ [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"zwoptex/grossini.plist"];
+ [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"zwoptex/grossini-generic.plist"];
+
+ CCColorLayer *layer1 = [CCColorLayer layerWithColor:ccc4(255, 0, 0, 255) width:85 height:121];
+ layer1.position = ccp(s.width/2-80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f));
+ [self addChild:layer1];
+
+ sprite1 = [CCSprite spriteWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"grossini_dance_01.png"]];
+ sprite1.position = ccp( s.width/2-80, s.height/2);
+ [self addChild:sprite1];
+
+ sprite1.flipX = NO;
+ sprite1.flipY = NO;
+
+ CCColorLayer *layer2 = [CCColorLayer layerWithColor:ccc4(255, 0, 0, 255) width:85 height:121];
+ layer2.position = ccp(s.width/2+80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f));
+ [self addChild:layer2];
+
+ sprite2 = [CCSprite spriteWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"grossini_dance_generic_01.png"]];
+ sprite2.position = ccp( s.width/2 + 80, s.height/2);
+ [self addChild:sprite2];
+
+ sprite2.flipX = NO;
+ sprite2.flipY = NO;
+
+ [self schedule:@selector(startIn05Secs:) interval:1.0f];
+
+ counter = 0;
+
+ }
+ return self;
+}
+
+-(void) startIn05Secs:(ccTime)dt
+{
+ [self unschedule:_cmd];
+ [self schedule:@selector(flipSprites:) interval:0.5f];
+}
+
+static int spriteFrameIndex = 0;
+-(void) flipSprites:(ccTime)dt
+{
+ counter ++;
+
+ BOOL fx = NO;
+ BOOL fy = NO;
+ int i = counter % 4;
+
+ switch ( i ) {
+ case 0:
+ fx = NO;
+ fy = NO;
+ break;
+ case 1:
+ fx = YES;
+ fy = NO;
+ break;
+ case 2:
+ fx = NO;
+ fy = YES;
+ break;
+ case 3:
+ fx = YES;
+ fy = YES;
+ break;
+ }
+
+ sprite1.flipX = sprite2.flipX = fx;
+ sprite1.flipY = sprite2.flipY = fy;
+
+ if(++spriteFrameIndex > 14) {
+ spriteFrameIndex = 1;
+ }
+ [sprite1 setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"grossini_dance_%02d.png",spriteFrameIndex]]];
+ [sprite2 setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"grossini_dance_generic_%02d.png",spriteFrameIndex]]];
+}
+
+- (void) dealloc
+{
+ [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
+ [super dealloc];
+}
+
+-(NSString *) title
+{
+ return @"Zwoptex Tests";
+}
+
+-(NSString*) subtitle
+{
+ return @"Coordinate Formats, Rotation, Trimming, flipX/Y";
+}
+@end
+
+#pragma mark -
+#pragma mark AppDelegate
+
+// CLASS IMPLEMENTATIONS
+@implementation AppController
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ // Init the window
+ window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+
+ // must be called before any othe call to the director
+ [CCDirector setDirectorType:kCCDirectorTypeDisplayLink];
+
+ // before creating any layer, set the landscape mode
+ CCDirector *director = [CCDirector sharedDirector];
+
+ // landscape orientation
+ [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
+
+ // set FPS at 60
+ [director setAnimationInterval:1.0/60];
+
+ // Display FPS: yes
+ [director setDisplayFPS:YES];
+
+ // Create an EAGLView with a RGB8 color buffer, and a depth buffer of 24-bits
+ EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
+ pixelFormat:kEAGLColorFormatRGBA8
+ depthFormat:GL_DEPTH_COMPONENT24_OES
+ preserveBackbuffer:NO];
+
+ // attach the openglView to the director
+ [director setOpenGLView:glView];
+
+ // 2D projection
+ // [director setProjection:kCCDirectorProjection2D];
+
+ // To use High-Res un comment the following line
+ // [director setContentScaleFactor:2];
+
+ // make the OpenGLView a child of the main window
+ [window addSubview:glView];
+
+ // make main window visible
+ [window makeKeyAndVisible];
+
+ // Default texture format for PNG/BMP/TIFF/JPEG/GIF images
+ // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
+ // You can change anytime.
+ [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
+
+ // create the main scene
+ CCScene *scene = [CCScene node];
+ [scene addChild: [nextAction() node]];
+
+
+ // and run it!
+ [director runWithScene: scene];
+
+ return YES;
+}
+
+// getting a call, pause the game
+-(void) applicationWillResignActive:(UIApplication *)application
+{
+ [[CCDirector sharedDirector] pause];
+}
+
+// call got rejected
+-(void) applicationDidBecomeActive:(UIApplication *)application
+{
+ [[CCDirector sharedDirector] resume];
+}
+
+-(void) applicationDidEnterBackground:(UIApplication*)application
+{
+ [[CCDirector sharedDirector] stopAnimation];
+}
+
+-(void) applicationWillEnterForeground:(UIApplication*)application
+{
+ [[CCDirector sharedDirector] startAnimation];
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ CCDirector *director = [CCDirector sharedDirector];
+ [[director openGLView] removeFromSuperview];
+ [director end];
+}
+
+// purge memory
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
+{
+ [[CCDirector sharedDirector] purgeCachedData];
+}
+
+// next delta time will be zero
+-(void) applicationSignificantTimeChange:(UIApplication *)application
+{
+ [[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
+}
+
+- (void) dealloc
+{
+ [window release];
+ [super dealloc];
+}
+@end
View
50 cocos2d/CCSpriteFrameCache.m
@@ -93,13 +93,11 @@ -(void) dealloc
-(void) addSpriteFramesWithDictionary:(NSDictionary*)dictionary texture:(CCTexture2D*)texture
{
/*
- Supported Zwoptex Formats:
- enum {
- ZWTCoordinatesListXMLFormat_Legacy = 0 // flash version
- ZWTCoordinatesListXMLFormat_v1_0 = 1, // desktop version
- ZWTCoordinatesListXMLFormat_v1_1 = 2, // desktop version - adds rotated support
- ZWTCoordinatesListXMLFormat_v1_2 = 3, // desktop version - adds name aliasing support
- };
+ Supported Zwoptex Formats:
+ ZWTCoordinatesFormatOptionXMLLegacy = 0, // Flash Version
+ ZWTCoordinatesFormatOptionXML1_0 = 1, // Desktop Version 0.0 - 0.4b
+ ZWTCoordinatesFormatOptionXML1_1 = 2, // Desktop Version 1.0.0 - 1.0.1
+ ZWTCoordinatesFormatOptionXML1_2 = 3, // Desktop Version 1.0.2+
*/
NSDictionary *metadataDict = [dictionary objectForKey:@"metadata"];
NSDictionary *framesDict = [dictionary objectForKey:@"frames"];
@@ -137,30 +135,42 @@ -(void) addSpriteFramesWithDictionary:(NSDictionary*)dictionary texture:(CCTextu
oh = abs(oh);
// create frame
spriteFrame = [CCSpriteFrame frameWithTexture:texture rect:CGRectMake(x, y, w, h) rotated:NO offset:CGPointMake(ox, oy) originalSize:CGSizeMake(ow, oh)];
- } else if(format == 1 || format == 2 || format == 3) {
+ } else if(format == 1 || format == 2) {
CGRect frame = CGRectFromString([frameDict objectForKey:@"frame"]);
BOOL rotated = NO;
// rotation
- if(format == 2 || format == 3)
+ if(format == 2)
rotated = [[frameDict objectForKey:@"rotated"] boolValue];
- // name aliases
- if(format == 3) {
- NSArray *aliases = [frameDict objectForKey:@"aliases"];
- for(NSString *alias in aliases) {
- if( [spriteFramesAliases_ objectForKey:alias] )
- CCLOG(@"cocos2d: WARNING: an alias with name %@ already exists",alias);
-
- [spriteFramesAliases_ setObject:frameDictKey forKey:alias];
- }
- }
-
CGPoint offset = CGPointFromString([frameDict objectForKey:@"offset"]);
CGSize sourceSize = CGSizeFromString([frameDict objectForKey:@"sourceSize"]);
// create frame
spriteFrame = [CCSpriteFrame frameWithTexture:texture rect:frame rotated:rotated offset:offset originalSize:sourceSize];
+ } else if(format == 3) {
+ // get values
+ CGSize spriteSize = CGSizeFromString([frameDict objectForKey:@"spriteSize"]);
+ CGPoint spriteOffset = CGPointFromString([frameDict objectForKey:@"spriteOffset"]);
+ CGSize spriteSourceSize = CGSizeFromString([frameDict objectForKey:@"spriteSourceSize"]);
+ CGRect textureRect = CGRectFromString([frameDict objectForKey:@"textureRect"]);
+ BOOL textureRotated = [[frameDict objectForKey:@"textureRotated"] boolValue];
+
+ // get aliases
+ NSArray *aliases = [frameDict objectForKey:@"aliases"];
+ for(NSString *alias in aliases) {
+ if( [spriteFramesAliases_ objectForKey:alias] )
+ CCLOG(@"cocos2d: WARNING: an alias with name %@ already exists",alias);
+
+ [spriteFramesAliases_ setObject:frameDictKey forKey:alias];
+ }
+
+ // create frame
+ spriteFrame = [CCSpriteFrame frameWithTexture:texture
+ rect:CGRectMake(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height)
+ rotated:textureRotated
+ offset:spriteOffset
+ originalSize:spriteSourceSize];
}
// add sprite frame

0 comments on commit b705ac9

Please sign in to comment.