@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;
+ if ( (self = [super initWithWidth:width height:height]) ){
+ unit = [[Unit alloc] initWithFile:@"tank-pink.png" atX: 50.0f andY:50.0f];
+ [self addEventListener:@selector(onTouch:) atObject:unit forType:SP_EVENT_TYPE_TOUCH];
+ [self addChild:unit.quad];
+ }
+ return self;
}
- (void)dealloc {
- [self setUnit:nil];
- [super dealloc];
+ [self setUnit:nil];
+ [super dealloc];
}
@end
\ No newline at end of file
@property(nonatomic, retain) SPQuad* quad;
--(Unit*)initWithWidth:(int)width height:(int)height X:(int)x Y:(int)y;
+-(void)dealloc;
+-(Unit*)initWithWidth:(float)width height:(float)height X:(float)x Y:(float)y color:(int)color;
+-(Unit*)initWithFile:(NSString*)fileName atX:(float)x andY:(float)y;
+
-(void)onTouch:(SPTouchEvent*)event;
+
@end
@synthesize quad;
--(Unit*)initWithWidth:(int)width height:(int)height X:(int)x Y:(int)y {
- quad = [SPQuad quadWithWidth:width height:height];
- quad.color = 0xff0000;
+-(void)dealloc {
+ [quad release];
+ [super dealloc];
+}
+
+-(Unit*)initWithWidth:(float)width height:(float)height X:(float)x Y:(float)y color:(int)color {
+ quad = [[SPQuad alloc] initWithWidth:width height:height];
+ quad.color = color;
+ quad.x = x;
+ quad.y = y;
+
+ return self;
+}
+
+-(Unit*)initWithFile:(NSString*)fileName atX:(float)x andY:(float)y
+{
+ quad = [[SPImage alloc] initWithContentsOfFile:fileName];
quad.x = x;
quad.y = y;
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 */; };
+ 4B8B2A3213784D2D00CA4076 /* tank-pink.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B8B2A3113784D2D00CA4076 /* tank-pink.png */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
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>"; };
+ 4B8B2A3113784D2D00CA4076 /* tank-pink.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "tank-pink.png"; path = "textures/tank-pink.png"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
49F2D9D313764A9B000B6B8C /* etc */ = {
isa = PBXGroup;
children = (
+ 4B8B2A3313784D3400CA4076 /* textures */,
49F2D9D413764A9B000B6B8C /* InfoPlist.strings */,
49F2D9D613764A9B000B6B8C /* tanks-Info.plist */,
);
path = unit;
sourceTree = "<group>";
};
+ 4B8B2A3313784D3400CA4076 /* textures */ = {
+ isa = PBXGroup;
+ children = (
+ 4B8B2A3113784D2D00CA4076 /* tank-pink.png */,
+ );
+ name = textures;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
49F2D9C713764666000B6B8C /* MainWindow_iPad.xib in Resources */,
49F2D9C913764666000B6B8C /* MainWindow_iPhone.xib in Resources */,
49F2D9D713764A9B000B6B8C /* InfoPlist.strings in Resources */,
+ 4B8B2A3213784D2D00CA4076 /* tank-pink.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};