Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @synthesize spawnRate = _spawnRate;
- @synthesize levelNum = _levelNum;
- @synthesize enemyHP = _enemyHP;
- @synthesize bgImageName = _bgImageName;
- - (id)initWithLevelNum:(int)levelNum
- spawnRate:(float)spawnRate
- enemyHP:(int)enemyHP
- bgImageName:(NSString *)bgImageName {
- if ((self = [super init])) {
- self.levelNum = levelNum;
- self.spawnRate = spawnRate;
- self.enemyHP = enemyHP;
- self.bgImageName = bgImageName;
- }
- return self;
- }
- ============
- #import "SpaceManagerCocos2d.h"
- #import "ParticleFactory.h"
- @class GameLayer;
- @interface Truck : cpCCSprite {
- GameLayer* _game;
- CCTexture2D* textureWheel;
- CCTexture2D* textureChassis;
- CCParticleSystemQuad* tFront;
- CCParticleSystemQuad* tMid;
- CCParticleSystemQuad* tRear;
- cpCCSprite* thrustSprite;
- cpConstraint* motor1;
- cpConstraint* motor2;
- float motorRateMultiplier;
- int thrustFactorX;
- int thrustFactorY;
- cpVect velocity;
- }
- @property(assign) cpCCNode* chassis;
- @property(assign) cpShape* bodyShape;
- -(id) initWithGame:(GameLayer*)game;
- -(void) moveTruck:(float)joyPadXVel;
- -(void) attemptBoost:(float)joyPadXVel : (float)joyPadYVel;
- -(void) showThrustGraphic;
- -(void) hideThrustGraphic;
- @end
- //.m
- #import "Truck.h"
- #import "GameLayer.h"
- @interface Truck (Private)
- -(void) buildTruckWithGame:(GameLayer*)game;
- @end
- @implementation Truck
- @synthesize chassis;
- @synthesize bodyShape;
- -(id) initWithGame:(GameLayer*)game
- {
- self = [super init];
- if (self != nil)
- {
- _game = game;
- textureWheel = [[[CCTexture2D alloc] initWithImage:[UIImage imageNamed:@"nWheel.png"]]autorelease];
- textureChassis = [[[CCTexture2D alloc] initWithImage:[UIImage imageNamed:@"chassis.png"]]autorelease];
- [self buildTruckWithGame:game];
- thrustFactorX=3000;
- thrustFactorY=4000;
- }
- return self;
- }
- -(void) buildTruckWithGame:(GameLayer*)game
- {
- motorRateMultiplier = -10;
- float springStiffness = 2000.0;
- float springDamping = 25.0;
- float springRestLength = 35.0;
- float wheelFriction = 1.2;
- float wheelMass = 10;
- float wheelRad = 25;
- #pragma mark CHASSIS
- bodyShape = [game.spaceManager addRectAt:cpv(100, 200) mass:50 width:100.0 height:50.0 rotation:0.0];
- chassis = [cpCCSprite spriteWithTexture:textureChassis];
- chassis.shape = bodyShape;
- chassis.spaceManager = game.spaceManager;
- chassis.autoFreeShapeAndBody = YES;
- [self addChild:chassis];
Add Comment
Please, Sign In to add comment