}
#endif
- if (self = [super init])
+ if ((self = [super init]))
{
mAlpha = 1.0f;
mScaleX = 1.0f;
{
if (!texture) [NSException raise:SP_EXC_INVALID_OPERATION format:@"texture cannot be nil!"];
- if (self = [super initWithWidth:texture.width height:texture.height])
+ if ((self = [super initWithWidth:texture.width height:texture.height]))
{
self.texture = texture;
mTexCoords[0] = 0.0f; mTexCoords[1] = 0.0f;
- (id)initWithWidth:(float)width height:(float)height color:(uint)color
{
- if (self = [super init])
+ if ((self = [super init]))
{
mVertexCoords[2] = width;
mVertexCoords[5] = height;
@property(nonatomic, retain) SPQuad* quad;
-(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;
return self;
}
--(Unit*)initWithFile:(NSString*)fileName atX:(float)x andY:(float)y
-{
+-(Unit*)initWithFile:(NSString*)fileName atX:(float)x andY:(float)y {
quad = [[SPImage alloc] initWithContentsOfFile:fileName];
quad.x = x;
quad.y = y;
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;
+ quad.x = touchPosition.x - quad.width * 0.5f;
+ quad.y = touchPosition.y - quad.height * 0.5f;
}
}