i init my sprite using this method:
-(id)initAttackerWithType:(ShapeType)type withPosition:(CGPoint)pos world:(b2World*)world andEnergy:(float)energy {
if(([self initWithTexture:[[CCTextureCache sharedTextureCache]addImage:@"circle.png"]])){
self.tag=type;
self.color= type == Enemy ? ccc3(255, 0, 0) : ccc3(0, 255, 0);
self.scale=energy *.22/PTM_RATIO; //scale depending on energy
// 0.22 gets the sprite scale to synchronize with shape radius
self.position=pos;
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(pos.x/PTM_RATIO, pos.y/PTM_RATIO);
_body = world->CreateBody(&bodyDef);
b2CircleShape dynamicCircle;
dynamicCircle.m_radius=energy/PTM_RATIO; //radius depending on energy
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicCircle;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0;
fixtureDef.restitution = 1;
_body->CreateFixture(&fixtureDef);
fixtureDef.userData=self;
_body->SetUserData(self);
}else self = nil;
return self ? self : nil;
}
Everything regarding mechanics, collisions works well. The only problem is that the sprite scale doesn't change according to energy. Don't get me wrong, it's beeing added on the screen as it should, but only at scale 1.
When i log the scale, it logs at the scale it should be but the actual image is not.
I'm sure there's something simple and easy that i overlooked but i cannot figure out what.