You can use BOOL porperty
if(CGRectIntersectsRect(m_Heart, m_sBirdSprite.boundingBox) && [m_sHeart[i] isVisible]){
m_sHeart[i].visible=FALSE;
m_fTime += 1;
}
Question
if(CGRectIntersectsRect(m_Heart, m_sBirdSprite.boundingBox)){
m_sHeart[i].visible=FALSE;
m_fTime += 1;
}
This is my code, and the problem is that i want to add only one value in m_fTime variable, but it is continuously adding +1 in m_fTime varible because it is in process to be intersecting, now is there any way to add only 1 value in it when it intersects?
Solution
You can use BOOL porperty
if(CGRectIntersectsRect(m_Heart, m_sBirdSprite.boundingBox) && [m_sHeart[i] isVisible]){
m_sHeart[i].visible=FALSE;
m_fTime += 1;
}
OTHER TIPS
thanks for your kind answer @Himanshu Joshi its correct in terms of logic, but bit incorrect in terms of syntax i did try the same, i am not pointing your syntax wrong, just giving the correct syntax for our new/beginner friends. and i am marking your question as right answer.
if(CGRectIntersectsRect(m_sHearts, m_sBirdSprite.boundingBox) && m_sHeart[i].visible==TRUE){
m_sHeart[i].visible=FALSE;
m_fTime += 1;
}
In expert programming a simple way to use Boolean flags. Same here you can implement the Boolean flags in your problem,
if(CGRectIntersectsRect(m_Heart, m_sBirdSprite.boundingBox) && [m_sHeart[i] isVisible]){
m_sHeart[i].visible=true;
m_fTime += 1;
}