@ set widht, height and skin in diff class
code:
//////////////////////////////////
- (id)init {
if(self = [super init]) {
[self setBodyDef:new b2BodyDef];
[self setShapeDef:new b2PolygonDef];
[self setSize:CGSizeMake(64.0f, 64.0f)];
[self setHighlightedView:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ObstacleHighlighted.png"]] autorelease]];/// skin code by default
[self setNormalView:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ObstacleNormal.png"]] autorelease]];// skin at collision
}
return self;
}
////////////////////////
Obstacle *anObstacle = [[[Obstacle alloc] init] autorelease];
[anObstacle setPosition:CGPointMake(60.0f, 130.0f)];
[anObstacle setRotation:45.0f];
[self addActor:anObstacle];
No comments:
Post a Comment