From e90de91f8ced888e469e17e8ea972d957ff52225 Mon Sep 17 00:00:00 2001 From: dsc Date: Tue, 24 May 2011 13:21:13 -0700 Subject: [PATCH] Well, it seems sizes/bounds are still off a little bit, but this is still good progress. --- src/game/QQGame.mm | 4 +++- src/game/actor/QQUnit.h | 1 + src/game/actor/QQUnit.mm | 12 ++++++++---- src/game/actor/unit/QQTank.mm | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/game/QQGame.mm b/src/game/QQGame.mm index 51b05b4..985c53b 100644 --- a/src/game/QQGame.mm +++ b/src/game/QQGame.mm @@ -1,5 +1,6 @@ #import "QQGame.h" #import "game/actor/unit/QQTank.h" +#import "game/actor/QQUnit.h" #import @@ -36,7 +37,8 @@ static QQGame* _CurrentGame = NULL; _actors = [[NSMutableArray alloc] initWithCapacity:10]; _world = [[QQWorld alloc] init]; - [[[QQTank alloc] init] autorelease]; + [[[QQTank alloc] initAtX:50 y:50 width:50 height:50 color:0xFF0071] autorelease]; + [[[QQUnit alloc] initAtX:75 y:100 width:50 height:50 color:0x4596FF] autorelease]; [self addEventListener:@selector(onEnterFrame:) atObject:self forType:SP_EVENT_TYPE_ENTER_FRAME]; } diff --git a/src/game/actor/QQUnit.h b/src/game/actor/QQUnit.h index e1b509d..e963b45 100644 --- a/src/game/actor/QQUnit.h +++ b/src/game/actor/QQUnit.h @@ -18,6 +18,7 @@ - (void) setShapeFromFile:(NSString*)filename; /// initializers +- (id) initAtX:(float)x y:(float)y width:(float)w height:(float)h color:(uint)color; - (id) initAtX:(float)x y:(float)y withShape:(SPDisplayObject*)shape; diff --git a/src/game/actor/QQUnit.mm b/src/game/actor/QQUnit.mm index 1687b13..869930f 100644 --- a/src/game/actor/QQUnit.mm +++ b/src/game/actor/QQUnit.mm @@ -20,17 +20,21 @@ /// initializers - (id) init { - return [self initAtX:50 y:50 withShape:[SPQuad quadWithWidth:50 height:50 color:0xff0000]]; + return [self initAtX:50 y:50 width:50 height:50 color:0xff0071]; +} + +- (id) initAtX:(float)x y:(float)y width:(float)w height:(float)h color:(uint)color { + return [self initAtX:x y:y withShape:[SPQuad quadWithWidth:w height:h color:color]]; } - (id) initAtX:(float)x y:(float)y withShape:(SPDisplayObject*)shape { if ((self = [super initAtX:x y:y])) { self.shape = shape; - float px = self.world.scale; + float dblpx = 2*self.world.scale; b2PolygonShape box; - box.SetAsBox(shape.width/px, shape.height/px); - self.body->CreateFixture(&box, 5.0f); + box.SetAsBox(shape.width/dblpx, shape.height/dblpx); + self.body->CreateFixture(&box, 1.0f); } return self; } diff --git a/src/game/actor/unit/QQTank.mm b/src/game/actor/unit/QQTank.mm index 8587589..cb6192a 100644 --- a/src/game/actor/unit/QQTank.mm +++ b/src/game/actor/unit/QQTank.mm @@ -15,9 +15,9 @@ @synthesize coolAtk = _coolAtk; -- (id) init { - if ((self = [super init])){ - self.coolAtk = [QQCooldown cooldownWithDuration:2]; +- (id) initAtX:(float)x y:(float)y withShape:(SPDisplayObject*)shape { + if ((self = [super initAtX:x y:y withShape:shape])){ + self.coolAtk = [QQCooldown cooldownWithDuration:0.5f]; [self.game addEventListener:@selector(onTouch:) atObject:self forType:SP_EVENT_TYPE_TOUCH]; } return self; -- 1.7.0.4