guys,
I need help with this… its driving me nuts…
I need to position particles on the back of my sprite. My sprite is spaceship and the particles is the engine firetail. So, when the spaceship moves around the particles have to move too.
I’m having problems to come up with the right code to always get the right position.
//this is the spaceship
Point normalized = targetPoint - this->getPosition();
normalized = normalized.normalize();
float angle = CC_RADIANS_TO_DEGREES(atan2f(normalized.y, -normalized.x)) + 270;
Point desiredPosition = this->getPosition() + ( normalized * m_moveSpeed) ;
this->setPosition(desiredPosition);
this->setRotation(angle);
int x=0;
int y=0;
//trying to make the particles to follow the spaceship.. not working properly.
if(angle > 180 && angle < 270){
x= desiredPosition.x;
y= desiredPosition.y+40;
}else if(angle > 270 && angle < 360){
x= desiredPosition.x-40;
y= desiredPosition.y+40;
}else if(angle > 0 && angle < 90){
x= desiredPosition.x+40;
y= desiredPosition.y+40;
}else if(angle > 90 && angle < 180){
x= desiredPosition.x+40;
y= desiredPosition.y+40;
}
m_engine1->setPosition( Point(x,y) );
m_engine1->setRotation(angle);
any help will be appreciated… tkx