Manual merge of chester-sparrow.
authordsc <david.schoonover@gmail.com>
Sun, 8 May 2011 09:08:25 +0000 (02:08 -0700)
committerdsc <david.schoonover@gmail.com>
Sun, 8 May 2011 09:08:25 +0000 (02:08 -0700)
.gitignore
src/RootAppDelegate.m
src/tanks/Game.h
src/tanks/Game.m
src/tanks/unit/Unit.h [new file with mode: 0644]
src/tanks/unit/Unit.m [new file with mode: 0644]
tanks.tmproj [new file with mode: 0644]
tanks.xcodeproj/project.pbxproj

index 41304c2..9408889 100644 (file)
@@ -1,5 +1,5 @@
 # Xcode
-*/build/*
+build
 *.pbxuser
 !default.pbxuser
 *.mode1v3
index 0cdfe1d..fac7681 100644 (file)
@@ -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];
     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];
index 92a1fec..50950df 100644 (file)
@@ -8,8 +8,11 @@
 
 #import <Foundation/Foundation.h>
 #import "Sparrow.h"
+#import "tanks/unit/Unit.h"
 
 
 @interface Game : SPStage
 
+@property(retain) Unit* unit;
+
 @end
index 7948dbb..377fb6d 100644 (file)
 
 @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 (file)
index 0000000..1c8fea5
--- /dev/null
@@ -0,0 +1,20 @@
+//
+//  Unit.h
+//  tanks
+//
+//  Created by Doris Chen on 5/7/11.
+//  Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#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 (file)
index 0000000..66da593
--- /dev/null
@@ -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 (file)
index 0000000..949588f
--- /dev/null
@@ -0,0 +1,133 @@
+<?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>currentDocument</key>
+       <string>tmp/tanks/tanks/tanksAppDelegate.h</string>
+       <key>documents</key>
+       <array>
+               <dict>
+                       <key>expanded</key>
+                       <true/>
+                       <key>name</key>
+                       <string>src</string>
+                       <key>regexFolderFilter</key>
+                       <string>!.*/(junk|target|html\-template|bin\-debug|\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|egg-info))$</string>
+                       <key>sourceDirectory</key>
+                       <string>src</string>
+               </dict>
+               <dict>
+                       <key>expanded</key>
+                       <true/>
+                       <key>name</key>
+                       <string>tanks</string>
+                       <key>regexFolderFilter</key>
+                       <string>!.*/(junk|target|html\-template|bin\-debug|\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|egg-info))$</string>
+                       <key>sourceDirectory</key>
+                       <string>tmp/tanks</string>
+               </dict>
+       </array>
+       <key>fileHierarchyDrawerWidth</key>
+       <integer>217</integer>
+       <key>metaData</key>
+       <dict>
+               <key>src/RootAppDelegate.h</key>
+               <dict>
+                       <key>caret</key>
+                       <dict>
+                               <key>column</key>
+                               <integer>0</integer>
+                               <key>line</key>
+                               <integer>1</integer>
+                       </dict>
+                       <key>firstVisibleColumn</key>
+                       <integer>0</integer>
+                       <key>firstVisibleLine</key>
+                       <integer>0</integer>
+               </dict>
+               <key>src/RootAppDelegate.m</key>
+               <dict>
+                       <key>caret</key>
+                       <dict>
+                               <key>column</key>
+                               <integer>0</integer>
+                               <key>line</key>
+                               <integer>0</integer>
+                       </dict>
+                       <key>firstVisibleColumn</key>
+                       <integer>0</integer>
+                       <key>firstVisibleLine</key>
+                       <integer>0</integer>
+               </dict>
+               <key>tmp/tanks/tanks/Game.h</key>
+               <dict>
+                       <key>caret</key>
+                       <dict>
+                               <key>column</key>
+                               <integer>0</integer>
+                               <key>line</key>
+                               <integer>0</integer>
+                       </dict>
+                       <key>firstVisibleColumn</key>
+                       <integer>0</integer>
+                       <key>firstVisibleLine</key>
+                       <integer>0</integer>
+               </dict>
+               <key>tmp/tanks/tanks/Game.m</key>
+               <dict>
+                       <key>caret</key>
+                       <dict>
+                               <key>column</key>
+                               <integer>14</integer>
+                               <key>line</key>
+                               <integer>27</integer>
+                       </dict>
+                       <key>firstVisibleColumn</key>
+                       <integer>0</integer>
+                       <key>firstVisibleLine</key>
+                       <integer>0</integer>
+               </dict>
+               <key>tmp/tanks/tanks/tanksAppDelegate.h</key>
+               <dict>
+                       <key>caret</key>
+                       <dict>
+                               <key>column</key>
+                               <integer>4</integer>
+                               <key>line</key>
+                               <integer>20</integer>
+                       </dict>
+                       <key>firstVisibleColumn</key>
+                       <integer>0</integer>
+                       <key>firstVisibleLine</key>
+                       <integer>0</integer>
+               </dict>
+               <key>tmp/tanks/tanks/tanksAppDelegate.m</key>
+               <dict>
+                       <key>caret</key>
+                       <dict>
+                               <key>column</key>
+                               <integer>0</integer>
+                               <key>line</key>
+                               <integer>0</integer>
+                       </dict>
+                       <key>firstVisibleColumn</key>
+                       <integer>0</integer>
+                       <key>firstVisibleLine</key>
+                       <integer>0</integer>
+               </dict>
+       </dict>
+       <key>openDocuments</key>
+       <array>
+               <string>src/RootAppDelegate.m</string>
+               <string>src/RootAppDelegate.h</string>
+               <string>tmp/tanks/tanks/Game.h</string>
+               <string>tmp/tanks/tanks/Game.m</string>
+               <string>tmp/tanks/tanks/tanksAppDelegate.h</string>
+               <string>tmp/tanks/tanks/tanksAppDelegate.m</string>
+       </array>
+       <key>showFileHierarchyDrawer</key>
+       <false/>
+       <key>windowFrame</key>
+       <string>{{0, 0}, {1534, 1578}}</string>
+</dict>
+</plist>
index f593d0b..559abcf 100644 (file)
@@ -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 */; };
                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 */
 /* 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; };
                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 = "<group>"; };
-               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 = "<group>"; };
                49F2D9B213764666000B6B8C /* prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prefix.pch; sourceTree = "<group>"; };
                49F2D9B413764666000B6B8C /* RootAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootAppDelegate.h; sourceTree = "<group>"; };
                49F2DAEA13765004000B6B8C /* iPhoneTestEntries.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = iPhoneTestEntries.mm; sourceTree = "<group>"; };
                49F2DAEB13765004000B6B8C /* TestEntriesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestEntriesViewController.h; sourceTree = "<group>"; };
                49F2DAEC13765004000B6B8C /* TestEntriesViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestEntriesViewController.mm; sourceTree = "<group>"; };
+               49F2DB321376632E000B6B8C /* Unit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unit.h; sourceTree = "<group>"; };
+               49F2DB331376632E000B6B8C /* Unit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Unit.m; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                        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 */,
                499668C513692E2D006E8125 /* Frameworks */ = {
                        isa = PBXGroup;
                        children = (
-                               49F2D999137645BF000B6B8C /* libSparrow.a */,
-                               49F2D9AC1376462B000B6B8C /* libBox2D.a */,
+                               494DE9961376927C00FDB3D7 /* libBox2D.a */,
                                49F2D99B137645DF000B6B8C /* box2d-ios.xcodeproj */,
                                49966912136930E8006E8125 /* AudioToolbox.framework */,
                                49966913136930E8006E8125 /* AVFoundation.framework */,
                49F2D9B613764666000B6B8C /* tanks */ = {
                        isa = PBXGroup;
                        children = (
+                               49F2DB311376632E000B6B8C /* unit */,
                                49F2D9B713764666000B6B8C /* Game.h */,
                                49F2D9B813764666000B6B8C /* Game.m */,
                        );
                        name = libs;
                        sourceTree = "<group>";
                };
+               49F2DB311376632E000B6B8C /* unit */ = {
+                       isa = PBXGroup;
+                       children = (
+                               49F2DB321376632E000B6B8C /* Unit.h */,
+                               49F2DB331376632E000B6B8C /* Unit.m */,
+                       );
+                       path = unit;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
                                49F2DADD13764ED6000B6B8C /* SPUtils.h in Headers */,
                                49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */,
                                49F2DAF213765004000B6B8C /* GLES-Render.h in Headers */,
+                               49F2DB341376632E000B6B8C /* Unit.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                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;
                };
                        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 */,
                                49F2DADC13764ED6000B6B8C /* SPPoolObject.m in Sources */,
                                49F2DADE13764ED6000B6B8C /* SPUtils.m in Sources */,
                                49F2DAF313765004000B6B8C /* GLES-Render.mm in Sources */,
+                               49F2DB351376632E000B6B8C /* Unit.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                GCC_PREFIX_HEADER = src/prefix.pch;
                                INFOPLIST_FILE = "etc/tanks-Info.plist";
                                LIBRARY_SEARCH_PATHS = (
-                                       "libs/**",
+                                       "\"$(SRCROOT)/libs\"/**",
                                        "\"$(SRCROOT)\"",
                                );
                                OTHER_LDFLAGS = "";
                                GCC_PREFIX_HEADER = src/prefix.pch;
                                INFOPLIST_FILE = "etc/tanks-Info.plist";
                                LIBRARY_SEARCH_PATHS = (
-                                       "libs/**",
+                                       "\"$(SRCROOT)/libs\"/**",
                                        "\"$(SRCROOT)\"",
                                );
                                OTHER_LDFLAGS = "";