From 5bd75b4459cf4fce667d2b5cb51e2cb5bbd11f82 Mon Sep 17 00:00:00 2001 From: dsc Date: Sun, 8 May 2011 02:08:25 -0700 Subject: [PATCH] Manual merge of chester-sparrow. --- .gitignore | 2 +- src/RootAppDelegate.m | 12 ++-- src/tanks/Game.h | 3 + src/tanks/Game.m | 26 ++++---- src/tanks/unit/Unit.h | 20 ++++++ src/tanks/unit/Unit.m | 34 ++++++++++ tanks.tmproj | 133 +++++++++++++++++++++++++++++++++++++++ tanks.xcodeproj/project.pbxproj | 36 +++++++---- 8 files changed, 232 insertions(+), 34 deletions(-) create mode 100644 src/tanks/unit/Unit.h create mode 100644 src/tanks/unit/Unit.m create mode 100644 tanks.tmproj diff --git a/.gitignore b/.gitignore index 41304c2..9408889 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Xcode -*/build/* +build *.pbxuser !default.pbxuser *.mode1v3 diff --git a/src/RootAppDelegate.m b/src/RootAppDelegate.m index 0cdfe1d..fac7681 100644 --- a/src/RootAppDelegate.m +++ b/src/RootAppDelegate.m @@ -14,9 +14,9 @@ @synthesize window; @synthesize sparrowView; -- (void)applicationDidFinishLaunching:(UIApplication *)application -{ - SP_CREATE_POOL(pool); +- (void)applicationDidFinishLaunching:(UIApplication *)application +{ + SP_CREATE_POOL(pool); [SPStage setSupportHighResolutions:YES]; [SPAudioEngine start]; @@ -31,17 +31,17 @@ SP_RELEASE_POOL(pool); } -- (void)applicationWillResignActive:(UIApplication *)application +- (void)applicationWillResignActive:(UIApplication *)application { [sparrowView stop]; } -- (void)applicationDidBecomeActive:(UIApplication *)application +- (void)applicationDidBecomeActive:(UIApplication *)application { [sparrowView start]; } -- (void)dealloc +- (void)dealloc { [sparrowView release]; [window release]; diff --git a/src/tanks/Game.h b/src/tanks/Game.h index 92a1fec..50950df 100644 --- a/src/tanks/Game.h +++ b/src/tanks/Game.h @@ -8,8 +8,11 @@ #import #import "Sparrow.h" +#import "tanks/unit/Unit.h" @interface Game : SPStage +@property(retain) Unit* unit; + @end diff --git a/src/tanks/Game.m b/src/tanks/Game.m index 7948dbb..377fb6d 100644 --- a/src/tanks/Game.m +++ b/src/tanks/Game.m @@ -11,20 +11,20 @@ @implementation Game -- (id)initWithWidth:(float)width height:(float)height -{ - if ((self = [super initWithWidth:width height:height])) - { - // this is where the code of your game will start. - // in this sample, we add just a simple quad to see - // if it works. - - SPQuad *quad = [SPQuad quadWithWidth:100 height:100]; - quad.color = 0xff0000; - quad.x = 50; - quad.y = 50; - [self addChild:quad]; +@synthesize unit; + +- (id)initWithWidth:(float)width height:(float)height { + if ( (self = [super initWithWidth:width height:height]) ){ + unit = [[Unit alloc] initWithWidth:100 height:100 X:50 Y:50]; + [self addEventListener:@selector(onTouch:) atObject:unit forType:SP_EVENT_TYPE_TOUCH]; + [self addChild:unit.quad]; } return self; } + +- (void)dealloc { + [self setUnit:nil]; + [super dealloc]; +} + @end \ No newline at end of file diff --git a/src/tanks/unit/Unit.h b/src/tanks/unit/Unit.h new file mode 100644 index 0000000..1c8fea5 --- /dev/null +++ b/src/tanks/unit/Unit.h @@ -0,0 +1,20 @@ +// +// Unit.h +// tanks +// +// Created by Doris Chen on 5/7/11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import +#import "Sparrow.h" + + +@interface Unit : NSObject { +} + +@property(nonatomic, retain) SPQuad* quad; + +-(Unit*)initWithWidth:(int)width height:(int)height X:(int)x Y:(int)y; +-(void)onTouch:(SPTouchEvent*)event; +@end diff --git a/src/tanks/unit/Unit.m b/src/tanks/unit/Unit.m new file mode 100644 index 0000000..66da593 --- /dev/null +++ b/src/tanks/unit/Unit.m @@ -0,0 +1,34 @@ +// +// Unit.m +// tanks +// +// Created by Doris Chen on 5/7/11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import "Unit.h" + + +@implementation Unit + +@synthesize quad; + +-(Unit*)initWithWidth:(int)width height:(int)height X:(int)x Y:(int)y { + quad = [SPQuad quadWithWidth:width height:height]; + quad.color = 0xff0000; + quad.x = x; + quad.y = y; + + return self; +} + +-(void)onTouch:(SPTouchEvent*)event { + SPTouch* touch = [[event touchesWithTarget:quad.parent] anyObject]; + if (touch) { + SPPoint* touchPosition = [touch locationInSpace:quad.parent]; + quad.x = touchPosition.x - quad.width / 2.0f; + quad.y = touchPosition.y - quad.height / 2.0f; + } +} + +@end diff --git a/tanks.tmproj b/tanks.tmproj new file mode 100644 index 0000000..949588f --- /dev/null +++ b/tanks.tmproj @@ -0,0 +1,133 @@ + + + + + currentDocument + tmp/tanks/tanks/tanksAppDelegate.h + documents + + + expanded + + name + src + regexFolderFilter + !.*/(junk|target|html\-template|bin\-debug|\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|egg-info))$ + sourceDirectory + src + + + expanded + + name + tanks + regexFolderFilter + !.*/(junk|target|html\-template|bin\-debug|\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|egg-info))$ + sourceDirectory + tmp/tanks + + + fileHierarchyDrawerWidth + 217 + metaData + + src/RootAppDelegate.h + + caret + + column + 0 + line + 1 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + src/RootAppDelegate.m + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tmp/tanks/tanks/Game.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tmp/tanks/tanks/Game.m + + caret + + column + 14 + line + 27 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tmp/tanks/tanks/tanksAppDelegate.h + + caret + + column + 4 + line + 20 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + tmp/tanks/tanks/tanksAppDelegate.m + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + + openDocuments + + src/RootAppDelegate.m + src/RootAppDelegate.h + tmp/tanks/tanks/Game.h + tmp/tanks/tanks/Game.m + tmp/tanks/tanks/tanksAppDelegate.h + tmp/tanks/tanks/tanksAppDelegate.m + + showFileHierarchyDrawer + + windowFrame + {{0, 0}, {1534, 1578}} + + diff --git a/tanks.xcodeproj/project.pbxproj b/tanks.xcodeproj/project.pbxproj index f593d0b..559abcf 100644 --- a/tanks.xcodeproj/project.pbxproj +++ b/tanks.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 494DE9971376927C00FDB3D7 /* libBox2D.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 494DE9961376927C00FDB3D7 /* libBox2D.a */; }; 499668C713692E2D006E8125 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499668C613692E2D006E8125 /* UIKit.framework */; }; 499668C913692E2D006E8125 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499668C813692E2D006E8125 /* Foundation.framework */; }; 499668CB13692E2D006E8125 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499668CA13692E2D006E8125 /* CoreGraphics.framework */; }; @@ -15,8 +16,6 @@ 49966919136930E8006E8125 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49966914136930E8006E8125 /* OpenAL.framework */; }; 4996691A136930E8006E8125 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49966915136930E8006E8125 /* OpenGLES.framework */; }; 4996691B136930E8006E8125 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49966916136930E8006E8125 /* QuartzCore.framework */; }; - 49F2D99A137645BF000B6B8C /* libSparrow.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 49F2D999137645BF000B6B8C /* libSparrow.a */; }; - 49F2D9AD1376462B000B6B8C /* libBox2D.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 49F2D9AC1376462B000B6B8C /* libBox2D.a */; }; 49F2D9C413764666000B6B8C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B013764666000B6B8C /* main.m */; }; 49F2D9C513764666000B6B8C /* RootAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B513764666000B6B8C /* RootAppDelegate.m */; }; 49F2D9C613764666000B6B8C /* Game.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B813764666000B6B8C /* Game.m */; }; @@ -28,9 +27,7 @@ 49F2D9CE13764710000B6B8C /* Game.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2D9B713764666000B6B8C /* Game.h */; }; 49F2D9CF13764710000B6B8C /* RootAppDelegate_iPad.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2D9BD13764666000B6B8C /* RootAppDelegate_iPad.h */; }; 49F2D9D013764710000B6B8C /* RootAppDelegate_iPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2D9C213764666000B6B8C /* RootAppDelegate_iPhone.h */; }; - 49F2D9D213764763000B6B8C /* prefix.pch in Sources */ = {isa = PBXBuildFile; fileRef = 49F2D9B213764666000B6B8C /* prefix.pch */; }; 49F2D9D713764A9B000B6B8C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 49F2D9D413764A9B000B6B8C /* InfoPlist.strings */; }; - 49F2D9D813764A9B000B6B8C /* tanks-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 49F2D9D613764A9B000B6B8C /* tanks-Info.plist */; }; 49F2DA8213764ED6000B6B8C /* SPAVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DA2613764ED5000B6B8C /* SPAVSound.h */; }; 49F2DA8313764ED6000B6B8C /* SPAVSound.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2DA2713764ED5000B6B8C /* SPAVSound.m */; }; 49F2DA8413764ED6000B6B8C /* SPAVSoundChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DA2813764ED5000B6B8C /* SPAVSoundChannel.h */; }; @@ -127,6 +124,8 @@ 49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DA1D13764ED5000B6B8C /* Sparrow.h */; }; 49F2DAF213765004000B6B8C /* GLES-Render.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DAE613765004000B6B8C /* GLES-Render.h */; }; 49F2DAF313765004000B6B8C /* GLES-Render.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49F2DAE713765004000B6B8C /* GLES-Render.mm */; }; + 49F2DB341376632E000B6B8C /* Unit.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DB321376632E000B6B8C /* Unit.h */; }; + 49F2DB351376632E000B6B8C /* Unit.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2DB331376632E000B6B8C /* Unit.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -147,6 +146,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 494DE9961376927C00FDB3D7 /* libBox2D.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libBox2D.a; sourceTree = SOURCE_ROOT; }; 499668C213692E2D006E8125 /* Tanks.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Tanks.app; sourceTree = BUILT_PRODUCTS_DIR; }; 499668C613692E2D006E8125 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 499668C813692E2D006E8125 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -156,9 +156,7 @@ 49966914136930E8006E8125 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 49966915136930E8006E8125 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 49966916136930E8006E8125 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - 49F2D999137645BF000B6B8C /* libSparrow.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libSparrow.a; sourceTree = SOURCE_ROOT; }; 49F2D99B137645DF000B6B8C /* box2d-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "box2d-ios.xcodeproj"; path = "libs/box2d/box2d-ios.xcodeproj"; sourceTree = ""; }; - 49F2D9AC1376462B000B6B8C /* libBox2D.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libBox2D.a; sourceTree = SOURCE_ROOT; }; 49F2D9B013764666000B6B8C /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 49F2D9B213764666000B6B8C /* prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prefix.pch; sourceTree = ""; }; 49F2D9B413764666000B6B8C /* RootAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootAppDelegate.h; sourceTree = ""; }; @@ -279,6 +277,8 @@ 49F2DAEA13765004000B6B8C /* iPhoneTestEntries.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = iPhoneTestEntries.mm; sourceTree = ""; }; 49F2DAEB13765004000B6B8C /* TestEntriesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestEntriesViewController.h; sourceTree = ""; }; 49F2DAEC13765004000B6B8C /* TestEntriesViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestEntriesViewController.mm; sourceTree = ""; }; + 49F2DB321376632E000B6B8C /* Unit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unit.h; sourceTree = ""; }; + 49F2DB331376632E000B6B8C /* Unit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Unit.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -286,8 +286,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 49F2D9AD1376462B000B6B8C /* libBox2D.a in Frameworks */, - 49F2D99A137645BF000B6B8C /* libSparrow.a in Frameworks */, + 494DE9971376927C00FDB3D7 /* libBox2D.a in Frameworks */, 49966917136930E8006E8125 /* AudioToolbox.framework in Frameworks */, 49966918136930E8006E8125 /* AVFoundation.framework in Frameworks */, 49966919136930E8006E8125 /* OpenAL.framework in Frameworks */, @@ -324,8 +323,7 @@ 499668C513692E2D006E8125 /* Frameworks */ = { isa = PBXGroup; children = ( - 49F2D999137645BF000B6B8C /* libSparrow.a */, - 49F2D9AC1376462B000B6B8C /* libBox2D.a */, + 494DE9961376927C00FDB3D7 /* libBox2D.a */, 49F2D99B137645DF000B6B8C /* box2d-ios.xcodeproj */, 49966912136930E8006E8125 /* AudioToolbox.framework */, 49966913136930E8006E8125 /* AVFoundation.framework */, @@ -399,6 +397,7 @@ 49F2D9B613764666000B6B8C /* tanks */ = { isa = PBXGroup; children = ( + 49F2DB311376632E000B6B8C /* unit */, 49F2D9B713764666000B6B8C /* Game.h */, 49F2D9B813764666000B6B8C /* Game.m */, ); @@ -665,6 +664,15 @@ name = libs; sourceTree = ""; }; + 49F2DB311376632E000B6B8C /* unit */ = { + isa = PBXGroup; + children = ( + 49F2DB321376632E000B6B8C /* Unit.h */, + 49F2DB331376632E000B6B8C /* Unit.m */, + ); + path = unit; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -727,6 +735,7 @@ 49F2DADD13764ED6000B6B8C /* SPUtils.h in Headers */, 49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */, 49F2DAF213765004000B6B8C /* GLES-Render.h in Headers */, + 49F2DB341376632E000B6B8C /* Unit.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -798,7 +807,6 @@ 49F2D9C713764666000B6B8C /* MainWindow_iPad.xib in Resources */, 49F2D9C913764666000B6B8C /* MainWindow_iPhone.xib in Resources */, 49F2D9D713764A9B000B6B8C /* InfoPlist.strings in Resources */, - 49F2D9D813764A9B000B6B8C /* tanks-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -809,7 +817,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 49F2D9D213764763000B6B8C /* prefix.pch in Sources */, 49F2D9C413764666000B6B8C /* main.m in Sources */, 49F2D9C513764666000B6B8C /* RootAppDelegate.m in Sources */, 49F2D9C613764666000B6B8C /* Game.m in Sources */, @@ -860,6 +867,7 @@ 49F2DADC13764ED6000B6B8C /* SPPoolObject.m in Sources */, 49F2DADE13764ED6000B6B8C /* SPUtils.m in Sources */, 49F2DAF313765004000B6B8C /* GLES-Render.mm in Sources */, + 49F2DB351376632E000B6B8C /* Unit.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -945,7 +953,7 @@ GCC_PREFIX_HEADER = src/prefix.pch; INFOPLIST_FILE = "etc/tanks-Info.plist"; LIBRARY_SEARCH_PATHS = ( - "libs/**", + "\"$(SRCROOT)/libs\"/**", "\"$(SRCROOT)\"", ); OTHER_LDFLAGS = ""; @@ -964,7 +972,7 @@ GCC_PREFIX_HEADER = src/prefix.pch; INFOPLIST_FILE = "etc/tanks-Info.plist"; LIBRARY_SEARCH_PATHS = ( - "libs/**", + "\"$(SRCROOT)/libs\"/**", "\"$(SRCROOT)\"", ); OTHER_LDFLAGS = ""; -- 1.7.0.4